Files
odoo_source/addons/l10n_se/models/res_partner.py
T
Daniel Stenlöv 8aa0f237b1 [MOV] l10n_se: merge l10n_se_ocr in l10n_se
Also did below improvements/fixes,
- Added missing .pot file for internationalization and re-exported
Swedish translation file and adapted the translation.
- Fixed partner view by inherting it from account instead of base.
- Constrain method should not 'return' ValidationError, it should
'raise', it is now fixed.

closes odoo/odoo#53298

Task: 2279356
Closes: #53298
Related: odoo/upgrade#1371
Signed-off-by: William André (wan) <wan@odoo.com>
2021-01-22 14:24:03 +00:00

22 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, api, _
from stdnum import luhn
class ResPartner(models.Model):
_inherit = 'res.partner'
l10n_se_check_vendor_ocr = fields.Boolean(string='Check Vendor OCR', help='This Vendor uses OCR Number on their Vendor Bills.')
l10n_se_default_vendor_payment_ref = fields.Char(string='Default Vendor Payment Ref', help='If set, the vendor uses the same Default Payment Reference or OCR Number on all their Vendor Bills.')
@api.onchange('l10n_se_default_vendor_payment_ref')
def onchange_l10n_se_default_vendor_payment_ref(self):
if not self.l10n_se_default_vendor_payment_ref == "" and self.l10n_se_check_vendor_ocr:
reference = self.l10n_se_default_vendor_payment_ref
try:
luhn.validate(reference)
except:
return {'warning': {'title': _('Warning'), 'message': _('Default vendor OCR number isn\'t a valid OCR number.')}}