diff --git a/addons/sale_purchase/models/product_template.py b/addons/sale_purchase/models/product_template.py index 70e926e084e..a5d1b22feda 100644 --- a/addons/sale_purchase/models/product_template.py +++ b/addons/sale_purchase/models/product_template.py @@ -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):