[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:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user