Files
suite/delivery_partner_dhl/models/delivery.py
Leighton Pennicott 69a05508b9 [MIG] delivery_partner_dhl: migrate module from 12.0 to 13.0
Migrate delivery_partner_dhl from 12.0 to 13.0 and write tests for the validation error

H4409
2020-11-05 16:24:38 -05:00

18 lines
453 B
Python

import re
from odoo import fields, models
from odoo.exceptions import ValidationError
class PartnerShippingAccount(models.Model):
_inherit = 'partner.shipping.account'
delivery_type = fields.Selection(selection_add=[('dhl', 'DHL')])
def dhl_check_validity(self):
m = re.search(r'^(\d{8}|\d{9}|\d{10})$', self.name or '')
if not m:
raise ValidationError('DHL Account numbers must be 8-10 decimal numbers.')