initial budget + expected price constrain

This commit is contained in:
Esraa-Exp 2025-02-05 13:15:25 +02:00
parent 3d8e983074
commit 881541105f
1 changed files with 7 additions and 1 deletions

View File

@ -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!"))