False "Bad total!" exception in account.invoice (trunk)

Bug #310919 reported by Dukai Gábor
2
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Christophe Simonis (OpenERP)

Bug Description

Hi!
Trunk version.
The situation: basic setup: a purchase invoice is made from a purchase order. There is one product with the price of 1.00 and a tax 0.18, resulting in a total of 1.18.
There is a problem in account_invoice.action_move_create() with the following lines (I have inserted debug()-s to show the problem):
for inv in self.browse(cr, uid, ids):
    debug('test1')
    debug(self.pool.get('account.invoice').read(cr, uid, inv.id, ['check_total']))
    self.button_compute(cr, uid, ids, context={},set_total=True)
    debug('test2')
    debug(self.pool.get('account.invoice').read(cr, uid, inv.id, ['check_total']))
    debug('test3 - variable not changed')
    debug(inv.check_total)
    if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0):
        raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.'))

Log:
DEBUG:action_move_create:'test1'
DEBUG:action_move_create:self.pool.get('account.invoice').read(cr, uid, inv.id, ['check_total']) = {'check_total': 1.0, 'id': 1}
DEBUG:action_move_create:'test2'
DEBUG:action_move_create:self.pool.get('account.invoice').read(cr, uid, inv.id, ['check_total']) = {'check_total': 1.1799999999999999, 'id': 1}
DEBUG:action_move_create:'test3 - variable not changed'
DEBUG:action_move_create:inv.check_total = 1.0

The problem is that although account_invoice.button_compute() writes the new value to account_invoice.check_total, the variable inv in action_move_create() has the old incorrect value and the "Bad total!" exception is raised.

Changed in openobject-addons:
assignee: nobody → kangol
Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

fixed by 2054 christophe@cobalt-20081223162210-chbr8wg9ae19cwbm

Changed in openobject-addons:
milestone: none → 5.0
status: New → Fix Released
Revision history for this message
Dukai Gábor (gdukai) wrote :

Your fix was modified and the bug reappeared:

@@ -448,7 +448,7 @@
         ait_obj = self.pool.get('account.invoice.tax')
         cur_obj = self.pool.get('res.currency')
         acc_obj = self.pool.get('account.account')
- self.button_compute(cr, uid, ids, context={}, set_total=True)
+ self.button_compute(cr, uid, ids, context={}, set_total=False)
         for inv in self.browse(cr, uid, ids):
             if inv.move_id:
                 continue

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.