[FIX] stock: fix search default property for missing locs
It may happen that there is a property defined on some field that is not the default property, but rather the property associated to a record. For example ``` => select id,name,company_id,fields_id,value_reference,res_id from ir_property where name like '%property_stock_inventory%' +------+--------------------------+--------------+-------------+-------------------+----------------------+ | id | name | company_id | fields_id | value_reference | res_id | |------+--------------------------+--------------+-------------+-------------------+----------------------| | 528 | property_stock_inventory | 1 | 4665 | <null> | product.template,752 | | 6 | property_stock_inventory | <null> | 4665 | stock.location,5 | <null> | +------+--------------------------+--------------+-------------+-------------------+----------------------+ ``` In this case the property with id=528 is not a default property since res_id is not NULL. Alternatively the property id=6 is a default one. The issue here is that when searching for the missing locations we do not filter out the properties with res_id not NULL, thus we may get that a company has the location define while in fact it doesn't. Following the example above, this means that we incorrectly get property id=528 as the one defining the location for the company id=1 here: https://github.com/odoo/odoo/blob/c5c47da2e96fd5e37030c70d6bb1bae4c4047fa8/addons/stock/models/res_company.py#L107 This not only prevents the creation of the correct default property but also the default locations https://github.com/odoo/odoo/blob/c5c47da2e96fd5e37030c70d6bb1bae4c4047fa8/addons/stock/models/res_company.py#L36-L51 On this patch we fix the domain search for default property. This allows for the correct creation of the default locations and associated properties. This issue was observed during upgrade 40921, where it prevents the upgrade to 15.0 closes odoo/odoo#78949 X-original-commit: 17e74b48 Signed-off-by:Arnold Moyaux <arm@odoo.com>
Please register or sign in to comment