Merge lp:~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision into lp:openobject-addons

Proposed by Alexis de Lattre
Status: Rejected
Rejected by: qdp (OpenERP)
Proposed branch: lp:~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision
Merge into: lp:openobject-addons
Diff against target: 60 lines (+11/-8)
2 files modified
account/account.py (+7/-8)
product/product_data.xml (+4/-0)
To merge this branch: bzr merge lp:~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision
Reviewer Review Type Date Requested Status
Nhomar - Vauxoo (community) amazing Disapprove
OpenERP Core Team Pending
Review via email: mp+103579@code.launchpad.net

Description of the change

This merge proposal aims at fixing https://bugs.launchpad.net/openobject-addons/+bug/815398 ; see my comment #2.

Here is a small summary :
- by default, OpenERP compute taxes with the method "sum of rounded line values"
- with this merge proposal, it continues to compute taxes with this method by default, by you can now change to the method "rounded sum of line values" by simply changing the new "Tax calculation" decimal precision parameter from 2 (default value) to 5.

To post a comment you must log in.
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Tottaly agreed with this improvement.

We just made this change for V6 already in an external module.

BTW, it should be great if we have a configuration parameter to have both tax computation parameter you mention above -IT will be next history -

review: Approve (amazing)
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :
Download full text (3.6 KiB)

I don't think it's the right way to implement what you need. A simple option "round per line"/"round globally" is much better. It's only 3 lines of code in the tax computation method, if I remember well.

Sent from my iPhone

On 26 Apr 2012, at 00:28, Alexis de Lattre <email address hidden> wrote:

> Alexis de Lattre has proposed merging lp:~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision into lp:openobject-addons.
>
> Requested reviews:
> OpenERP Core Team (openerp)
> Related bugs:
> Bug #815398 in OpenERP Addons: "compute tax always round with account decimal precision"
> https://bugs.launchpad.net/openobject-addons/+bug/815398
>
> For more details, see:
> https://code.launchpad.net/~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision/+merge/103579
>
> This merge proposal aims at fixing https://bugs.launchpad.net/openobject-addons/+bug/815398 ; see my comment #2.
>
> Here is a small summary :
> - by default, OpenERP compute taxes with the method "sum of rounded line values"
> - with this merge proposal, it continues to compute taxes with this method by default, by you can now change to the method "rounded sum of line values" by simply changing the new "Tax calculation" decimal precision parameter from 2 (default value) to 5.
> --
> https://code.launchpad.net/~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision/+merge/103579
> Your team OpenERP Core Team is requested to review the proposed merge of lp:~akretion-team/openobject-addons/trunk-addons-tax-calculation-decimal-precision into lp:openobject-addons.
> === modified file 'account/account.py' --- account/account.py 2012-04-03 08:29:06 +0000 +++ account/account.py 2012-04-25 22:26:18 +0000 @@ -2068,7 +2068,7 @@ 'taxes': [] # List of taxes, see compute for the format } """ - precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Tax calculation') totalin = totalex = round(price_unit * quantity, precision) tin = [] tex = [] @@ -2111,12 +2111,12 @@ """ res = self._unit_compute(cr, uid, taxes, price_unit, product, partner, quantity) total = 0.0 - precision_pool = self.pool.get('decimal.precision') + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Tax calculation') for r in res: if r.get('balance',False): - r['amount'] = round(r.get('balance', 0.0) * quantity, precision_pool.precision_get(cr, uid, 'Account')) - total + r['amount'] = round(r.get('balance', 0.0) * quantity, precision) - total else: - r['amount'] = round(r.get('amount', 0.0) * quantity, precision_pool.precision_get(cr, uid, 'Account')) + r['amount'] = round(r.get('amount', 0.0) * quantity, precision) total += r['amount'] return res @@ -2204,13 +2204,12 @@ """ res = self._unit_compute_inv(cr, uid, taxes, price_unit, product, partner=None) total = 0.0 - obj_precision = self.pool.get('decimal.precision') + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Tax calculation') for r in res: - prec = obj_precision.precision_get(cr, uid, 'Account') if r.get('balance',False): - r['amount'] = round(r['b...

Read more...

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

@Fabien,

Your suggestion is good ; I can implement it.

Should I set an option on the res_company object ? Can I already use the new system with one configuration page per "topic" that you show during the community days ? If yes, do you have an example of code that I could follow ?

Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

I thnk we need both, but we can try first with one what fabien said, and then with the other one.

Revision history for this message
Christophe Combelles (ccomb) wrote :

The solution is smart because it doesn't change anything in the code, except the selection of the precision, but indeed it leads to the choice being difficult to know and understand. I agree that the choice between the two methods should be explicit. If I understand well it would just consist in disabling the rounding at the line level, depending on the method, so that there is a full decimal precision when computing the line tax, then leave the final rounding as it is?

Revision history for this message
Cristian Salamea (ovnicraft) wrote :

Here please take in care accounting results, as you know taxes value are related directly into account moves.
Can you Alexis gives us your feedback about ?

Regards,

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Just a quick note to say that I started implementing the suggestion of Fabien : add an option "round per line"/"round globally" (fields.selection). It will be a field of res_company, that will also be displayed on the "Settings > Configuration > Accounting" page.

I hope to be able to finish it soon.

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Here is my new merge proposal that implements Fabien's suggestion to have an option "round per line/round globally" :

https://code.launchpad.net/~akretion-team/openobject-addons/trunk-add-tax-rounding-option/+merge/113833

Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Done in other branch

review: Disapprove (amazing)
Revision history for this message
qdp (OpenERP) (qdp) wrote :

i reject as the option "round per line"/"round globally" was implemented and merged lately.

Thanks

Unmerged revisions

6762. By Alexis de Lattre

Small code optimisations.

6761. By Alexis de Lattre

Add a new 'Tax calculation' decimal precision :
- by default, it has the same value as the 'Account' decimal precision, so it will continue to have the same behavior by default
- for those who want to have their taxes computed as "rounded sum of line values" instead of the default "sum of rounded line values", they just have to change the value of the 'Tax calculation' decimal precision from 2 to 5

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2012-04-03 08:29:06 +0000
3+++ account/account.py 2012-04-25 22:26:18 +0000
4@@ -2068,7 +2068,7 @@
5 'taxes': [] # List of taxes, see compute for the format
6 }
7 """
8- precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
9+ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Tax calculation')
10 totalin = totalex = round(price_unit * quantity, precision)
11 tin = []
12 tex = []
13@@ -2111,12 +2111,12 @@
14 """
15 res = self._unit_compute(cr, uid, taxes, price_unit, product, partner, quantity)
16 total = 0.0
17- precision_pool = self.pool.get('decimal.precision')
18+ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Tax calculation')
19 for r in res:
20 if r.get('balance',False):
21- r['amount'] = round(r.get('balance', 0.0) * quantity, precision_pool.precision_get(cr, uid, 'Account')) - total
22+ r['amount'] = round(r.get('balance', 0.0) * quantity, precision) - total
23 else:
24- r['amount'] = round(r.get('amount', 0.0) * quantity, precision_pool.precision_get(cr, uid, 'Account'))
25+ r['amount'] = round(r.get('amount', 0.0) * quantity, precision)
26 total += r['amount']
27 return res
28
29@@ -2204,13 +2204,12 @@
30 """
31 res = self._unit_compute_inv(cr, uid, taxes, price_unit, product, partner=None)
32 total = 0.0
33- obj_precision = self.pool.get('decimal.precision')
34+ precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Tax calculation')
35 for r in res:
36- prec = obj_precision.precision_get(cr, uid, 'Account')
37 if r.get('balance',False):
38- r['amount'] = round(r['balance'] * quantity, prec) - total
39+ r['amount'] = round(r['balance'] * quantity, precision) - total
40 else:
41- r['amount'] = round(r['amount'] * quantity, prec)
42+ r['amount'] = round(r['amount'] * quantity, precision)
43 total += r['amount']
44 return res
45
46
47=== modified file 'product/product_data.xml'
48--- product/product_data.xml 2012-03-12 11:07:50 +0000
49+++ product/product_data.xml 2012-04-25 22:26:18 +0000
50@@ -156,6 +156,10 @@
51 <field name="name">Account</field>
52 <field name="digits">2</field>
53 </record>
54+ <record forcecreate="True" id="decimal_tax_calculation" model="decimal.precision">
55+ <field name="name">Tax calculation</field>
56+ <field name="digits">2</field>
57+ </record>
58 <record forcecreate="True" id="decimal_stock_weight" model="decimal.precision">
59 <field name="name">Stock Weight</field>
60 <field name="digits">2</field>

Subscribers

People subscribed via source and target branches

to all changes: