[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) <yti@odoo.com>
Signed-off-by: Alex Thuyls (alt) <alt@odoo.com>
This commit is contained in:
alt-odoo
2021-12-23 15:07:12 +00:00
parent bfec4e2ca4
commit 6fab93bf64
+3
View File
@@ -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({