[IMP] delivery_hibou: add get_to_ship_picking_packages utility

I find that this must be in the pre-amble of iteration on pickings to ensure they have the correct output when package carriers are in play.

Specifically, we need to be able to 're-enter' the send to shipper method with a new package for a different carrier and not even try to ship if all packages have tracking numbers.
This commit is contained in:
Jared Kipe
2022-09-14 00:41:30 +00:00
parent 22a32f9582
commit def7e5da74

View File

@@ -51,6 +51,20 @@ class DeliveryCarrier(models.Model):
return package_types if not package_type else package_type return package_types if not package_type else package_type
# Utility # Utility
def get_to_ship_picking_packages(self, picking):
# Will return a stock.quant.package record set if the picking has packages
# in the case of multi-packing and none applicable, will return None
# Additionally, will not return packages that have a tracking number (because they have shipped)
picking_packages = picking.package_ids
package_carriers = picking_packages.mapped('carrier_id')
if package_carriers:
# only ship ours
picking_packages = picking_packages.filtered(lambda p: p.carrier_id == self and not p.carrier_tracking_ref)
if package_carriers and not picking_packages:
return None
return picking_packages
def get_insurance_value(self, order=None, picking=None, package=None): def get_insurance_value(self, order=None, picking=None, package=None):
value = 0.0 value = 0.0
if order: if order: