[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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user