Merge lp:~julie-w/unifield-addons/UTP-28 into lp:unifield-addons

Proposed by jftempo
Status: Merged
Merged at revision: 4689
Proposed branch: lp:~julie-w/unifield-addons/UTP-28
Merge into: lp:unifield-addons
Diff against target: 66 lines (+13/-9)
2 files modified
account/account_invoice_view.xml (+1/-1)
account/invoice.py (+12/-8)
To merge this branch: bzr merge lp:~julie-w/unifield-addons/UTP-28
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+287279@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_invoice_view.xml'
2--- account/account_invoice_view.xml 2015-05-13 12:33:38 +0000
3+++ account/account_invoice_view.xml 2016-02-26 09:46:51 +0000
4@@ -190,7 +190,7 @@
5 <field name="tax_line" nolabel="1">
6 <tree editable="bottom" string="Taxes">
7 <field name="invoice_id" invisible="True"/>
8- <field name="account_tax_id" on_change="tax_code_change(account_tax_id,parent.amount_untaxed,parent.amount_total)"/>
9+ <field name="account_tax_id" on_change="tax_code_change(account_tax_id,parent.amount_untaxed,parent.amount_total,context)"/>
10 <field name="name"/>
11
12 <field name="account_id" groups="account.group_account_invoice" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation'),('user_type.code','not in',['income','expense'])]"/>
13
14=== modified file 'account/invoice.py'
15--- account/invoice.py 2015-07-24 11:50:33 +0000
16+++ account/invoice.py 2016-02-26 09:46:51 +0000
17@@ -749,10 +749,11 @@
18 for tax in inv.tax_line:
19 if tax.manual:
20 continue
21- key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id)
22+ key = tax.account_tax_id.id # taxes are grouped by id
23 tax_key.append(key)
24 if not key in compute_taxes:
25- raise osv.except_osv(_('Warning !'), _('Global taxes defined, but are not in invoice lines !'))
26+ raise osv.except_osv(_('Warning !'),
27+ _('Global taxes defined, click on compute to update tax base !'))
28 base = compute_taxes[key]['base']
29 if abs(base - tax.base) > inv.company_id.currency_id.rounding:
30 raise osv.except_osv(_('Warning !'), _('Tax base different !\nClick on compute to update tax base'))
31@@ -1691,11 +1692,13 @@
32
33
34 def tax_code_change(self, cr, uid, ids, account_tax_id, amount_untaxed,
35- amount_total):
36- atx_obj = self.pool.get('account.tax')
37- atx = atx_obj.browse(cr, uid, account_tax_id)
38- return {'value': {'account_id': atx.account_collected_id.id, 'name': "{0} - {1}".format(atx.name,atx.description), 'base_amount': amount_untaxed, 'amount': self._calculate_tax(cr, uid, account_tax_id, amount_untaxed, amount_total)}}
39-
40+ amount_total, context=None):
41+ ret = {}
42+ if account_tax_id:
43+ atx_obj = self.pool.get('account.tax')
44+ atx = atx_obj.browse(cr, uid, account_tax_id, context=context)
45+ ret = {'value': {'account_id': atx.account_collected_id.id, 'name': "{0} - {1}".format(atx.name, atx.description or ''), 'base_amount': amount_untaxed, 'amount': self._calculate_tax(cr, uid, account_tax_id, amount_untaxed, amount_total)}}
46+ return ret
47
48 def _calculate_tax(self, cr, uid, account_tax_id, amount_untaxed,
49 amount_total):
50@@ -1766,6 +1769,7 @@
51 val['manual'] = False
52 val['sequence'] = tax['sequence']
53 val['base'] = tax['price_unit'] * line['quantity']
54+ val['account_tax_id'] = tax['id']
55
56 if inv.type in ('out_invoice','in_invoice'):
57 val['base_code_id'] = tax['base_code_id']
58@@ -1780,7 +1784,7 @@
59 val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
60 val['account_id'] = tax['account_paid_id'] or line.account_id.id
61
62- key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
63+ key = tax['id'] # taxes are grouped by id
64 if not key in tax_grouped:
65 tax_grouped[key] = val
66 else:

Subscribers

People subscribed via source and target branches