summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Lefèvre <lul@odoo.com>2020-02-25 13:53:57 +0000
committerLucas Lefèvre <lul@odoo.com>2020-03-02 08:57:10 +0000
commit983edd2fccf8fbcf4a65348c7268d9c9d3671ee2 (patch)
treec2fa9c287a16e9de5476de3e53e9276cb3533f4a
parentd2860cc9dc0fc220cdbc4e03cc7ffb76d31dade6 (diff)
[FIX] lunch: Apply real multi company ir.rule
The current "mutli-company filter" of lunch product reports is hardcoded in the SQL view, based on the user's company, ignoring the general mechanism of multi company rules (env allowed companies). Task 2202678 closes odoo/odoo#46630 X-original-commit: b77d2bde9431ae549779a466a76dae7c3173d8a6 Signed-off-by: lul-odoo <LucasLefevre@users.noreply.github.com>
-rw-r--r--addons/lunch/report/lunch_product_report.py2
-rw-r--r--addons/lunch/security/lunch_security.xml7
2 files changed, 8 insertions, 1 deletions
diff --git a/addons/lunch/report/lunch_product_report.py b/addons/lunch/report/lunch_product_report.py
index bd2f93600c5..8ff8858487f 100644
--- a/addons/lunch/report/lunch_product_report.py
+++ b/addons/lunch/report/lunch_product_report.py
@@ -91,7 +91,7 @@ class LunchProductReport(models.Model):
product.new_until >= current_date AS is_new,
orders.last_order_date
FROM lunch_product product
- INNER JOIN res_users users ON product.company_id IS NULL OR users.company_id = product.company_id -- multi company
+ CROSS JOIN res_users users
INNER JOIN res_groups_users_rel groups ON groups.uid = users.id -- only generate for internal users
LEFT JOIN LATERAL (select max(date) AS last_order_date FROM lunch_order where user_id=users.id and product_id=product.id) AS orders ON TRUE
LEFT JOIN LATERAL (select user_id FROM lunch_product_favorite_user_rel where user_id=users.id and product_id=product.id) AS fav ON TRUE
diff --git a/addons/lunch/security/lunch_security.xml b/addons/lunch/security/lunch_security.xml
index ac8d3eee796..01a59c0057a 100644
--- a/addons/lunch/security/lunch_security.xml
+++ b/addons/lunch/security/lunch_security.xml
@@ -85,5 +85,12 @@
<field name="global" eval="True"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
+
+ <record id="ir_rule_lunch_product_report_multi_company" model="ir.rule">
+ <field name="name">Lunch product report: Multi Company</field>
+ <field name="model_id" ref="model_lunch_product_report"/>
+ <field name="global" eval="True"/>
+ <field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
+ </record>
</data>
</odoo>