diff --git a/addons/account/account.py b/addons/account/account.py index 684a3d0f142..c31f34740cc 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1618,8 +1618,42 @@ class account_tax(osv.osv): cur_price_unit+=amount2 return res - def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): + def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): + """ + RETURN: { + 'total': 0.0, # Total without taxes + 'total_included: 0.0, # Total with taxes + 'taxes': [] # List of taxes, see compute for the format + } + """ + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') + totalin = totalex = round(price_unit * quantity, precision) + tin = [] + tex = [] + for tax in taxes: + if tax.price_include: + tin.append(tax) + else: + tex.append(tax) + tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner) + for r in tin: + totalex -= r['amount'] + tex = self._compute(cr, uid, tex, totalex/quantity, quantity, address_id=address_id, product=product, partner=partner) + for r in tex: + totalin += r['amount'] + return { + 'total': totalex, + 'total_included': totalin, + 'taxes': tin + tex + } + def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): + logger = netsvc.Logger() + logger.notifyChannel("warning", netsvc.LOG_WARNING, + "Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included") + return self._compute(cr, uid, taxes, price_unit, quantity, address_id, product, partner) + + def _compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID. @@ -1636,7 +1670,6 @@ class account_tax(osv.osv): else: r['amount'] = round(r['amount'] * quantity, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')) total += r['amount'] - return res def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None): @@ -2007,13 +2040,12 @@ class account_add_tmpl_wizard(osv.osv_memory): if not tids or not tids[0]['parent_id']: return False ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code']) + res = None if not ptids or not ptids[0]['code']: raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!')) res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])]) - if res: - return res[0] - else: - return False + + return res and res[0] or False _columns = { 'cparent_id':fields.many2one('account.account', 'Parent target', help="Creates an account with the selected template under this existing parent.", required=True), diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 4c6faae9e19..50e431935bc 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -19,26 +19,26 @@ position="attributes"> You can enhance OpenERP's basic accounting support with a few additional OpenERP applications. - + Configure 23 - - - + + + - + - - -
+ + + @@ -51,15 +51,15 @@ - - + + - - - - - + + + + + @@ -88,12 +88,12 @@ account_installer_action_replace tree - - -