From 881541105f28d9e60b9630d31e08a9889577a3a0 Mon Sep 17 00:00:00 2001 From: Esraa-Exp Date: Wed, 5 Feb 2025 13:15:25 +0200 Subject: [PATCH] initial budget + expected price constrain --- .../purchase_custom_stock/models/purchase_request.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/odex25_purchase/purchase_custom_stock/models/purchase_request.py b/odex25_purchase/purchase_custom_stock/models/purchase_request.py index c05113599..6cc068270 100644 --- a/odex25_purchase/purchase_custom_stock/models/purchase_request.py +++ b/odex25_purchase/purchase_custom_stock/models/purchase_request.py @@ -49,7 +49,7 @@ class PurchaseRequest(models.Model): def action_confirm(self): init_active = self.env['ir.module.module'].sudo().search([('name', '=', 'initial_engagement_budget'), ('state', '=', 'installed')], limit=1) - init_budget = True if init_active else False + init_budget = self.initial_engagement_activate if len(self.line_ids) == 0: raise ValidationError(_("Can't Confirm Request With No Item!")) if not self.department_id: @@ -315,4 +315,10 @@ class PurchaseRequestLine(models.Model): if rec.qty <= 0: raise ValidationError(_("Item Quantity MUST be at Least ONE!")) + @api.constrains('expected_price') + def expected_price_validation(self): + for rec in self: + if rec.request_id.initial_engagement_activate == True and rec.expected_price <= 0: + raise ValidationError(_("Expected Price MUST be at Least ONE!")) +