From 2cdcbe7303e20c3665cc100c88db484053458d62 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 28 Apr 2026 11:27:35 +0200 Subject: [PATCH] Bug --- modules/account_invoice/invoice.py | 12 ++++++++++-- modules/account_stock_anglo_saxon/invoice.py | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 8971b8e..26652ca 100755 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -1963,17 +1963,25 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): move_line_.amount_second_currency = -original_amount if amount < 0: + lot_has_sale_invoice = ( + move_line.lot + and (move_line.lot.sale_invoice_line + or move_line.lot.sale_invoice_line_prov)) move_line.debit = Decimal(0) move_line.credit = -amount - move_line.account = gl.product.account_stock_used if not (move_line.lot.sale_invoice_line or move_line.lot.sale_invoice_line_prov) else gl.product.account_stock_out_used + move_line.account = gl.product.account_stock_used if not lot_has_sale_invoice else gl.product.account_stock_out_used move_line.account = gl.product.account_cogs_used if gl.fee else move_line.account move_line_.credit = Decimal(0) move_line_.debit = -amount move_line_.account = gl.product.account_stock_in_used else: + lot_has_sale_invoice = ( + move_line.lot + and (move_line.lot.sale_invoice_line + or move_line.lot.sale_invoice_line_prov)) move_line.debit = amount move_line.credit = Decimal(0) - move_line.account = gl.product.account_stock_used if not (move_line.lot.sale_invoice_line or move_line.lot.sale_invoice_line_prov) else gl.product.account_stock_out_used + move_line.account = gl.product.account_stock_used if not lot_has_sale_invoice else gl.product.account_stock_out_used move_line.account = gl.product.account_cogs_used if gl.fee else move_line.account move_line_.debit = Decimal(0) move_line_.credit = amount diff --git a/modules/account_stock_anglo_saxon/invoice.py b/modules/account_stock_anglo_saxon/invoice.py index 18be9e0..b615a1f 100755 --- a/modules/account_stock_anglo_saxon/invoice.py +++ b/modules/account_stock_anglo_saxon/invoice.py @@ -181,7 +181,11 @@ class InvoiceLine(metaclass=PoolMeta): company=self.invoice.company.id, date=accounting_date): anglo_saxon_move_lines = self._get_anglo_saxon_move_lines( cost, type_) - if type_ == 'in_supplier' and (self.lot.sale_invoice_line_prov or self.lot.sale_invoice_line) and not self.fee: + lot_has_sale_invoice = ( + self.lot + and (self.lot.sale_invoice_line_prov + or self.lot.sale_invoice_line)) + if type_ == 'in_supplier' and lot_has_sale_invoice and not self.fee: anglo_saxon_move_lines_ = self._get_anglo_saxon_move_lines(cost, 'out_customer') result.extend(anglo_saxon_move_lines) result.extend(anglo_saxon_move_lines_)