mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'imp/12.0/delivery_stamps__pricelist' into '12.0-test'
imp/12.0/delivery_stamps__pricelist into 12.0-test See merge request hibou-io/hibou-odoo/suite!956
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import hashlib
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
@@ -169,6 +170,10 @@ class ProviderStamps(models.Model):
|
|||||||
res = service.get_address(address).Address
|
res = service.get_address(address).Address
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _stamps_hash_partner(self, partner):
|
||||||
|
to_hash = ''.join(f[1] if isinstance(f, tuple) else str(f) for f in partner.read(['name', 'street', 'street2', 'city', 'country_id', 'state_id', 'zip', 'phone', 'email'])[0].values())
|
||||||
|
return hashlib.sha1(to_hash.encode()).hexdigest()
|
||||||
|
|
||||||
def _stamps_get_shippings_for_picking(self, service, picking):
|
def _stamps_get_shippings_for_picking(self, service, picking):
|
||||||
ret = []
|
ret = []
|
||||||
company, from_partner, to_partner = self._stamps_get_addresses_for_picking(picking)
|
company, from_partner, to_partner = self._stamps_get_addresses_for_picking(picking)
|
||||||
@@ -191,7 +196,7 @@ class ProviderStamps(models.Model):
|
|||||||
ret_val.ServiceType = self.stamps_service_type
|
ret_val.ServiceType = self.stamps_service_type
|
||||||
ret_val.WeightLb = weight
|
ret_val.WeightLb = weight
|
||||||
ret_val.ContentType = self._stamps_content_type(package=package)
|
ret_val.ContentType = self._stamps_content_type(package=package)
|
||||||
ret.append((package.name + ret_val.ShipDate + str(ret_val.WeightLb), ret_val))
|
ret.append((package.name + ret_val.ShipDate + str(ret_val.WeightLb) + self._stamps_hash_partner(to_partner), ret_val))
|
||||||
if not ret:
|
if not ret:
|
||||||
weight = self._stamps_convert_weight(picking.shipping_weight)
|
weight = self._stamps_convert_weight(picking.shipping_weight)
|
||||||
l, w, h = self._stamps_package_dimensions()
|
l, w, h = self._stamps_package_dimensions()
|
||||||
@@ -208,7 +213,7 @@ class ProviderStamps(models.Model):
|
|||||||
ret_val.ServiceType = self.stamps_service_type
|
ret_val.ServiceType = self.stamps_service_type
|
||||||
ret_val.WeightLb = weight
|
ret_val.WeightLb = weight
|
||||||
ret_val.ContentType = self._stamps_content_type()
|
ret_val.ContentType = self._stamps_content_type()
|
||||||
ret.append((picking.name + ret_val.ShipDate + str(ret_val.WeightLb), ret_val))
|
ret.append((picking.name + ret_val.ShipDate + str(ret_val.WeightLb) + self._stamps_hash_partner(to_partner), ret_val))
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@@ -327,13 +332,21 @@ class ProviderStamps(models.Model):
|
|||||||
# Note multiple packages will result in all product being on customs form.
|
# Note multiple packages will result in all product being on customs form.
|
||||||
# Recommended to ship one customs international package at a time.
|
# Recommended to ship one customs international package at a time.
|
||||||
for quant in picking.mapped('package_ids.quant_ids'):
|
for quant in picking.mapped('package_ids.quant_ids'):
|
||||||
if quant.product_id not in product_values:
|
# Customs should have the price for the destination but we may not be able
|
||||||
product_values[quant.product_id] = {
|
# to rely on the price from the SO (e.g. kit BoM)
|
||||||
|
product = quant.product_id
|
||||||
|
quantity = quant.quantity
|
||||||
|
price = product.lst_price
|
||||||
|
if to_partner.property_product_pricelist:
|
||||||
|
# Note the quantity is used for the price, but it is per unit
|
||||||
|
price = to_partner.property_product_pricelist.get_product_price(product, quantity, to_partner)
|
||||||
|
if product not in product_values:
|
||||||
|
product_values[product] = {
|
||||||
'quantity': 0.0,
|
'quantity': 0.0,
|
||||||
'value': 0.0,
|
'value': 0.0,
|
||||||
}
|
}
|
||||||
product_values[quant.product_id]['quantity'] += quant.quantity
|
product_values[product]['quantity'] += quantity
|
||||||
product_values[quant.product_id]['value'] += quant.quantity * quant.product_id.lst_price
|
product_values[product]['value'] += price * quantity
|
||||||
|
|
||||||
# Note that Stamps will not allow you to use the scale weight if it is not equal
|
# Note that Stamps will not allow you to use the scale weight if it is not equal
|
||||||
# to the sum of the customs lines.
|
# to the sum of the customs lines.
|
||||||
|
|||||||
Reference in New Issue
Block a user