This commit is contained in:
2026-02-18 11:03:27 +01:00
parent 697b53e68a
commit 0011a7f943
2 changed files with 14 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ from decimal import Decimal
from trytond.i18n import gettext
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.exceptions import UserWarning, UserError
from .exceptions import COGSWarning
import logging
@@ -171,12 +171,19 @@ class InvoiceLine(metaclass=PoolMeta):
cost = self.amount
else:
cost = self.lot.get_cog()
if not cost or cost == 0:
raise UserError('No COG for this invoice, please generate the reception of the goods')
if self.amount < 0 :
cost *= -1
logger.info("GETMOVELINES_COST:%s",cost)
with Transaction().set_context(
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.sale_invoice_line):
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_)
#Fee inventoried delivery management
if self.lot and type_ != 'in_supplier':
FeeLots = Pool().get('fee.lots')