Before this commit, to aaccess some values of the DeliveryPackage objects, we needed to take the value from the related picking. for example, for the `payment country code` linked to the package, we need to retrieve the value from the related picking or order. To avoid passing too much data to the request objects, it is convenient to be able to access to the order/picking related to the package directly from the package. Because these objects are not children of odoo.models.Model, I do not need to follow the convention for the names, however, calling the picking > picking_id in the DeliveryPackage suggests that the picking is actually a odoo.models.Model child, which should be the case if it exists. reference-branch= https://github.com/odoo-dev/enterprise/tree/master-dhl_add_commercial_invoice-goa closes odoo/odoo#83404 Signed-off-by: Arnold Moyaux <arm@odoo.com>
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
class DeliveryPackage:
|
|
""" Each provider need similar information about its packages. """
|
|
def __init__(self, commodities, weight, package_type, name=None, total_cost=0, currency=None, picking=False, order=False):
|
|
""" The UOMs are based on the config parameters, which is very convenient:
|
|
we do not need to keep those stored."""
|
|
self.picking_id = picking
|
|
self.order_id = order
|
|
self.company_id = order and order.company_id or picking and picking.company_id
|
|
self.commodities = commodities or [] # list of DeliveryCommodity objects
|
|
self.weight = weight
|
|
self.dimension = {
|
|
'length': package_type.packaging_length,
|
|
'width': package_type.width,
|
|
'height': package_type.height
|
|
}
|
|
self.packaging_type = package_type.shipper_package_code or False
|
|
self.name = name
|
|
self.total_cost = total_cost
|
|
self.currency_id = currency
|
|
|
|
|
|
class DeliveryCommodity:
|
|
""" Commodities information are needed for Commercial invoices with each provider. """
|
|
def __init__(self, product, amount, monetary_value, country_of_origin):
|
|
self.product_id = product
|
|
self.qty = amount
|
|
self.monetary_value = monetary_value # based on company currency
|
|
self.country_of_origin = country_of_origin
|