From 95f513aab599dfb985d3f044ab6002dbf016b960 Mon Sep 17 00:00:00 2001 From: "Djamel (otd)" Date: Thu, 17 Jun 2021 14:27:42 +0000 Subject: [PATCH] [FIX] sale: re-invoicing of multiple orders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Go to sales app > create two SO with different price lists - Go to expense app > create a new expense - Add two expense lines related to the two SO - Click on the “Submit to Manager” button - Approve the expense - Click on “Post journal entries” - An error is triggered Problem: We call the onchange_discount on all SO lines together in the “_sale_create_reinvoice_sale_line function”, while it should be called on each created line separately. Bug introduced by this commit : https://github.com/odoo/odoo/commit/8815f4d9ab8620428d50abbe603c7f6c63076d6c opw-2571247 closes odoo/odoo#72381 X-original-commit: 3cc4b573e95880d8f55692e986c159b7a8dc8b8d Signed-off-by: Victor Feyens (vfe) Signed-off-by: Djamel Touati --- addons/sale/models/account_move_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/account_move_line.py b/addons/sale/models/account_move_line.py index e74f8c19dc1..43a0be53dba 100644 --- a/addons/sale/models/account_move_line.py +++ b/addons/sale/models/account_move_line.py @@ -118,7 +118,8 @@ class AccountMoveLine(models.Model): # create the sale lines in batch new_sale_lines = self.env['sale.order.line'].create(sale_line_values_to_create) - new_sale_lines._onchange_discount() + for sol in new_sale_lines: + sol._onchange_discount() # build result map by replacing index with newly created record of sale.order.line result = {}