[FIX]move constraint from the rma order to the line

This commit is contained in:
ahenriquez
2019-10-29 16:36:59 +01:00
committed by mreficent
parent 270307a55e
commit 8e47ffc476
2 changed files with 7 additions and 12 deletions

View File

@@ -2,8 +2,7 @@
# © 2017 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, fields, models, _
from odoo.exceptions import UserError
from odoo import api, fields, models
from datetime import datetime
@@ -69,16 +68,6 @@ class RmaOrder(models.Model):
required=True, default=lambda self:
self.env.user.company_id)
@api.constrains("partner_id", "rma_line_ids")
def _check_partner_id(self):
if self.rma_line_ids and self.partner_id != self.mapped(
"rma_line_ids.partner_id"):
raise UserError(_(
"Group partner and RMA's partner must be the same."))
if len(self.mapped("rma_line_ids.partner_id")) > 1:
raise UserError(_(
"All grouped RMA's should have same partner."))
@api.model
def create(self, vals):
if (self.env.context.get('supplier') or

View File

@@ -676,3 +676,9 @@ class RmaOrderLine(models.Model):
result['views'] = [(res and res.id or False, 'form')]
result['res_id'] = rma_lines.id
return result
@api.constrains("partner_id", "rma_id")
def _check_partner_id(self):
if self.rma_id and self.partner_id != self.rma_id.partner_id:
raise ValidationError(_(
"Group partner and RMA's partner must be the same."))