diff options
| author | Achraf (abz) <abz@odoo.com> | 2020-12-11 11:29:06 +0000 |
|---|---|---|
| committer | Achraf (abz) <abz@odoo.com> | 2020-12-16 09:12:12 +0000 |
| commit | a8467765b97e429712b79d41f88492993f8620ea (patch) | |
| tree | 3d92da704c484c68f31b05aee70c7eb9fa8e1e7c /addons/lunch | |
| parent | ff61ab121e3fb3c0c9b269c0dc9a65b3f1c8e664 (diff) | |
[FIX] lunch: Use extra toppings without problem
1) Extra Items
Issue: Adding an extra to one menu item, automatically adds it to the other food items in the same order.
Expected Behavior: When adding an extra, it should only be associated to
the food item for which it was selected, and NOT applied to the other ordered items.
For example, if I select a "Ranch" dressing for the "Chef Salad",
the ranch should not appear as an extra for the "Cheeseburger" or "Cookie of the Day".
2) Unable to Submit Certain Orders
Issue: Odoo prevents the user from submitting an order in the following case
(better illustrated through an example). If you select a "Chef Salad", you will be prompted to select a "Dressing Choice",
because the configuration is set to select one and only one extra.
You cannot add the salad to the cart without selecting a dressing,
nor can you proceed if you have more than one dressing selected;
this is functioning as expected. The problem, however, comes when you
select a dressing and add the salad to the cart, and now you try to add a
dressing as its own order item (separate from any salad). Even though the
salad has its own dressing selected, and the separate dressing is its own item,
the error message: "You have to order one and only one Dressing choice" appears and
prevents the order from being submitted. This issue may be a consequence of the behavior observed in the first issue.
Expected Behavior: The user should be able to submit the order in
this case because the salad had only one dressing associated with it,
and the extra dressing is supposed to be its own item.
This should not create a conflict with the "only one" extra logic.
Step to reproduce (edv)
Reproducible on runbot.
1) Extra Items
https://drive.google.com/file/d/1yos9coFqd55pq8qNbNs1OqGNMNSdgxDX/view
2) Unable to Submit Certain Orders
https://drive.google.com/file/d/1M0ZEElu-hYwU9bmCwEx_tqEZRAPG_UEt/view
opw-2391070
closes odoo/odoo#63228
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/lunch')
| -rw-r--r-- | addons/lunch/models/lunch_order.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/addons/lunch/models/lunch_order.py b/addons/lunch/models/lunch_order.py index 121ddb110c0..e25a550723a 100644 --- a/addons/lunch/models/lunch_order.py +++ b/addons/lunch/models/lunch_order.py @@ -123,18 +123,17 @@ class LunchOrder(models.Model): def write(self, values): merge_needed = 'note' in values or 'topping_ids_1' in values or 'topping_ids_2' in values or 'topping_ids_3' in values - # Only write on topping_ids_1 because they all share the same table - # and we don't want to remove all the records - # _extract_toppings will pop topping_ids_1, topping_ids_2 and topping_ids_3 from values - # This also forces us to invalidate the cache for topping_ids_2 and topping_ids_3 that - # could have changed through topping_ids_1 without the cache knowing about it - toppings = self._extract_toppings(values) - values['topping_ids_1'] = [(6, 0, toppings)] - self.invalidate_cache(['topping_ids_2', 'topping_ids_3']) - if merge_needed: lines_to_deactivate = self.env['lunch.order'] for line in self: + # Only write on topping_ids_1 because they all share the same table + # and we don't want to remove all the records + # _extract_toppings will pop topping_ids_1, topping_ids_2 and topping_ids_3 from values + # This also forces us to invalidate the cache for topping_ids_2 and topping_ids_3 that + # could have changed through topping_ids_1 without the cache knowing about it + toppings = self._extract_toppings(values) + self.invalidate_cache(['topping_ids_2', 'topping_ids_3']) + values['topping_ids_1'] = [(6, 0, toppings)] matching_lines = self._find_matching_lines({ 'user_id': values.get('user_id', line.user_id.id), 'product_id': values.get('product_id', line.product_id.id), |
