[IMP] delivery_hibou: automatic signature required fields and calculations based on value.

This commit is contained in:
Jared Kipe
2021-10-25 10:08:37 -07:00
parent 5f00d694e0
commit 5ac761a035
6 changed files with 42 additions and 4 deletions

View File

@@ -9,6 +9,9 @@ class DeliveryCarrier(models.Model):
automatic_insurance_value = fields.Float(string='Automatic Insurance Value',
help='Will be used during shipping to determine if the '
'picking\'s value warrants insurance being added.')
automatic_sig_req_value = fields.Float(string='Automatic Signature Required Value',
help='Will be used during shipping to determine if the '
'picking\'s value warrants signature required being added.')
procurement_priority = fields.Selection(PROCUREMENT_PRIORITIES,
string='Procurement Priority',
help='Priority for this carrier. Will affect pickings '
@@ -31,6 +34,21 @@ class DeliveryCarrier(models.Model):
value = 0.0
return value
def get_signature_required(self, order=None, picking=None):
value = 0.0
if order:
if order.order_line:
value = sum(order.order_line.filtered(lambda l: l.type != 'service').mapped('price_subtotal'))
else:
return False
if picking:
value = picking.declared_value()
if picking.require_signature == 'no':
return False
elif picking.require_signature == 'yes':
return True
return self.automatic_sig_req_value and value >= self.automatic_sig_req_value
def get_third_party_account(self, order=None, picking=None):
if order and order.shipping_account_id:
return order.shipping_account_id