From 0011a7f943e28389f28aeeace52f1dc67bf80c0c Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Wed, 18 Feb 2026 11:03:27 +0100 Subject: [PATCH] 18.02.26 --- modules/account_stock_anglo_saxon/invoice.py | 9 ++++++++- modules/purchase_trade/lot.py | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/account_stock_anglo_saxon/invoice.py b/modules/account_stock_anglo_saxon/invoice.py index c75283f..7b13138 100755 --- a/modules/account_stock_anglo_saxon/invoice.py +++ b/modules/account_stock_anglo_saxon/invoice.py @@ -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') diff --git a/modules/purchase_trade/lot.py b/modules/purchase_trade/lot.py index 111b35f..540fb38 100755 --- a/modules/purchase_trade/lot.py +++ b/modules/purchase_trade/lot.py @@ -2022,10 +2022,16 @@ class LotShipping(Wizard): if shipped_quantity == 0: shipped_quantity = Decimal(str(r.r_lot_matched)).quantize(Decimal("0.00001")) if self.ship.shipment == 'in': + if not self.ship.shipment_in: + UserError("Shipment not known!") shipment_origin = 'stock.shipment.in,'+str(self.ship.shipment_in.id) elif self.ship.shipment == 'out': + if not self.ship.shipment_out: + UserError("Shipment not known!") shipment_origin = 'stock.shipment.out,'+str(self.ship.shipment_out.id) elif self.ship.shipment == 'int': + if not self.ship.shipment_internal: + UserError("Shipment not known!") shipment_origin = 'stock.shipment.internal,'+str(self.ship.shipment_internal.id) if r.id < 10000000 : l = Lot(r.id)