[9.0][IMP] rma: add constrains

This commit is contained in:
lreficent
2017-10-19 10:10:19 +02:00
committed by ahenriquez
parent a82f603497
commit e22467a00b

View File

@@ -425,6 +425,17 @@ class RmaOrderLine(models.Model):
self.update(data) self.update(data)
self._remove_other_data_origin('reference_move_id') self._remove_other_data_origin('reference_move_id')
@api.multi
@api.constrains('reference_move_id', 'partner_id')
def _check_move_partner(self):
for rec in self:
if (rec.reference_move_id and
rec.reference_move_id.picking_id.partner_id !=
rec.partner_id):
raise ValidationError(_(
"RMA customer and originating stock move customer "
"doesn't match."))
@api.multi @api.multi
def _remove_other_data_origin(self, exception): def _remove_other_data_origin(self, exception):
if not exception == 'reference_move_id': if not exception == 'reference_move_id':