Allow choosing the DPD product and formats
issue9857 review328991002
This commit is contained in:
1 parent
edf940a935
commit
da43d5b2e4
7 files changed
+86
-3
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Allow choosing the DPD product and formats
|
||||
|
||||
Version 5.8.0 - 2020-11-02
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Remove support for Python 3.5
|
||||
|
||||
+48
@@ -8,6 +8,7 @@ from zeep.exceptions import Fault
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import ModelSQL, ModelView, MatchMixin, fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
from .configuration import get_client, LOGIN_SERVICE
|
||||
from .exceptions import DPDError
|
||||
@@ -54,7 +55,54 @@ class CredentialDPD(ModelSQL, ModelView, MatchMixin):
|
||||
class Carrier(metaclass=PoolMeta):
|
||||
__name__ = 'carrier'
|
||||
|
||||
dpd_product = fields.Selection([
|
||||
(None, ''),
|
||||
('CL', "DPD CLASSIC"),
|
||||
('E830', "DPD 8:30"),
|
||||
('E10', "DPD 10:00"),
|
||||
('E12', "DPD 12:00"),
|
||||
('E18', "DPD 18:00"),
|
||||
('IE2', "DPD EXPRESS"),
|
||||
('PL', "DPD PARCEL Letter"),
|
||||
('PL+', "DPD PARCEL Letter Plus"),
|
||||
('MAIL', "DPD International Mail"),
|
||||
], "Product", sort=False, translate=False,
|
||||
states={
|
||||
'required': Eval('shipping_service') == 'dpd',
|
||||
'invisible': Eval('shipping_service') != 'dpd',
|
||||
},
|
||||
depends=['shipping_service'])
|
||||
dpd_printer_language = fields.Selection([
|
||||
(None, ''),
|
||||
('PDF', "PDF"),
|
||||
('ZPL', "ZPL"),
|
||||
], "Printer Language", sort=False, translate=False,
|
||||
states={
|
||||
'required': Eval('shipping_service') == 'dpd',
|
||||
'invisible': Eval('shipping_service') != 'dpd',
|
||||
},
|
||||
depends=['shipping_service'])
|
||||
dpd_paper_format = fields.Selection([
|
||||
(None, ''),
|
||||
('A4', "A4"),
|
||||
('A6', "A6"),
|
||||
('A7', "A7"),
|
||||
], "Paper Format", sort=False, translate=False,
|
||||
states={
|
||||
'required': Eval('shipping_service') == 'dpd',
|
||||
'invisible': Eval('shipping_service') != 'dpd',
|
||||
},
|
||||
depends=['shipping_service'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Carrier, cls).__setup__()
|
||||
cls.shipping_service.selection.append(('dpd', 'DPD'))
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return super().view_attributes() + [
|
||||
("/form/separator[@id='dpd']", 'states', {
|
||||
'invisible': Eval('shipping_service') != 'dpd',
|
||||
}),
|
||||
]
|
||||
@@ -3,6 +3,12 @@
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="carrier_view_form">
|
||||
<field name="model">carrier</field>
|
||||
<field name="inherit" ref="carrier.carrier_view_form"/>
|
||||
<field name="name">carrier_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="credential_view_form">
|
||||
<field name="model">carrier.credential.dpd</field>
|
||||
<field name="type">form</field>
|
||||
|
||||
@@ -20,3 +20,12 @@ Shipment.
|
||||
- *Password*: The Password used to access the DPD API.
|
||||
- *Server*: Are those credentials used for accessing the Testing or the
|
||||
Production server.
|
||||
|
||||
Carrier
|
||||
*******
|
||||
|
||||
The Carrier model is extended with the following fields:
|
||||
|
||||
- *Product*: The DPD product requested.
|
||||
- *Printer Language*: The type of file used for the label sent by DPD
|
||||
- *Paper Format*: The format of the label sent by DPD
|
||||
@@ -152,8 +152,8 @@ class CreateDPDShipping(Wizard):
|
||||
|
||||
def get_print_options(self, shipment):
|
||||
return {
|
||||
'printerLanguage': 'PDF',
|
||||
'paperFormat': 'A6',
|
||||
'printerLanguage': shipment.carrier.dpd_printer_language,
|
||||
'paperFormat': shipment.carrier.dpd_paper_format,
|
||||
}
|
||||
|
||||
def shipping_party(self, party, address):
|
||||
@@ -216,7 +216,7 @@ class CreateDPDShipping(Wizard):
|
||||
'generalShipmentData': {
|
||||
'identificationNumber': shipment.number,
|
||||
'sendingDepot': credential.depot,
|
||||
'product': 'CL',
|
||||
'product': shipment.carrier.dpd_product,
|
||||
'sender': self.shipping_party(
|
||||
shipment.company.party, shipment.warehouse.address),
|
||||
'recipient': self.shipping_party(
|
||||
|
||||
@@ -175,6 +175,9 @@ Create a DPD Carrier and the related credential::
|
||||
>>> carrier.party = dpd
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.shipping_service = 'dpd'
|
||||
>>> carrier.dpd_product = 'CL'
|
||||
>>> carrier.dpd_printer_language = 'PDF'
|
||||
>>> carrier.dpd_paper_format = 'A6'
|
||||
>>> carrier.save()
|
||||
|
||||
>>> catchall_selection = CarrierSelection(carrier=carrier)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='carrier_cost_method']" position="after">
|
||||
<separator string="DPD" colspan="4" id="dpd"/>
|
||||
<label name="dpd_product"/>
|
||||
<field name="dpd_product"/>
|
||||
<newline/>
|
||||
<label name="dpd_printer_language"/>
|
||||
<field name="dpd_printer_language"/>
|
||||
<label name="dpd_paper_format"/>
|
||||
<field name="dpd_paper_format"/>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in new issue
Block a user