diff options
| author | Toufik Ben Jaa <tbe@odoo.com> | 2019-05-13 13:29:43 +0000 |
|---|---|---|
| committer | Toufik Ben Jaa <tbe@odoo.com> | 2019-05-14 09:57:56 +0000 |
| commit | 2a7652307e74927c5f9681d16c16d9293e5dbbf1 (patch) | |
| tree | 7edc859045a0c670b9af2a47852d33452541f016 | |
| parent | 23d1bb8ea12ba72c3644add9dff860b47f7053e1 (diff) | |
[FIX] lunch: missing products on lunch order page
- Since the performance commit @c42ccf2ca7f0a600a0dd7e3b4dd8bacd7a5c6513
the lunch products are displayed only if you have already ordered it.
- Added indexes on `lunch.order` to speed up the SQL request.
closes odoo/odoo#33336
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
| -rw-r--r-- | addons/lunch/models/lunch_order.py | 4 | ||||
| -rw-r--r-- | addons/lunch/report/lunch_product_report.py | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/addons/lunch/models/lunch_order.py b/addons/lunch/models/lunch_order.py index ee3f01c6d44..8ad99e9f940 100644 --- a/addons/lunch/models/lunch_order.py +++ b/addons/lunch/models/lunch_order.py @@ -42,6 +42,10 @@ class LunchOrder(models.Model): display_toppings = fields.Text('Toppings', compute='_compute_display_toppings', store=True) + def init(self): + self._cr.execute("""CREATE INDEX IF NOT EXISTS lunch_order_user_product_date ON %s (user_id, product_id, date)""" + % self._table) + @api.depends('topping_ids_1', 'topping_ids_2', 'topping_ids_3', 'product_id', 'quantity') def _compute_total_price(self): for line in self: diff --git a/addons/lunch/report/lunch_product_report.py b/addons/lunch/report/lunch_product_report.py index 7c9fcfcb000..ddec62aa10e 100644 --- a/addons/lunch/report/lunch_product_report.py +++ b/addons/lunch/report/lunch_product_report.py @@ -86,7 +86,7 @@ class LunchProductReport(models.Model): RIGHT JOIN res_users users ON users.company_id = product.company_id -- multi company LEFT JOIN lunch_product_favorite_user_rel fav ON fav.product_id = product.id AND fav.user_id = users.id JOIN res_groups_users_rel groups ON groups.uid = users.id -- only generate for internal users - JOIN lunch_order l_order ON l_order.product_id = product.id AND l_order.user_id = users.id AND l_order.date <= current_date + LEFT JOIN lunch_order l_order ON l_order.product_id = product.id AND l_order.user_id = users.id WHERE users.active AND product.active AND groups.gid = %%s --only take into account active products and users GROUP BY product.id, product.name, product.category_id, product.description, product.price, product.supplier_id, product.company_id, product.active, users.id, is_favorite, is_new ); |
