[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>
This commit is contained in:
Lucas Lefèvre
2020-03-02 08:57:10 +00:00
parent d2860cc9dc
commit 983edd2fcc
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -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
+7
View File
@@ -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>