Merge pull request #2771 from expsa/samir-aladawi-fix-purchase-requisition

[FIX] purchase_requisition_custom
This commit is contained in:
SamirLADOUI-sa 2025-04-16 07:49:47 +01:00 committed by GitHub
commit 8cc36566fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 13 deletions

View File

@ -525,19 +525,19 @@ class PurchaseOrderCustom(models.Model):
line.choosen = True
self._amount_all()
@api.constrains('requisition_id', 'partner_id')
def PreventSameVendor(self):
"""
Constrain to prevent the same vendor in the order for the same requisition
"""
orders = self.env['purchase.order'].search([
('id', '!=', self.id),
('requisition_id', '=', self.requisition_id.id),
('requisition_id', '!=', False),
('partner_id', '=', self.partner_id.id)
])
if len(orders) != 0:
raise ValidationError(_("This Vendor have order before"))
# @api.constrains('requisition_id', 'partner_id')
# def PreventSameVendor(self):
# """
# Constrain to prevent the same vendor in the order for the same requisition
# """
# orders = self.env['purchase.order'].search([
# ('id', '!=', self.id),
# ('requisition_id', '=', self.requisition_id.id),
# ('requisition_id', '!=', False),
# ('partner_id', '=', self.partner_id.id)
# ])
# if len(orders) != 0:
# raise ValidationError(_("This Vendor have order before"))
# test