[FIX] stock_account: delete COGS when set to draft
- Create a product A, FIFO & Automated - Create a SO, deliver and invoice - Post the invoice - Reset it to draft - Post the invoice again The COGS lines are duplicated. Unlike the other lines, the COGS lines are only added at posting. This is done in case several invoices are generated in draft, but validated in an arbitrary order. We clean up the COGS lines when resetting to draft. opw-2153695 opw-2152465 closes odoo/odoo#41931 X-original-commit: 84cb3b9c848ed42017b3253ca70b9455c8af7307 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -38,11 +38,20 @@ class AccountMove(models.Model):
|
||||
self._stock_account_anglo_saxon_reconcile_valuation()
|
||||
return res
|
||||
|
||||
def button_draft(self):
|
||||
res = super(AccountMove, self).button_draft()
|
||||
|
||||
# Unlink the COGS lines generated during the 'post' method.
|
||||
self.mapped('line_ids').filtered(lambda line: line.is_anglo_saxon_line).unlink()
|
||||
return res
|
||||
|
||||
def button_cancel(self):
|
||||
# OVERRIDE
|
||||
res = super(AccountMove, self).button_cancel()
|
||||
|
||||
# Unlink the COGS lines generated during the 'post' method.
|
||||
# In most cases it shouldn't be necessary since they should be unlinked with 'button_draft'.
|
||||
# However, since it can be called in RPC, better be safe.
|
||||
self.mapped('line_ids').filtered(lambda line: line.is_anglo_saxon_line).unlink()
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user