From eb72686c8f9b9fe8978fd18ef82b378fd8264856 Mon Sep 17 00:00:00 2001 From: pedrambiria Date: Wed, 25 Jan 2023 11:39:51 +0000 Subject: [PATCH] [FIX] point_of_sale: skip synchronize journal entries in PoS The problem happens when the company is Angelo Saxon, and `l10n_eg_edi_eta` is installed. Also, the product should have a cost and automatic inventory valuation. https://github.com/odoo/odoo/commit/4b430f8e30efb15f06982e4673cd73531a2119b3 The problem is that with this commit, after calling the `_set_next_sequence` function, it calls `flush_recordset`. It would cause a write to be triggered and add an Automatic Balancing Line. While in `_create_account_move` of PoS the stock output line will add later to it, and make it unbalanced. The first Automatic Balancing Line is incorrect as it will call `_create_stock_output_lines` later and it adds a line which makes it balance. But with that Automatic Balancing Line as it's unbalanced at the end it will call `_close_session_action` in PoS and shows a pop-up to add another line to make it balance. The solution is skip synchronize of journal entries. opw-3137723 closes odoo/odoo#112238 X-original-commit: 890b685e94383491579258093f934b7143612b80 Signed-off-by: Trinh Jacky (trj) Signed-off-by: Pedram Bi Ria (pebr) --- addons/point_of_sale/models/pos_session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 1922e025375..6378fd9acee 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -294,10 +294,10 @@ class PosSession(models.Model): self._create_picking_at_end_of_session() self.order_ids.filtered(lambda o: not o.is_total_cost_computed)._compute_total_cost_at_session_closing(self.picking_ids.move_ids) try: - data = self.with_company(self.company_id)._create_account_move(balancing_account, amount_to_balance, bank_payment_method_diffs) + data = self.with_company(self.company_id).with_context(check_move_validity=False, skip_invoice_sync=True)._create_account_move(balancing_account, amount_to_balance, bank_payment_method_diffs) except AccessError as e: if sudo: - data = self.sudo().with_company(self.company_id)._create_account_move(balancing_account, amount_to_balance, bank_payment_method_diffs) + data = self.sudo().with_company(self.company_id).with_context(check_move_validity=False, skip_invoice_sync=True)._create_account_move(balancing_account, amount_to_balance, bank_payment_method_diffs) else: raise e