odoo / odoo

Odoo. Open Source Apps To Grow Your Business.
https://www.odoo.com
Other
38.38k stars 24.9k forks source link

_check_company function in models.py fails in multi-company scenario #53187

Closed b-kannan closed 4 years ago

b-kannan commented 4 years ago

Impacted versions: 13.0

Steps to reproduce: a. Setup 2 companies (parent-child) and set current company to child b. Install manufacturing and configure advanced planning (workorders) c. Define a product for manufacturing (setup product, bom, components, etc.) d. Define a simple routing for manufacturing - 2 steps (sufficient) e. Create a new MO, and confirm f. Click Plan

Current behavior: Error

Some records are incompatible with the company of the Work Order.

Incompatibilities: Fields: leave_id Record ids: 32

Expected behavior: No errors.

Code snippet in debugger to highlight issue in line 3175 of models.py.

-> elif not (corecord.company_id <= company): (Pdb) corecord.company_id res.company(1,) (Pdb) company res.company(4,) (Pdb) corecord.company_id <= company False (Pdb) corecord.company_id.id <= company.id True

The way the code is written, it is doing a comparison on two objects that returns a False. In reality, the check should be between the two ids -- which would have returned True.

pedrobaeza commented 4 years ago

Closing as there's already a PR.