| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from odoo import fields, models, api, _ |
| 5 |
from odoo.exceptions import ValidationError |
| 6 |
|
| 7 |
|
| 8 |
class AccountJournal(models.Model): |
| 9 |
_inherit = 'account.journal' |
| 10 |
|
| 11 |
invoice_reference_model = fields.Selection( |
| 12 |
selection_add=[ |
| 13 |
('se_ocr2', 'Sweden OCR Level 1 & 2 (1255)'), |
| 14 |
('se_ocr3', 'Sweden OCR Level 3 (12658)'), |
| 15 |
('se_ocr4', 'Sweden OCR Level 4 (001271)'), |
| 16 |
], |
| 17 |
ondelete={'se_ocr2': 'set default', 'se_ocr3': 'set default', 'se_ocr4': 'set default'} |
| 18 |
) |
| 19 |
l10n_se_invoice_ocr_length = fields.Integer(string='OCR Number Length', help="Total length of OCR Reference Number including checksum.", default=6) |
| 20 |
|
| 21 |
@api.constrains('l10n_se_invoice_ocr_length') |
| 22 |
def _check_l10n_se_invoice_ocr_length(self): |
| 23 |
for journal in self: |
| 24 |
if journal.l10n_se_invoice_ocr_length < 6: |
| 25 |
raise ValidationError(_('OCR Reference Number length need to be greater than 5. Please correct settings under invoice journal settings.')) |