From 9cfb8ee77c3ccd9c9c0617e375dd30c9e9ea5712 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Wed, 18 Oct 2023 10:24:33 +0700 Subject: [PATCH] [FIX] account_spread_cost_revenue: Skip creating a template Bug fix: Duplicate spread creation when clicking 'Create Move' Error Steps: 1. Create a spread template. 2. Create a vendor bill and select the same account as the template, then confirm it. 3. Go to 'Spread Costs/Revenues' and click 'create move' on line. 4. It creates a new move and a new template. (It should not create a new template) --- account_spread_cost_revenue/models/account_move_line.py | 3 +++ account_spread_cost_revenue/models/account_spread_line.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/account_spread_cost_revenue/models/account_move_line.py b/account_spread_cost_revenue/models/account_move_line.py index 804136ae1..ba060a6c7 100644 --- a/account_spread_cost_revenue/models/account_move_line.py +++ b/account_spread_cost_revenue/models/account_move_line.py @@ -135,6 +135,9 @@ class AccountMoveLine(models.Model): return False return True + # Skip create new template when create move on spread lines + if self.env.context.get("skip_create_template"): + return for line in self: if line.spread_check == "linked": continue diff --git a/account_spread_cost_revenue/models/account_spread_line.py b/account_spread_cost_revenue/models/account_spread_line.py index 87e17795e..f1ea606ce 100644 --- a/account_spread_cost_revenue/models/account_spread_line.py +++ b/account_spread_cost_revenue/models/account_spread_line.py @@ -40,7 +40,9 @@ class AccountInvoiceSpreadLine(models.Model): def create_move(self): """Button to manually create a move from a spread line entry.""" self.ensure_one() - self.create_and_reconcile_moves() + self.with_context( + skip_create_template=True, + ).create_and_reconcile_moves() def _create_moves(self): if self.filtered(lambda l: l.move_id):