[FIX] sale_purchase: Fix wrong constraint definition
constraint validation should work correctly on multi records creation/updates
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -18,9 +18,11 @@ class ProductTemplate(models.Model):
|
||||
]
|
||||
|
||||
@api.constrains('service_to_purchase', 'seller_ids')
|
||||
def validate_service_to_purchase(self):
|
||||
if self.service_to_purchase and not self.seller_ids:
|
||||
raise ValidationError("Please define the vendor from whom you would like to purchase this service automatically.")
|
||||
def _check_service_to_purchase(self):
|
||||
for template in self:
|
||||
if template.service_to_purchase and not template.seller_ids:
|
||||
raise ValidationError(_(
|
||||
"Please define the vendor from whom you would like to purchase this service automatically."))
|
||||
|
||||
@api.depends('type', 'expense_policy')
|
||||
def _compute_service_to_purchase(self):
|
||||
|
||||
Reference in New Issue
Block a user