[FIX] point_of_sale: prevent adding extra rounding line
Steps to reproduce: 1. Make a cash rounding method, make it specific to cash 2. Add a product line with non-rounded price 3. Enable invoice, and add a customer 4. Make a payment with a combination of cash and bank 5. Validate, an error appears that "the move is not balanced". The issue is there is a rounding line added, that should be removed. However, here `unlink` and `write` methods, trigger a dynamic sync operation that re-generates the rounding line, making the move unbalanced. To fix the issue, we can prevent the sync operation, so that no extra rounding lines are added. opw-3180708 closes odoo/odoo#114020 X-original-commit: 3bd28525d9486e2f33b8d338c39675125fa22d7a Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com> Signed-off-by: Khanalizadeh Ahmad (khah) <khah@odoo.com>
This commit is contained in:
@@ -543,7 +543,7 @@ class PosOrder(models.Model):
|
||||
})
|
||||
else:
|
||||
if rounding_line:
|
||||
rounding_line.with_context(check_move_validity=False).unlink()
|
||||
rounding_line.with_context(skip_invoice_sync=True, check_move_validity=False).unlink()
|
||||
if rounding_line_difference:
|
||||
existing_terms_line = new_move.line_ids.filtered(
|
||||
lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable'))
|
||||
@@ -555,12 +555,10 @@ class PosOrder(models.Model):
|
||||
existing_terms_line_new_val = float_round(
|
||||
-existing_terms_line.credit + rounding_line_difference,
|
||||
precision_rounding=new_move.currency_id.rounding)
|
||||
existing_terms_line.write({
|
||||
existing_terms_line.with_context(skip_invoice_sync=True).write({
|
||||
'debit': existing_terms_line_new_val > 0.0 and existing_terms_line_new_val or 0.0,
|
||||
'credit': existing_terms_line_new_val < 0.0 and -existing_terms_line_new_val or 0.0,
|
||||
})
|
||||
|
||||
new_move._recompute_payment_terms_lines()
|
||||
return new_move
|
||||
|
||||
def action_pos_order_paid(self):
|
||||
|
||||
Reference in New Issue
Block a user