Use cost method on shipment instead of shipment cost method on sale
issue11620 review415401003
This commit is contained in:
1 parent
50993d7acf
commit
659d7ae8ef
2 files changed
+8
-12
No files matched your search
@@ -339,13 +339,10 @@ class Line(metaclass=PoolMeta):
|
||||
context = Transaction().context
|
||||
shipment_cost_invoiced = context.get('_shipment_cost_invoiced')
|
||||
lines = super().get_invoice_line()
|
||||
if (self.sale.shipment_cost_method == 'shipment'
|
||||
and self.shipment_cost
|
||||
if (self.shipment_cost
|
||||
and shipment_cost_invoiced is not None):
|
||||
for shipment in self.sale.shipments:
|
||||
if (shipment.state == 'done'
|
||||
and shipment.carrier
|
||||
and not shipment.cost_invoice_line
|
||||
and shipment.id not in shipment_cost_invoiced):
|
||||
invoice_line = shipment.get_cost_invoice_line(
|
||||
self.sale._get_invoice_sale())
|
||||
|
||||
@@ -114,7 +114,10 @@ class ShipmentOut(metaclass=PoolMeta):
|
||||
Currency = pool.get('currency.currency')
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
|
||||
if not self.cost_sale_used:
|
||||
if (self.cost_method != 'shipment'
|
||||
or not self.carrier
|
||||
or not self.cost_sale_used
|
||||
or self.cost_invoice_line):
|
||||
return
|
||||
product = self.carrier.carrier_product
|
||||
|
||||
@@ -146,18 +149,14 @@ class ShipmentOut(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Currency = pool.get('currency.currency')
|
||||
cost = super()._get_shipment_cost()
|
||||
methods = {
|
||||
m.sale.shipment_cost_method for m in self.outgoing_moves if m.sale}
|
||||
if 'shipment' in methods:
|
||||
if self.cost_method == 'shipment':
|
||||
if self.cost_sale:
|
||||
cost_sale = Currency.compute(
|
||||
self.cost_sale_currency, self.cost_sale,
|
||||
self.company.currency, round=False)
|
||||
cost -= cost_sale
|
||||
if 'order' in methods:
|
||||
sales = {
|
||||
m.sale for m in self.outgoing_moves
|
||||
if m.sale and m.sale.shipment_cost_method == 'order'}
|
||||
elif self.cost_method == 'order':
|
||||
sales = {m.sale for m in self.outgoing_moves if m.sale}
|
||||
for sale in sales:
|
||||
shipment_cost = sum(
|
||||
(s.cost_used or 0) for s in sale.shipments
|
||||
|
||||
Reference in new issue
Block a user