| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
|
| 4 |
from odoo import models, _ |
| 5 |
from odoo.exceptions import UserError |
| 6 |
|
| 7 |
|
| 8 |
class SaleOrder(models.Model): |
| 9 |
_inherit = 'sale.order' |
| 10 |
|
| 11 |
def action_confirm(self): |
| 12 |
unmatch = self.filtered(lambda so: so.carrier_id.is_mondialrelay != so.partner_shipping_id.is_mondialrelay) |
| 13 |
if unmatch: |
| 14 |
error = _('Mondial Relay mismatching between delivery method and shipping address.') |
| 15 |
if len(self) > 1: |
| 16 |
error += ' (%s)' % ','.join(unmatch.mapped('name')) |
| 17 |
raise UserError(error) |
| 18 |
return super().action_confirm() |