18.02.26
This commit is contained in:
@@ -6,7 +6,7 @@ from decimal import Decimal
|
|||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
from trytond.exceptions import UserWarning, UserError
|
||||||
from .exceptions import COGSWarning
|
from .exceptions import COGSWarning
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -171,12 +171,19 @@ class InvoiceLine(metaclass=PoolMeta):
|
|||||||
cost = self.amount
|
cost = self.amount
|
||||||
else:
|
else:
|
||||||
cost = self.lot.get_cog()
|
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)
|
logger.info("GETMOVELINES_COST:%s",cost)
|
||||||
with Transaction().set_context(
|
with Transaction().set_context(
|
||||||
company=self.invoice.company.id, date=accounting_date):
|
company=self.invoice.company.id, date=accounting_date):
|
||||||
anglo_saxon_move_lines = self._get_anglo_saxon_move_lines(
|
anglo_saxon_move_lines = self._get_anglo_saxon_move_lines(
|
||||||
cost, type_)
|
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)
|
||||||
|
result.extend(anglo_saxon_move_lines_)
|
||||||
#Fee inventoried delivery management
|
#Fee inventoried delivery management
|
||||||
if self.lot and type_ != 'in_supplier':
|
if self.lot and type_ != 'in_supplier':
|
||||||
FeeLots = Pool().get('fee.lots')
|
FeeLots = Pool().get('fee.lots')
|
||||||
|
|||||||
@@ -2022,10 +2022,16 @@ class LotShipping(Wizard):
|
|||||||
if shipped_quantity == 0:
|
if shipped_quantity == 0:
|
||||||
shipped_quantity = Decimal(str(r.r_lot_matched)).quantize(Decimal("0.00001"))
|
shipped_quantity = Decimal(str(r.r_lot_matched)).quantize(Decimal("0.00001"))
|
||||||
if self.ship.shipment == 'in':
|
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)
|
shipment_origin = 'stock.shipment.in,'+str(self.ship.shipment_in.id)
|
||||||
elif self.ship.shipment == 'out':
|
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)
|
shipment_origin = 'stock.shipment.out,'+str(self.ship.shipment_out.id)
|
||||||
elif self.ship.shipment == 'int':
|
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)
|
shipment_origin = 'stock.shipment.internal,'+str(self.ship.shipment_internal.id)
|
||||||
if r.id < 10000000 :
|
if r.id < 10000000 :
|
||||||
l = Lot(r.id)
|
l = Lot(r.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user