From 6fab93bf6478e2dd5e1007c4751f73540c43dc7b Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Thu, 2 Dec 2021 19:55:04 +0000 Subject: [PATCH] [FIX] lunch: prevent order of unavailable vendor There is a default Available Today filter on products view but it is not enough to prevent a very hungry employee to order a product from a vendor not available today if he removes the filter. closes odoo/odoo#81866 X-original-commit: 7ec9ab0e9efd87c9e49f72f5f9fc5e43108ed591 Signed-off-by: Yannick Tivisse (yti) Signed-off-by: Alex Thuyls (alt) --- addons/lunch/models/lunch_order.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/lunch/models/lunch_order.py b/addons/lunch/models/lunch_order.py index c3559040f97..aeeb244386a 100644 --- a/addons/lunch/models/lunch_order.py +++ b/addons/lunch/models/lunch_order.py @@ -206,6 +206,9 @@ class LunchOrder(models.Model): raise ValidationError(_('Your wallet does not contain enough money to order that. To add some money to your wallet, please contact your lunch manager.')) def action_order(self): + for order in self: + if not order.supplier_id.available_today: + raise UserError(_('The vendor related to this order is not available today.')) if self.filtered(lambda line: not line.product_id.active): raise ValidationError(_('Product is no longer available.')) self.write({