[FIX] stock: add a partner on warehouse doesn't set correct properties

- Install stock with demo data
- Log in Chicago company
- Chicago partner has inter-company transit set on Customer and Supplier
locations
- Jeff Lawson (partner address of chicago warehouse) has Customer and
supplier locations set instead of inter-company transit.

It prevents the following usecase:
- Enable synch SO and PO between chicago and SF company with automatic
confirmation
- Create a product with route Buy and MTO
- Create a PO in company chicago that buy to SF comapny
- Validate the PO

You have an error with rule since it try to pull from intercompany
transit instead of customer

However if you log in San Francisco company Jeff Lawson has
inter-company transit set while it should not.

It happens because during the demo install the partner is added through
a write and the company is not provided and the code was missing a part
in that case.

closes odoo/odoo#82006

X-original-commit: 46c49ce4f6c9677463425981f01b69117c11943e
Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
Arnold Moyaux
2021-12-30 09:27:33 +00:00
parent 72ef6c8db5
commit 062ad4d998
+5 -1
View File
@@ -173,7 +173,11 @@ class Warehouse(models.Model):
# If another partner assigned
if vals.get('partner_id'):
warehouses._update_partner_data(vals['partner_id'], vals.get('company_id'))
if vals.get('company_id'):
warehouses._update_partner_data(vals['partner_id'], vals.get('company_id'))
else:
for warehouse in self:
warehouse._update_partner_data(vals['partner_id'], warehouse.company_id.id)
res = super(Warehouse, self).write(vals)