[FIX] website_sale_picking: picking right warehouse without error

Steps to reproduce the bug:

- Get the website module.
- Go to Settings > Website > Shipping.
- Activate "On Site Payments & Picking" and save.
- Go to the same setting again and click on "Customize Pickup Sites".
- Pick the only delivery method that exists.
- Inside the delivery method, select a warehouse of the current company
and try to save.

Issue:

We won't be able to add a warehouse as the hidden field of the
`company_id` is not set.

Solution:

We modified the if statement inside `_check_warehouse_company` in order
to accept companies.

opw-3097424

closes odoo/odoo#112696

X-original-commit: dc8c24a5ace17382f54ad256b0ef585e24bca7ca
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
Maruan Aguerdouh (magm)
2023-02-15 10:14:47 +01:00
parent f8adfe72dd
commit e5aee1fcbf
@@ -19,7 +19,7 @@ class DeliveryCarrier(models.Model):
@api.constrains('warehouse_id', 'company_id')
def _check_warehouse_company(self):
for carrier in self:
if carrier.warehouse_id.company_id and carrier.company_id != carrier.warehouse_id.company_id:
if carrier.warehouse_id.company_id and carrier.company_id and carrier.company_id != carrier.warehouse_id.company_id:
raise ValidationError(_("The picking site and warehouse must share the same company"))
def onsite_rate_shipment(self, order):