Odoo - OpenERP - Correct way to setup decimal precision in OpenERP ?

Support
Support
5000
| 2 1 2
Asked on 8/15/15, 7:18 AM
0
vote
4575 Views

Wrong setting of decimal precision can result in big problem for accounting. Here is some tips from my experience.

  • It is ok (and sometime required to make a valid result) to increase the precision for non-Account items. I.e., Price, Discount.

  • But we should not change the precision of Account as it will affect account posting. Also, 2 digit is what we want for our Forms, it should be the same as what is recorded in system.

decmial_setup

  • In coding, OpenERP is using the same concept as Excel’s “Calculate as Display”. Meaning, each number should be rounded (2 digit as setup in currency) before further calculation.

  • Make sure when writing the code, use this concept to avoid future problem.

oe_1

 

 def cur_round(value):
        """Round value according to currency."""
        return cur_obj.round(cr, uid, cur, value)

    # add discount
    amount_untaxed = sum(line.price_subtotal
                         for line in getattr(record, self._line_column))
    add_disc = record.add_disc
    add_disc_amt = cur_round(amount_untaxed * add_disc / 100)
    o_res['add_disc_amt'] = add_disc_amt
    o_res['amount_net'] = o_res['amount_untaxed'] - add_disc_amt

    # we apply a discount on the tax as well.
    # We might have rounding issue
    o_res['amount_tax'] = cur_round(
        o_res['amount_tax'] * (100.0 - (add_disc or 0.0))/100.0)
    o_res['amount_total'] = o_res['amount_net'] + o_res['amount_tax']

 

Note:

You can note from the code that, we always round it (to 2 digits) before pass it to next calculation.

Support
Support
5000
| 2 1 2
Answered on 8/15/15, 7:19 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This forum is for HiTechnologia Employees & just Odoo general knowledge purpose only.

Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 8/15/15, 7:18 AM
Seen: 4575 times
Last updated: 8/15/15, 7:19 AM