Add issue5196 + issue5352: sale shipment cost
This commit is contained in:
parent
263eafea70
commit
94ff20052e
|
@ -0,0 +1,35 @@
|
|||
# HG changeset patch
|
||||
# User Ralf Peschke <rpit58@gmail.com>
|
||||
# Date 1451565066 -3600
|
||||
# Thu Dec 31 13:31:06 2015 +0100
|
||||
# Node ID 327570b091513f57dee4f7496c94348298ed7729
|
||||
# Parent 203168118615383810f0a349dcf4c006f70f501f
|
||||
Set product on invoice line with cost method 'shipment'
|
||||
|
||||
issue5196
|
||||
review19711002
|
||||
|
||||
diff -r 203168118615 -r 327570b09151 trytond/trytond/modules/sale_shipment_cost/stock.py
|
||||
--- a/trytond/trytond/modules/sale_shipment_cost/stock.py Sun Dec 13 14:58:50 2015 +0100
|
||||
+++ b/trytond/trytond/modules/sale_shipment_cost/stock.py Thu Dec 31 13:31:06 2015 +0100
|
||||
@@ -89,6 +89,7 @@
|
||||
invoice_line = InvoiceLine()
|
||||
product = self.carrier.carrier_product
|
||||
invoice_line.type = 'line'
|
||||
+ invoice_line.product = product
|
||||
|
||||
party = invoice.party
|
||||
party_context = {}
|
||||
diff -r 203168118615 -r 327570b09151 trytond/trytond/modules/sale_shipment_cost/tests/scenario_sale_shipment_cost.rst
|
||||
--- a/trytond/trytond/modules/sale_shipment_cost/tests/scenario_sale_shipment_cost.rst Sun Dec 13 14:58:50 2015 +0100
|
||||
+++ b/trytond/trytond/modules/sale_shipment_cost/tests/scenario_sale_shipment_cost.rst Thu Dec 31 13:31:06 2015 +0100
|
||||
@@ -176,6 +176,9 @@
|
||||
|
||||
>>> sale.reload()
|
||||
>>> invoice, = sale.invoices
|
||||
+ >>> sorted([l.product for l in invoice.lines]) == \
|
||||
+ ... sorted([product, carrier_product])
|
||||
+ True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('83.00')
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
diff -r 447a58b54f0d trytond/trytond/modules/sale_shipment_cost/sale.py
|
||||
--- a/trytond/trytond/modules/sale_shipment_cost/sale.py Mon Nov 02 16:19:34 2015 +0100
|
||||
+++ b/trytond/trytond/modules/sale_shipment_cost/sale.py Fri Sep 16 12:08:12 2016 +0200
|
||||
@@ -126,22 +126,16 @@
|
||||
cost_line.unit_price = cost_line.amount = cost
|
||||
return cost_line
|
||||
|
||||
- def create_shipment(self, shipment_type):
|
||||
- Shipment = Pool().get('stock.shipment.out')
|
||||
-
|
||||
- shipments = super(Sale, self).create_shipment(shipment_type)
|
||||
- if shipment_type == 'out' and shipments and self.carrier:
|
||||
- for shipment in shipments:
|
||||
- shipment.carrier = self.carrier
|
||||
- with Transaction().set_context(
|
||||
- shipment.get_carrier_context()):
|
||||
- cost, currency_id = self.carrier.get_sale_price()
|
||||
- Shipment.write([shipment], {
|
||||
- 'carrier': self.carrier.id,
|
||||
- 'cost': cost,
|
||||
- 'cost_currency': currency_id,
|
||||
- })
|
||||
- return shipments
|
||||
+ def _get_shipment_sale(self, Shipment, key):
|
||||
+ shipment = super(Sale, self)._get_shipment_sale(Shipment, key)
|
||||
+ if shipment.__name__ == 'stock.shipment.out' and self.carrier:
|
||||
+ shipment.carrier = self.carrier
|
||||
+ with Transaction().set_context(
|
||||
+ shipment.get_carrier_context()):
|
||||
+ cost, currency_id = self.carrier.get_sale_price()
|
||||
+ shipment.cost = cost
|
||||
+ shipment.cost_currency = currency_id
|
||||
+ return shipment
|
||||
|
||||
def _get_invoice_line_sale_line(self, invoice_type):
|
||||
result = super(Sale, self)._get_invoice_line_sale_line(invoice_type)
|
Loading…
Reference in New Issue