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:
parent
824d432937
commit
416ca1377e
|
@ -7,7 +7,7 @@
|
||||||
'description':"""
|
'description':"""
|
||||||
""",
|
""",
|
||||||
'author': 'Harald Welte',
|
'author': 'Harald Welte',
|
||||||
'depends': ['odoo_shipping_service_apps'],
|
'depends': ['odoo_shipping_service_apps','customs_description'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/dp_delivery_carrier.xml',
|
'views/dp_delivery_carrier.xml',
|
||||||
'views/res_config.xml',
|
'views/res_config.xml',
|
||||||
|
|
|
@ -139,11 +139,8 @@ class DPDeliveryCarrier(models.Model):
|
||||||
product_uom_obj = self.env['product.uom']
|
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)
|
q = product_uom_obj._compute_qty_obj(self._get_default_uom(), line.product_uom_qty, self.uom_id)
|
||||||
product = line.product_id
|
product = line.product_id
|
||||||
|
ptmpl = line.product_tmpl_id
|
||||||
if product:
|
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:
|
if product.x_country_of_origin:
|
||||||
orig = product.x_country_of_origin.code
|
orig = product.x_country_of_origin.code
|
||||||
elif line.product_tmpl_id and line.product_tmpl_id.x_country_of_origin:
|
elif line.product_tmpl_id and line.product_tmpl_id.x_country_of_origin:
|
||||||
|
@ -151,24 +148,21 @@ class DPDeliveryCarrier(models.Model):
|
||||||
else:
|
else:
|
||||||
raise Warning('Product Variant %s has no Country of Origin defined' % (product.name))
|
raise Warning('Product Variant %s has no Country of Origin defined' % (product.name))
|
||||||
weight = product.weight
|
weight = product.weight
|
||||||
elif line.product_tmpl_id:
|
else:
|
||||||
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))
|
|
||||||
if ptempl.x_country_of_origin:
|
if ptempl.x_country_of_origin:
|
||||||
orig = ptempl.x_country_of_origin.code
|
orig = ptempl.x_country_of_origin.code
|
||||||
else:
|
else:
|
||||||
raise Warning('Product %s has no Country of Origin defined' % (ptempl.name))
|
raise Warning('Product %s has no Country of Origin defined' % (ptempl.name))
|
||||||
weight = ptempl.weight
|
weight = ptempl.weight
|
||||||
|
hts = ptmpl.customs_code.strip()
|
||||||
|
desc = ptmpl.customs_description_en
|
||||||
if line.procurement_id and line.procurement_id.sale_line_id:
|
if line.procurement_id and line.procurement_id.sale_line_id:
|
||||||
price_unit = line.procurement_id.sale_line_id.price_unit
|
price_unit = line.procurement_id.sale_line_id.price_unit
|
||||||
else:
|
else:
|
||||||
raise Warning('Line has no procurement or procurement no sale order line?!?')
|
raise Warning('Line has no procurement or procurement no sale order line?!?')
|
||||||
weight_g = weight * 1000
|
weight_g = weight * 1000
|
||||||
line_value = q * price_unit
|
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):
|
def build_wpi_content(self, wpi, picking):
|
||||||
"""Build contentPieces from Odoo stock.picking."""
|
"""Build contentPieces from Odoo stock.picking."""
|
||||||
|
|
Loading…
Reference in New Issue