make use of customs_description module

The new customs_description module provides us with a better way
to provide customs description + HTS codes for product templates
or categories.
This commit is contained in:
Harald Welte 2021-03-07 23:14:57 +01:00
parent 824d432937
commit 416ca1377e
2 changed files with 6 additions and 12 deletions

View File

@ -7,7 +7,7 @@
'description':"""
""",
'author': 'Harald Welte',
'depends': ['odoo_shipping_service_apps'],
'depends': ['odoo_shipping_service_apps','customs_description'],
'data': [
'views/dp_delivery_carrier.xml',
'views/res_config.xml',

View File

@ -139,11 +139,8 @@ class DPDeliveryCarrier(models.Model):
product_uom_obj = self.env['product.uom']
q = product_uom_obj._compute_qty_obj(self._get_default_uom(), line.product_uom_qty, self.uom_id)
product = line.product_id
ptmpl = line.product_tmpl_id
if product:
if product.x_sysmo_customs_code:
hts = product.x_sysmo_customs_code
else:
raise Warning('Product Variant %s has no HTS defined' % (product.name))
if product.x_country_of_origin:
orig = product.x_country_of_origin.code
elif line.product_tmpl_id and line.product_tmpl_id.x_country_of_origin:
@ -151,24 +148,21 @@ class DPDeliveryCarrier(models.Model):
else:
raise Warning('Product Variant %s has no Country of Origin defined' % (product.name))
weight = product.weight
elif line.product_tmpl_id:
ptmpl = line.product_tmpl_id
if ptempl.x_sysmo_default_customs_code:
hts = ptempl.x_sysmo_default_customs_code
else:
raise Warning('Product %s has no HTS defined' % (ptempl.name))
else:
if ptempl.x_country_of_origin:
orig = ptempl.x_country_of_origin.code
else:
raise Warning('Product %s has no Country of Origin defined' % (ptempl.name))
weight = ptempl.weight
hts = ptmpl.customs_code.strip()
desc = ptmpl.customs_description_en
if line.procurement_id and line.procurement_id.sale_line_id:
price_unit = line.procurement_id.sale_line_id.price_unit
else:
raise Warning('Line has no procurement or procurement no sale order line?!?')
weight_g = weight * 1000
line_value = q * price_unit
return wpi.build_content_item(weight_g, line_value, q, hts, orig, product.name)
return wpi.build_content_item(weight_g, line_value, q, hts, orig, desc)
def build_wpi_content(self, wpi, picking):
"""Build contentPieces from Odoo stock.picking."""