[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)
This commit is contained in:
Saran440
2023-10-18 10:24:33 +07:00
parent 058b9f9106
commit 9cfb8ee77c
2 changed files with 6 additions and 1 deletions

View File

@@ -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

View File

@@ -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):