Browse Source

differentiate between EU / outside EU services

master
Harald Welte 9 months ago
parent
commit
5df351493e
  1. 14
      models/dp_delivery_carrier.py
  2. 4
      models/dp_shipping_service.py
  3. 4
      views/dp_delivery_carrier.xml

14
models/dp_delivery_carrier.py

@ -86,11 +86,23 @@ class DPDeliveryCarrier(models.Model):
last = last,
address = addr)
def _get_eu_res_country_group(self):
eu_group = self.env.ref("base.europe", raise_if_not_found=False)
if not eu_group:
raise Warning(_('The Europe country group cannot be found. '
'Please update the base module.'))
return eu_group
def get_services_by_country(self, service_class, country_code):
if country_code == 'DE':
return service_class.services_natl
else:
return service_class.services_intl
eu_country_group = self._get_eu_res_country_group()
country_id = self.env['res.country'].search([('code','=',country_code)])
if country_id in eu_country_group.country_ids.ids:
return service_class.services_eu
else:
return service_class.services_intl
# determine lowest-matching-max-weight service within same class
def get_service_by_class(self, recipient, weight, service_class):

4
models/dp_shipping_service.py

@ -13,6 +13,9 @@ class SMCShippingDpClass(models.Model):
# list of services in this class for national delivery
services_natl = fields.Many2many(comodel_name = 'delivery.carrier.dp.service',
relation = 'dp_class_natl_services_rel')
# list of services in this class for EU delivery
services_eu = fields.Many2many(comodel_name = 'delivery.carrier.dp.service',
relation = 'dp_class_eu_services_rel')
# list of services in this class for international delivery
services_intl = fields.Many2many(comodel_name = 'delivery.carrier.dp.service',
relation = 'dp_class_intl_services_rel')
@ -30,6 +33,7 @@ class SMCShippingDpService(models.Model):
width = fields.Integer("Width")
length = fields.Integer("Length")
international = fields.Boolean("International")
eu = fields.Boolean("EU")
# extend stock.picking with fields for Shipment and Voucher ID
class SMCStockPickingDp(models.Model):

4
views/dp_delivery_carrier.xml

@ -40,6 +40,7 @@
<field name="code"/>
<field name="prodws_id"/>
<field name="international"/>
<field name="eu"/>
<field name="cost_price"/>
</group>
<group>
@ -68,6 +69,7 @@
<field name="width"/>
<field name="length"/>
<field name="international"/>
<field name="eu"/>
</tree>
</field>
</record>
@ -82,6 +84,7 @@
<sheet>
<field name="name"/>
<field name="services_natl"/>
<field name="services_eu"/>
<field name="services_intl"/>
</sheet>
</form>
@ -95,6 +98,7 @@
<tree string="package">
<field name="name"/>
<field name="services_natl"/>
<field name="services_eu"/>
<field name="services_intl"/>
</tree>
</field>

Loading…
Cancel
Save