attempt fix to delivery carrier account - selecting collect account raising error
This commit is contained in:
parent
c507e5d416
commit
68d415fa17
2 changed files with 10 additions and 26 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
"name": "Carrier Accounts by Partner",
|
"name": "Carrier Accounts by Partner",
|
||||||
"version": "18.0.0.1.1",
|
"version": "18.0.0.1.2",
|
||||||
"summary": "Add one or many carrier accounts per partner",
|
"summary": "Add one or many carrier accounts per partner",
|
||||||
"category": "Delivery",
|
"category": "Delivery",
|
||||||
"author": "Bemade Inc.",
|
"author": "Bemade Inc.",
|
||||||
|
|
|
||||||
|
|
@ -322,37 +322,21 @@ class CarrierAccountMixin(models.AbstractModel):
|
||||||
@api.constrains("delivery_billing_mode", "carrier_id", "carrier_account_id")
|
@api.constrains("delivery_billing_mode", "carrier_id", "carrier_account_id")
|
||||||
def _check_carrier_account(self):
|
def _check_carrier_account(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.carrier_account_id and rec.delivery_billing_mode:
|
if (
|
||||||
if (
|
rec.carrier_account_id
|
||||||
rec.delivery_billing_mode == "collect"
|
and rec.delivery_billing_mode
|
||||||
and rec.carrier_account_id
|
and rec.carrier_account_id not in rec.valid_carrier_account_ids
|
||||||
not in (
|
):
|
||||||
rec.recipient_id | rec.recipient_id.commercial_partner_id
|
|
||||||
).carrier_account_ids
|
if rec.delivery_billing_mode == "collect":
|
||||||
):
|
|
||||||
raise UserError(
|
raise UserError(
|
||||||
"Carrier account is not associated with the recipient, but billing mode is collect."
|
"Carrier account is not associated with the recipient, but billing mode is collect."
|
||||||
)
|
)
|
||||||
elif (
|
elif rec.delivery_billing_mode in ["prepaid", "ppc", "no charge"]:
|
||||||
rec.delivery_billing_mode in ["prepaid", "ppc", "no charge"]
|
|
||||||
and rec.carrier_account_id
|
|
||||||
not in (
|
|
||||||
rec.sender_id | rec.sender_id.commercial_partner_id
|
|
||||||
).carrier_account_ids
|
|
||||||
):
|
|
||||||
raise UserError(
|
raise UserError(
|
||||||
"Carrier account is not associated with the sender, but billing mode is prepaid, ppc or no charge."
|
"Carrier account is not associated with the sender, but billing mode is prepaid, ppc or no charge."
|
||||||
)
|
)
|
||||||
elif (
|
elif rec.delivery_billing_mode == "third party":
|
||||||
rec.delivery_billing_mode == "third party"
|
|
||||||
and rec.carrier_account_id
|
|
||||||
in (
|
|
||||||
rec.sender_id
|
|
||||||
| rec.sender_id.commercial_partner_id
|
|
||||||
| rec.recipient_id
|
|
||||||
| rec.recipient_id.commercial_partner_id
|
|
||||||
).carrier_account_ids
|
|
||||||
):
|
|
||||||
raise UserError(
|
raise UserError(
|
||||||
"Third party carrier account cannot belong to sender or recipient."
|
"Third party carrier account cannot belong to sender or recipient."
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue