Rely on ShippingMixin to implement shipping service
This commit is contained in:
1 parent
e7f94ab26a
commit
768fc5c1a8
7 files changed
+21
-55
No files matched your search
@@ -1,6 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.stock_package_shipping.stock import ShippingMixin
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import carrier, stock
|
||||
@@ -11,10 +12,11 @@ def register():
|
||||
carrier.CredentialDPD,
|
||||
carrier.Carrier,
|
||||
stock.Package,
|
||||
stock.ShipmentOut,
|
||||
stock.ShipmentInReturn,
|
||||
module='stock_package_shipping_dpd', type_='model')
|
||||
Pool.register(
|
||||
stock.CreateShipping,
|
||||
stock.CreateDPDShipping,
|
||||
module='stock_package_shipping_dpd', type_='wizard')
|
||||
Pool.register_mixin(
|
||||
stock.ShippingDPDMixin, ShippingMixin,
|
||||
module='stock_package_shipping_dpd')
|
||||
@@ -37,22 +37,14 @@ class Package(metaclass=PoolMeta):
|
||||
__name__ = 'stock.package'
|
||||
|
||||
def get_shipping_tracking_url(self, name):
|
||||
pool = Pool()
|
||||
ShipmentOut = pool.get('stock.shipment.out')
|
||||
ShipmentInReturn = pool.get('stock.shipment.in.return')
|
||||
url = super().get_shipping_tracking_url(name)
|
||||
if (self.shipping_reference
|
||||
and self.shipment
|
||||
and self.shipment.id >= 0
|
||||
and self.shipment.carrier
|
||||
and self.shipment.carrier.shipping_service == 'dpd'):
|
||||
party = address = None
|
||||
if isinstance(self.shipment, ShipmentOut):
|
||||
party = self.shipment.customer
|
||||
address = self.shipment.delivery_address
|
||||
elif isinstance(self.shipment, ShipmentInReturn):
|
||||
party = self.shipment.supplier
|
||||
address = self.shipment.delivery_address
|
||||
party = self.shipment.shipping_to
|
||||
address = self.shipment.shipping_to_address
|
||||
if party and party.lang:
|
||||
lang_code = party.lang.code
|
||||
else:
|
||||
@@ -82,14 +74,6 @@ class ShippingDPDMixin:
|
||||
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):
|
||||
__name__ = 'stock.shipment.create_shipping'
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.stock_package_shipping.stock import ShippingMixin
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import carrier, stock
|
||||
@@ -13,10 +14,11 @@ def register():
|
||||
carrier.CredentialMyGLS,
|
||||
carrier.Carrier,
|
||||
stock.Package,
|
||||
stock.ShipmentOut,
|
||||
stock.ShipmentInReturn,
|
||||
module='stock_package_shipping_mygls', type_='model')
|
||||
Pool.register(
|
||||
stock.ShipmentCreateShipping,
|
||||
stock.ShipmentCreateShippingMyGLS,
|
||||
module='stock_package_shipping_mygls', type_='wizard')
|
||||
Pool.register_mixin(
|
||||
stock.ShippingMyGLSMixin, ShippingMixin,
|
||||
module='stock_package_shipping_mygls')
|
||||
@@ -108,14 +108,6 @@ class ShippingMyGLSMixin:
|
||||
address=shipping_to_address.rec_name))
|
||||
|
||||
|
||||
class ShipmentOut(ShippingMyGLSMixin, metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.out'
|
||||
|
||||
|
||||
class ShipmentInReturn(ShippingMyGLSMixin, metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.in.return'
|
||||
|
||||
|
||||
class ShipmentCreateShipping(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.create_shipping'
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.stock_package_shipping.stock import ShippingMixin
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import carrier, stock
|
||||
@@ -15,12 +16,11 @@ def register():
|
||||
carrier.SendcloudShippingMethod,
|
||||
carrier.Carrier,
|
||||
stock.Package,
|
||||
stock.ShipmentOut,
|
||||
stock.ShipmentInReturn,
|
||||
module='stock_package_shipping_sendcloud', type_='model')
|
||||
Pool.register(
|
||||
stock.CreateShipping,
|
||||
stock.CreateShippingSendcloud,
|
||||
module='stock_package_shipping_sendcloud', type_='wizard')
|
||||
Pool.register(
|
||||
module='stock_package_shipping_sendcloud', type_='report')
|
||||
Pool.register_mixin(
|
||||
stock.ShippingSendcloudMixin, ShippingMixin,
|
||||
module='stock_package_shipping_sendcloud')
|
||||
@@ -1,6 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.stock_package_shipping.stock import ShippingMixin
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import carrier, stock
|
||||
@@ -10,8 +11,6 @@ def register():
|
||||
Pool.register(
|
||||
stock.PackageType,
|
||||
stock.Package,
|
||||
stock.ShipmentOut,
|
||||
stock.ShipmentInReturn,
|
||||
carrier.CredentialUPS,
|
||||
carrier.Carrier,
|
||||
module='stock_package_shipping_ups', type_='model')
|
||||
@@ -19,3 +18,6 @@ def register():
|
||||
stock.CreateShipping,
|
||||
stock.CreateShippingUPS,
|
||||
module='stock_package_shipping_ups', type_='wizard')
|
||||
Pool.register_mixin(
|
||||
stock.ShippingUPSMixin, ShippingMixin,
|
||||
module='stock_package_shipping_ups')
|
||||
@@ -66,22 +66,14 @@ class Package(metaclass=PoolMeta):
|
||||
__name__ = 'stock.package'
|
||||
|
||||
def get_shipping_tracking_url(self, name):
|
||||
pool = Pool()
|
||||
ShipmentOut = pool.get('stock.shipment.out')
|
||||
ShipmentInReturn = pool.get('stock.shipment.in.return')
|
||||
url = super().get_shipping_tracking_url(name)
|
||||
if (self.shipping_reference
|
||||
and self.shipment
|
||||
and self.shipment.id >= 0
|
||||
and self.shipment.carrier
|
||||
and self.shipment.carrier.shipping_service == 'ups'):
|
||||
party = address = None
|
||||
if isinstance(self.shipment, ShipmentOut):
|
||||
party = self.shipment.customer
|
||||
address = self.shipment.delivery_address
|
||||
elif isinstance(self.shipment, ShipmentInReturn):
|
||||
party = self.shipment.supplier
|
||||
address = self.shipment.delivery_address
|
||||
party = self.shipment.shipping_to
|
||||
address = self.shipment.shipping_to_address
|
||||
parts = urllib.parse.urlsplit(TRACKING_URL)
|
||||
query = urllib.parse.parse_qsl(parts.query)
|
||||
if party and party.lang and address and address.country:
|
||||
@@ -106,7 +98,7 @@ class ShippingUPSMixin:
|
||||
'.msg_warehouse_address_required',
|
||||
shipment=self.rec_name,
|
||||
warehouse=warehouse.rec_name))
|
||||
if warehouse.address.country != self.delivery_address.country:
|
||||
if warehouse.address.country != self.shipping_to_address.country:
|
||||
for address in [self.shipping_to_address, warehouse.address]:
|
||||
if not address.contact_mechanism_get(
|
||||
{'phone', 'mobile'}, usage=usage):
|
||||
@@ -125,14 +117,6 @@ class ShippingUPSMixin:
|
||||
shipment=self.rec_name))
|
||||
|
||||
|
||||
class ShipmentOut(ShippingUPSMixin, metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.out'
|
||||
|
||||
|
||||
class ShipmentInReturn(ShippingUPSMixin, metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.in.return'
|
||||
|
||||
|
||||
class CreateShipping(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.create_shipping'
|
||||
|
||||
|
||||
Reference in new issue
Block a user