summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/tests
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2019-11-15 15:38:48 +0000
committerRaphael Collet <rco@odoo.com>2019-11-22 12:34:43 +0000
commite85faf398659a5beb0b1570a06af64dcf78dc1c8 (patch)
tree2726de4e47cb5f61bfd748416f85f3fadfb6bf7d /addons/point_of_sale/tests
parent8821f0e9176e3b976828f088ce5b7f5c6517b0c7 (diff)
[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>
Diffstat (limited to 'addons/point_of_sale/tests')
-rw-r--r--addons/point_of_sale/tests/test_frontend.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py
index 1b323572ff4..02447e04ab4 100644
--- a/addons/point_of_sale/tests/test_frontend.py
+++ b/addons/point_of_sale/tests/test_frontend.py
@@ -29,11 +29,13 @@ class TestPointOfSaleHttpCommon(odoo.tests.HttpCase):
'user_type_id': env.ref('account.data_account_type_receivable').id,
'reconcile': True})
self.env.company.account_default_pos_receivable_account_id = account_receivable
- field = env['ir.model.fields']._get('res.partner', 'property_account_receivable_id')
- env['ir.property'].create({'name': 'property_account_receivable_id',
- 'company_id': main_company.id,
- 'fields_id': field.id,
- 'value': 'account.account,' + str(account_receivable.id)})
+
+ self.env['ir.property'].set_default(
+ 'property_account_receivable_id',
+ 'res.partner',
+ account_receivable,
+ main_company,
+ )
cash_journal = journal_obj.create({
'name': 'Cash Test',