summaryrefslogtreecommitdiff
path: root/odoo/addons/test_new_api/security
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2020-07-08 13:26:27 +0000
committerYannick Tivisse <yti@odoo.com>2020-08-04 15:01:45 +0000
commit62355b6ad3e2af16efabe1c3ca2fb053a6084bc1 (patch)
tree4286761086dad2cc81b3b4a5c70f46057b79f458 /odoo/addons/test_new_api/security
parenteecb1e01fc7cd7de3f3f7fd3d531e43bb8484a88 (diff)
[FIX] test_new_api: Fix bad shared cache usage for stored computed fields
Purpose ======= Since the 13.0, a regression has been introduced in hr_timesheet. Considering: - The account.analytic.line model, representing a timesheet entry - The project.task model, representing a task, on which we have the fields: - timesheet_ids: One2many - planned_hours: Computed (sudo), stored, representing the sum of the timesheet amounts - An ir.rule restricting the timesheets CRUD to his own only. A user can only see its own timesheets on a task, but the field "Planned Hours", which is stored-compute_sudo, should take all the timesheet lines into account However, when adding a new line and then recomputing the value, no existing line from another user is binded on self, then the value is erased and saved on the database. Specification ============= This commit introduces a test that illustrates that bad usage of a shared cache. A correct way to fix this could be to avoid using the cache if an ir.rule is pointing to the related model. That would force the recomputation in a real sudoed environment. closes odoo/odoo#55408 Taskid: 2285924 X-original-commit: 50e229fe66b2a82717d4260287e18a875bbd26f5 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'odoo/addons/test_new_api/security')
-rw-r--r--odoo/addons/test_new_api/security/ir.model.access.csv2
-rw-r--r--odoo/addons/test_new_api/security/test_new_api_security.xml11
2 files changed, 13 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/security/ir.model.access.csv b/odoo/addons/test_new_api/security/ir.model.access.csv
index 7133940fc92..be706801d98 100644
--- a/odoo/addons/test_new_api/security/ir.model.access.csv
+++ b/odoo/addons/test_new_api/security/ir.model.access.csv
@@ -60,3 +60,5 @@ access_test_new_api_model_selection_required,access_test_new_api_model_selection
access_test_new_api_model_selection_non_stored,access_test_new_api_model_selection_non_stored,model_test_new_api_model_selection_non_stored,,1,1,1,1
access_test_new_api_move,access_test_new_api_move,model_test_new_api_move,,1,1,1,1
access_test_new_api_move_line,access_test_new_api_move_line,model_test_new_api_move_line,,1,1,1,1
+access_test_new_api_model_shared_cache_compute_parent,access_test_new_api.model_shared_cache_compute_parent,model_test_new_api_model_shared_cache_compute_parent,,1,1,1,1
+access_test_new_api_model_shared_cache_compute_line,access_test_new_api.model_shared_cache_compute_line,model_test_new_api_model_shared_cache_compute_line,,1,1,1,1
diff --git a/odoo/addons/test_new_api/security/test_new_api_security.xml b/odoo/addons/test_new_api/security/test_new_api_security.xml
new file mode 100644
index 00000000000..56f591b9374
--- /dev/null
+++ b/odoo/addons/test_new_api/security/test_new_api_security.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<odoo>
+ <data noupdate="1">
+ <record id="ir_rule_test_new_api_model_shared_cache_compute_line" model="ir.rule">
+ <field name="name">model_shared_cache_compute_line: See own lines</field>
+ <field name="model_id" ref="test_new_api.model_test_new_api_model_shared_cache_compute_line"/>
+ <field name="domain_force">[('user_id', '=', user.id)]</field>
+ <field name="groups" eval="[(4, ref('base.group_user'))]"/>
+ </record>
+ </data>
+</odoo>