From 983edd2fccf8fbcf4a65348c7268d9c9d3671ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Tue, 25 Feb 2020 13:53:57 +0000 Subject: [PATCH] [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 --- addons/lunch/report/lunch_product_report.py | 2 +- addons/lunch/security/lunch_security.xml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 @@ ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] + + + Lunch product report: Multi Company + + + ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] +