changeset 6704db02780a in modules/stock_package_shipping_dpd:default
details:
https://hg.tryton.org/modules/stock_package_shipping_dpd?cmd=changeset;node=6704db02780a
description:
Manage shipping for supplier shipment returns
We move the shipping code in mixin's such that it can be applied on
other
shipments.
We define properties to abstract the information needed by the create
shipping
wizards. Such that they can be execute on any shipment.
issue9850
review324521002
diffstat:
__init__.py | 1 +
stock.py | 22 +++++++++++++++-------
2 files changed, 16 insertions(+), 7 deletions(-)
diffs (57 lines):
diff -r b3304f47990a -r 6704db02780a __init__.py
--- a/__init__.py Sat Dec 19 17:08:47 2020 +0100
+++ b/__init__.py Sun Dec 20 19:54:48 2020 +0100
@@ -12,6 +12,7 @@
carrier.CredentialDPD,
carrier.Carrier,
stock.ShipmentOut,
+ stock.ShipmentInReturn,
module='stock_package_shipping_dpd', type_='model')
Pool.register(
stock.CreateShipping,
diff -r b3304f47990a -r 6704db02780a stock.py
--- a/stock.py Sat Dec 19 17:08:47 2020 +0100
+++ b/stock.py Sun Dec 20 19:54:48 2020 +0100
@@ -21,17 +21,24 @@
from .exceptions import DPDError
-class ShipmentOut(metaclass=PoolMeta):
- __name__ = 'stock.shipment.out'
+class ShippingDPDMixin:
def validate_packing_dpd(self):
- warehouse_address = self.warehouse.address
- if not warehouse_address:
+ warehouse = self.shipping_warehouse
+ if not warehouse.address:
raise PackingValidationError(
gettext('stock_package_shipping_dpd'
'.msg_warehouse_address_required',
shipment=self.rec_name,
- warehouse=self.warehouse.rec_name))
+ warehouse=warehouse.rec_name))
+
+
+class ShipmentOut(ShippingDPDMixin, metaclass=PoolMeta):
+ __name__ = 'stock.shipment.out'
+
+
+class ShipmentInReturn(ShippingDPDMixin, metaclass=PoolMeta):
+ __name__ = 'stock.shipment.in.return'
class CreateShipping(metaclass=PoolMeta):
@@ -218,9 +225,10 @@
'sendingDepot': credential.depot,
'product': shipment.carrier.dpd_product,
'sender': self.shipping_party(
- shipment.company.party, shipment.warehouse.address),
+ shipment.company.party,
+ shipment.shipping_warehouse.address),
'recipient': self.shipping_party(
- shipment.customer, shipment.delivery_address),
+ shipment.shipping_to, shipment.shipping_to_address),
},
'parcels': [self.get_parcel(p) for p in packages],
'productAndServiceData': {