Files
stock-rma/rma_purchase/models/rma_operation.py
2020-12-24 13:34:58 +05:30

25 lines
857 B
Python

# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import api, models, _
from odoo.exceptions import ValidationError
class RmaOperation(models.Model):
_inherit = 'rma.operation'
purchase_policy = fields.Selection(
selection=[('no', 'Not required'),
('ordered', 'Based on Ordered Quantities'),
('delivered', 'Based on Delivered Quantities')],
string="Purchase Policy", default='no',
)
@api.multi
@api.constrains('purchase_policy')
def _check_purchase_policy(self):
if self.filtered(
lambda r: r.purchase_policy != 'no' and r.type != 'supplier'):
raise ValidationError(_(
'Purchase Policy can only apply to supplier operations'))