summaryrefslogtreecommitdiff
path: root/addons/analytic
diff options
context:
space:
mode:
Diffstat (limited to 'addons/analytic')
-rw-r--r--addons/analytic/analytic.py167
-rw-r--r--addons/analytic/i18n/sr.po181
2 files changed, 148 insertions, 200 deletions
diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py
index f6263bfeb0d..1eb904e59d7 100644
--- a/addons/analytic/analytic.py
+++ b/addons/analytic/analytic.py
@@ -28,130 +28,65 @@ class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
_description = 'Analytic Account'
- def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, context=None):
- # Handle multi-currency on each level of analytic account
- # This is a refactoring of _balance_calc computation
- cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),))
- currency = dict(cr.fetchall())
- res_currency= self.pool.get('res.currency')
+ def _compute_level_tree(self, cr, uid, ids, child_ids, res, field_names, context=None):
+ def recursive_computation(account_id, res):
+ account = self.browse(cr, uid, account_id)
+ for son in account.child_ids:
+ res = recursive_computation(son.id, res)
+ for field in field_names:
+ res[account.id][field] += res[son.id][field]
+ return res
for account in self.browse(cr, uid, ids, context=context):
- if account.id not in ids2:
+ if account.id not in child_ids:
continue
- for child in account.child_ids:
- if child.id != account.id:
- res.setdefault(account.id, 0.0)
- if currency[child.id] != currency[account.id]:
- res[account.id] += res_currency.compute(cr, uid, currency[child.id], currency[account.id], res.get(child.id, 0.0), context=context)
- else:
- res[account.id] += res.get(child.id, 0.0)
-
- cur_obj = res_currency.browse(cr, uid, currency.values(), context=context)
- cur_obj = dict([(o.id, o) for o in cur_obj])
- for id in ids:
- if id in ids2:
- res[id] = res_currency.round(cr, uid, cur_obj[currency[id]], res.get(id,0.0))
-
- return dict([(i, res[i]) for i in ids ])
+ res = recursive_computation(account.id, res)
+ return res
- def _credit_calc(self, cr, uid, ids, name, arg, context=None):
+ def _debit_credit_bal_qtty(self, cr, uid, ids, name, arg, context=None):
res = {}
if context is None:
context = {}
- parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
- for i in ids:
- res.setdefault(i,0.0)
+ child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
+ for i in child_ids:
+ res[i] = {}
+ for n in name:
+ res[i][n] = 0.0
- if not parent_ids:
+ if not child_ids:
return res
where_date = ''
+ where_clause_args = [tuple(child_ids)]
if context.get('from_date', False):
- where_date += " AND l.date >= '" + context['from_date'] + "'"
+ where_date += " AND l.date >= %s"
+ where_clause_args += [context['from_date']]
if context.get('to_date', False):
- where_date += " AND l.date <= '" + context['to_date'] + "'"
- cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
- r = dict(cr.fetchall())
- return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context)
-
- def _debit_calc(self, cr, uid, ids, name, arg, context=None):
- res = {}
- if context is None:
- context = {}
- parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
- for i in ids:
- res.setdefault(i,0.0)
-
- if not parent_ids:
- return res
-
- where_date = ''
- if context.get('from_date',False):
- where_date += " AND l.date >= '" + context['from_date'] + "'"
- if context.get('to_date',False):
- where_date += " AND l.date <= '" + context['to_date'] + "'"
- cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),))
- r = dict(cr.fetchall())
- return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context=context)
-
- def _balance_calc(self, cr, uid, ids, name, arg, context=None):
- res = {}
- if context is None:
- context = {}
-
- parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
- for i in ids:
- res.setdefault(i,0.0)
-
- if not parent_ids:
- return res
-
- where_date = ''
- if context.get('from_date',False):
- where_date += " AND l.date >= '" + context['from_date'] + "'"
- if context.get('to_date',False):
- where_date += " AND l.date <= '" + context['to_date'] + "'"
- cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
-
- for account_id, sum in cr.fetchall():
- res[account_id] = sum
- return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
-
- def _quantity_calc(self, cr, uid, ids, name, arg, context=None):
- #XXX must convert into one uom
- res = {}
- if context is None:
- context = {}
-
- parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
-
- for i in ids:
- res.setdefault(i,0.0)
-
- if not parent_ids:
- return res
-
- where_date = ''
- if context.get('from_date',False):
- where_date += " AND l.date >= '" + context['from_date'] + "'"
- if context.get('to_date',False):
- where_date += " AND l.date <= '" + context['to_date'] + "'"
-
- cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
- FROM account_analytic_account a \
- LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \
- WHERE a.id IN %s GROUP BY a.id',(tuple(parent_ids),))
-
- for account_id, sum in cr.fetchall():
- res[account_id] = sum
-
- for account in self.browse(cr, uid, ids, context=context):
- if account.id not in parent_ids:
- continue
- for child in account.child_ids:
- if child.id != account.id:
- res.setdefault(account.id, 0.0)
- res[account.id] += res.get(child.id, 0.0)
- return dict([(i, res[i]) for i in ids])
+ where_date += " AND l.date <= %s"
+ where_clause_args += [context['to_date']]
+ cr.execute("""
+ SELECT a.id,
+ sum(
+ CASE WHEN l.amount > 0
+ THEN l.amount
+ ELSE 0.0
+ END
+ ) as debit,
+ sum(
+ CASE WHEN l.amount < 0
+ THEN -l.amount
+ ELSE 0.0
+ END
+ ) as credit,
+ COALESCE(SUM(l.amount),0) AS balance,
+ COALESCE(SUM(l.unit_amount),0) AS quantity
+ FROM account_analytic_account a
+ LEFT JOIN account_analytic_line l ON (a.id = l.account_id)
+ WHERE a.id IN %s
+ """ + where_date + """
+ GROUP BY a.id""", where_clause_args)
+ for ac_id, debit, credit, balance, quantity in cr.fetchall():
+ res[ac_id] = {'debit': debit, 'credit': credit, 'balance': balance, 'quantity': quantity}
+ return self._compute_level_tree(cr, uid, ids, child_ids, res, ['debit', 'credit', 'balance', 'quantity'], context)
def name_get(self, cr, uid, ids, context=None):
if not ids:
@@ -180,10 +115,10 @@ class account_analytic_account(osv.osv):
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'),
- 'balance': fields.function(_balance_calc, method=True, type='float', string='Balance'),
- 'debit': fields.function(_debit_calc, method=True, type='float', string='Debit'),
- 'credit': fields.function(_credit_calc, method=True, type='float', string='Credit'),
- 'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
+ 'balance': fields.function(_debit_credit_bal_qtty, method=True, type='float', string='Balance', multi='debit_credit_bal_qtty', digits_compute=dp.get_precision('Account')),
+ 'debit': fields.function(_debit_credit_bal_qtty, method=True, type='float', string='Debit', multi='debit_credit_bal_qtty', digits_compute=dp.get_precision('Account')),
+ 'credit': fields.function(_debit_credit_bal_qtty, method=True, type='float', string='Credit', multi='debit_credit_bal_qtty', digits_compute=dp.get_precision('Account')),
+ 'quantity': fields.function(_debit_credit_bal_qtty, method=True, type='float', string='Quantity', multi='debit_credit_bal_qtty'),
'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'contact_id': fields.many2one('res.partner.address', 'Contact'),
diff --git a/addons/analytic/i18n/sr.po b/addons/analytic/i18n/sr.po
index 77fb1553933..ed287335040 100644
--- a/addons/analytic/i18n/sr.po
+++ b/addons/analytic/i18n/sr.po
@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2010-06-18 10:59+0000\n"
-"PO-Revision-Date: 2010-10-15 08:47+0000\n"
+"POT-Creation-Date: 2010-10-18 17:46+0000\n"
+"PO-Revision-Date: 2010-10-26 08:24+0000\n"
"Last-Translator: OpenERP Administrators <Unknown>\n"
"Language-Team: Serbian <sr@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2010-10-16 04:48+0000\n"
+"X-Launchpad-Export-Date: 2010-10-27 04:59+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: analytic
@@ -23,14 +23,6 @@ msgid "Child Accounts"
msgstr "Podređeni Nalozi"
#. module: analytic
-#: help:account.analytic.line,amount_currency:0
-msgid ""
-"The amount expressed in the related account currency if not equal to the "
-"company one."
-msgstr ""
-"Vrednost izrazena u datom iznosu valute ako nije jednaka valuti preduzeca"
-
-#. module: analytic
#: constraint:ir.model:0
msgid ""
"The Object name must start with x_ and not contain any special character !"
@@ -40,7 +32,7 @@ msgstr ""
#. module: analytic
#: field:account.analytic.account,name:0
msgid "Account Name"
-msgstr "Naziv računa"
+msgstr "Naziv Naloga"
#. module: analytic
#: help:account.analytic.line,unit_amount:0
@@ -48,11 +40,6 @@ msgid "Specifies the amount of quantity to count."
msgstr "Specificira koju kolicinu iznosa da broji"
#. module: analytic
-#: help:account.analytic.line,currency_id:0
-msgid "The related account currency if not equal to the company one."
-msgstr "Dati iznos valute ako nije jednaka valuti preduzeca"
-
-#. module: analytic
#: model:ir.module.module,description:analytic.module_meta_information
msgid ""
"Module for defining analytic accounting object.\n"
@@ -87,40 +74,6 @@ msgid "Debit"
msgstr "Duguje"
#. module: analytic
-#: help:account.analytic.account,state:0
-msgid ""
-"* When an account is created its in 'Draft' state. "
-" \n"
-"* If any associated partner is there, it can be in 'Open' state. "
-" \n"
-"* If any pending balance is there it can be in 'Pending'. "
-" \n"
-"* And finally when all the transactions are over, it can be in 'Close' "
-"state. \n"
-"* The project can be in either if the states 'Template' and 'Running'.\n"
-" If it is template then we can make projects based on the template projects. "
-"If its in 'Running' state it is a normal project. "
-" \n"
-" If it is to be reviewed then the state is 'Pending'.\n"
-" When the project is completed the state is set to 'Done'."
-msgstr ""
-"*Kada je neka faktura kreirana a nalazi se u ' U Toku'. "
-" \n"
-"*Ako je bilo koji asocirani partner tamo, on mora biti u stanju ' Otvoren'. "
-" \n"
-"*Ako je bilo koji Saldo u stanju 'U izvrsenju' on mora i biti tamo. "
-" "
-"\n"
-"*I , na kraju kada su sve transakcije gotove, mora se naci u stanju ' "
-"Zatvoreno'. "
-" \n"
-" Ako je ovo shema(obrazac) onda mi mozemo napraviri projekat baziran na "
-"istom. Ako je u stanju ' U izvrsenju' to je normalnan\n"
-"projekat.\n"
-" Ako zelimo da ga pregledamo, stanje mora biti ' U Toku'.\n"
-" Kada je projekat zavrsen stanje je postavljeno na ' Zavrseno'."
-
-#. module: analytic
#: field:account.analytic.account,type:0
msgid "Account Type"
msgstr "Vrsta konta"
@@ -147,12 +100,9 @@ msgid "Description"
msgstr "Opis"
#. module: analytic
-#: help:account.analytic.line,amount:0
-msgid ""
-"Calculated by multiplying the quantity and the price given in the Product's "
-"cost price."
-msgstr ""
-"Izracunato mnozenjem kolicine i cene dobijene iz Proizvodove cene kostanja"
+#: selection:account.analytic.account,type:0
+msgid "Normal"
+msgstr "Normalan"
#. module: analytic
#: field:account.analytic.account,company_id:0
@@ -182,14 +132,23 @@ msgstr "Datum"
#. module: analytic
#: field:account.analytic.account,currency_id:0
-#: field:account.analytic.line,currency_id:0
msgid "Account currency"
msgstr "Valuta Naloga"
#. module: analytic
-#: selection:account.analytic.account,type:0
-msgid "View"
-msgstr "Pregled"
+#: field:account.analytic.account,quantity:0
+#: field:account.analytic.line,unit_amount:0
+msgid "Quantity"
+msgstr "Količina"
+
+#. module: analytic
+#: help:account.analytic.line,amount:0
+msgid ""
+"Calculated by multiplying the quantity and the price given in the Product's "
+"cost price. Always expressed in the company main currency."
+msgstr ""
+"Izracunato mnozenjem kolicine i cene date u proizvodovom cenovniku. Uvek "
+"prikazano u osnovnoj valuti preduzeca."
#. module: analytic
#: help:account.analytic.account,quantity_max:0
@@ -222,15 +181,13 @@ msgid "Balance"
msgstr "Saldo"
#. module: analytic
-#: field:account.analytic.account,date_start:0
-msgid "Date Start"
-msgstr "Početni datum"
-
-#. module: analytic
-#: field:account.analytic.account,quantity:0
-#: field:account.analytic.line,unit_amount:0
-msgid "Quantity"
-msgstr "Količina"
+#: help:account.analytic.account,type:0
+msgid ""
+"If you select the View Type, it means you won't allow to create journal "
+"entries using that account."
+msgstr ""
+"Ukoliko izaberete PREGLED, to znaci da ne zelite da kreirate sadrzaj "
+"dnevnika, koristeci taj nalog."
#. module: analytic
#: field:account.analytic.account,date:0
@@ -238,16 +195,16 @@ msgid "Date End"
msgstr "Završni datum"
#. module: analytic
+#: constraint:ir.rule:0
+msgid "Rules are not supported for osv_memory objects !"
+msgstr "Pravila nisu podrzana od strane osv_memory objekata !"
+
+#. module: analytic
#: field:account.analytic.account,code:0
msgid "Account Code"
msgstr "Sifra Naloga"
#. module: analytic
-#: selection:account.analytic.account,type:0
-msgid "Normal"
-msgstr "Normalan"
-
-#. module: analytic
#: field:account.analytic.account,complete_name:0
msgid "Full Account Name"
msgstr "Puni naziv konta"
@@ -260,19 +217,19 @@ msgid "Analytic Account"
msgstr "Analitički konto"
#. module: analytic
-#: field:account.analytic.account,company_currency_id:0
-msgid "Currency"
-msgstr "Valuta"
+#: selection:account.analytic.account,type:0
+msgid "View"
+msgstr "Pregled"
#. module: analytic
-#: field:account.analytic.line,amount_currency:0
-msgid "Amount currency"
-msgstr "Iznos valute"
+#: field:account.analytic.account,partner_id:0
+msgid "Partner"
+msgstr "Partner"
#. module: analytic
-#: field:account.analytic.account,partner_id:0
-msgid "Associated Partner"
-msgstr "Povezani partner"
+#: field:account.analytic.account,date_start:0
+msgid "Date Start"
+msgstr "Početni datum"
#. module: analytic
#: selection:account.analytic.account,state:0
@@ -283,3 +240,59 @@ msgstr "Otvori"
#: field:account.analytic.account,line_ids:0
msgid "Analytic Entries"
msgstr "Analitičke stavke"
+
+#~ msgid ""
+#~ "The amount expressed in the related account currency if not equal to the "
+#~ "company one."
+#~ msgstr ""
+#~ "Vrednost izrazena u datom iznosu valute ako nije jednaka valuti preduzeca"
+
+#~ msgid "The related account currency if not equal to the company one."
+#~ msgstr "Dati iznos valute ako nije jednaka valuti preduzeca"
+
+#~ msgid ""
+#~ "* When an account is created its in 'Draft' state. "
+#~ " \n"
+#~ "* If any associated partner is there, it can be in 'Open' state. "
+#~ " \n"
+#~ "* If any pending balance is there it can be in 'Pending'. "
+#~ " \n"
+#~ "* And finally when all the transactions are over, it can be in 'Close' "
+#~ "state. \n"
+#~ "* The project can be in either if the states 'Template' and 'Running'.\n"
+#~ " If it is template then we can make projects based on the template projects. "
+#~ "If its in 'Running' state it is a normal project. "
+#~ " \n"
+#~ " If it is to be reviewed then the state is 'Pending'.\n"
+#~ " When the project is completed the state is set to 'Done'."
+#~ msgstr ""
+#~ "*Kada je neka faktura kreirana a nalazi se u ' U Toku'. "
+#~ " \n"
+#~ "*Ako je bilo koji asocirani partner tamo, on mora biti u stanju ' Otvoren'. "
+#~ " \n"
+#~ "*Ako je bilo koji Saldo u stanju 'U izvrsenju' on mora i biti tamo. "
+#~ " "
+#~ "\n"
+#~ "*I , na kraju kada su sve transakcije gotove, mora se naci u stanju ' "
+#~ "Zatvoreno'. "
+#~ " \n"
+#~ " Ako je ovo shema(obrazac) onda mi mozemo napraviri projekat baziran na "
+#~ "istom. Ako je u stanju ' U izvrsenju' to je normalnan\n"
+#~ "projekat.\n"
+#~ " Ako zelimo da ga pregledamo, stanje mora biti ' U Toku'.\n"
+#~ " Kada je projekat zavrsen stanje je postavljeno na ' Zavrseno'."
+
+#~ msgid ""
+#~ "Calculated by multiplying the quantity and the price given in the Product's "
+#~ "cost price."
+#~ msgstr ""
+#~ "Izracunato mnozenjem kolicine i cene dobijene iz Proizvodove cene kostanja"
+
+#~ msgid "Currency"
+#~ msgstr "Valuta"
+
+#~ msgid "Associated Partner"
+#~ msgstr "Povezani partner"
+
+#~ msgid "Amount currency"
+#~ msgstr "Iznos valute"