Merge lp:~therp-nl/ocb-addons/6.1-lp941817-autocompute_taxes_on_proforma into lp:ocb-addons/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 6733
Proposed branch: lp:~therp-nl/ocb-addons/6.1-lp941817-autocompute_taxes_on_proforma
Merge into: lp:ocb-addons/6.1
Diff against target: 52 lines (+19/-2)
3 files modified
account/account_invoice.py (+17/-0)
account/account_invoice_view.xml (+1/-1)
account/account_invoice_workflow.xml (+1/-1)
To merge this branch: bzr merge lp:~therp-nl/ocb-addons/6.1-lp941817-autocompute_taxes_on_proforma
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review, no test Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+159168@code.launchpad.net

Commit message

[FIX] lp:941817, taxes not computed automatically on proforma

Description of the change

In OpenERP 6.1 and 7.0, taxes are not computed automatically in the workflow when a draft invoice becomes a proforma. This can lead to invalid proformas without tax being sent out by the user. This branch triggers the tax calculation from the workflow. Additionally, this branch hides the tax computation button which does have a function anymore after the first change.

The suggested change in https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-941817-amp makes it impossible to fix rounding differences in the tax amounts. The change in this proposal calls the same method as the validation step in the same invoice workflow, which only checks the base amount of existing taxes.

To post a comment you must log in.
Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

I think this is an important improvement.

Just wondering: why should the 'Compute Taxes' button be needed at all? Shouldn't taxes be automatically be updated whenever an invoice line changes?

Of course with keeping the possibility to add extra taxes, or modify tax lines when there have been rounding errors (as still happens all to frequently).

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Yes it is an important issue. However, the current fix makes it impossible to make changes in the tax amounts to fix rounding difference like you mention. Will refactor using account_invoice.check_tax_lines(). The scenario that you refer to would be useful but is out of scope for this particular issue.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_invoice.py'
2--- account/account_invoice.py 2013-04-09 13:45:44 +0000
3+++ account/account_invoice.py 2013-04-17 20:08:27 +0000
4@@ -1062,6 +1062,23 @@
5 self.log(cr, uid, inv_id, message, context=ctx)
6 return True
7
8+ def action_proforma(self, cr, uid, ids, context=None):
9+ """
10+ Check if all taxes are present with the correct base amount
11+ on creating a proforma invoice. This leaves room for manual
12+ corrections of the tax amount.
13+ """
14+ if not ids:
15+ return True
16+ if isinstance(ids, (int, long)):
17+ ids = [ids]
18+ ait_obj = self.pool.get('account.invoice.tax')
19+ for inv in self.browse(cr, uid, ids, context=context):
20+ compute_taxes = ait_obj.compute(cr, uid, inv.id, context=context)
21+ self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj)
22+ return self.write(
23+ cr, uid, ids, {'state': 'proforma2'}, context=context)
24+
25 def action_cancel(self, cr, uid, ids, *args):
26 context = {} # TODO: Use context from arguments
27 account_move_obj = self.pool.get('account.move')
28
29=== modified file 'account/account_invoice_view.xml'
30--- account/account_invoice_view.xml 2013-01-23 09:13:47 +0000
31+++ account/account_invoice_view.xml 2013-04-17 20:08:27 +0000
32@@ -296,7 +296,7 @@
33 </group>
34 <group col="4" colspan="2">
35 <group colspan="2" col="1">
36- <button name="button_reset_taxes" states="draft,proforma2" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific" help="This action will erase taxes"/>
37+ <button name="button_reset_taxes" states="draft" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific" help="This action will erase taxes"/>
38 </group>
39 <field name="amount_untaxed"/>
40 <label string="" colspan="2"/>
41
42=== modified file 'account/account_invoice_workflow.xml'
43--- account/account_invoice_workflow.xml 2011-01-14 00:11:01 +0000
44+++ account/account_invoice_workflow.xml 2013-04-17 20:08:27 +0000
45@@ -17,7 +17,7 @@
46 <record id="act_proforma2" model="workflow.activity">
47 <field name="wkf_id" ref="wkf"/>
48 <field name="name">proforma2</field>
49- <field name="action">write({'state':'proforma2'})</field>
50+ <field name="action">action_proforma()</field>
51 <field name="kind">function</field>
52 </record>
53

Subscribers

People subscribed via source and target branches