-
- Downloads
[IMP] base: add unique constraint on ir.property
There is no unique constraint on the properties to avoid having two properties for the same field, company and res_id. Having two properties for the same field, company and res_id, leads to inconsistencies through the code, as reading a company-dependent field nondeterministically returns one of the available property value. So now, before creating a property, we have to check that there is not already a value for the field, company and res_id and write or create depending on if it is already exists. The properties of specific records already satisfy the constraint thanks to the implementation of company-dependent fields that use the method `set_multi`. We added a method `set_default` to set generic properties, and its implementation does the right thing. It also simplifies the code to set such properties, by the way. closes odoo/odoo#40473 Signed-off-by:Xavier Morel (xmo) <xmo@odoo.com> Co-authored-by:
Raphael Collet <rco@odoo.com>
Showing
- addons/account/tests/common.py 6 additions, 26 deletionsaddons/account/tests/common.py
- addons/point_of_sale/tests/test_frontend.py 7 additions, 5 deletionsaddons/point_of_sale/tests/test_frontend.py
- addons/pos_restaurant/tests/test_frontend.py 8 additions, 5 deletionsaddons/pos_restaurant/tests/test_frontend.py
- addons/product/models/res_company.py 13 additions, 15 deletionsaddons/product/models/res_company.py
- addons/stock_account/__init__.py 15 additions, 50 deletionsaddons/stock_account/__init__.py
- addons/stock_account/tests/common.py 12 additions, 11 deletionsaddons/stock_account/tests/common.py
- addons/test_website_slides_full/tests/test_ui_wslides.py 5 additions, 12 deletionsaddons/test_website_slides_full/tests/test_ui_wslides.py
- odoo/addons/base/models/ir_property.py 37 additions, 1 deletionodoo/addons/base/models/ir_property.py
- odoo/addons/test_main_flows/tests/test_flow.py 7 additions, 26 deletionsodoo/addons/test_main_flows/tests/test_flow.py
- odoo/addons/test_new_api/tests/test_new_fields.py 4 additions, 7 deletionsodoo/addons/test_new_api/tests/test_new_fields.py
Loading
Please register or sign in to comment