diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/l10n_no/models | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/l10n_no/models')
| -rw-r--r-- | addons/l10n_no/models/__init__.py | 5 | ||||
| -rw-r--r-- | addons/l10n_no/models/account_journal.py | 12 | ||||
| -rw-r--r-- | addons/l10n_no/models/account_move.py | 29 |
3 files changed, 46 insertions, 0 deletions
diff --git a/addons/l10n_no/models/__init__.py b/addons/l10n_no/models/__init__.py new file mode 100644 index 00000000..d2409f02 --- /dev/null +++ b/addons/l10n_no/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import account_journal +from . import account_move diff --git a/addons/l10n_no/models/account_journal.py b/addons/l10n_no/models/account_journal.py new file mode 100644 index 00000000..fd75a635 --- /dev/null +++ b/addons/l10n_no/models/account_journal.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class AccountJournal(models.Model): + _inherit = 'account.journal' + + invoice_reference_model = fields.Selection(selection_add=[ + ('no', 'Norway') + ], ondelete={'no': lambda recs: recs.write({'invoice_reference_model': 'odoo'})}) diff --git a/addons/l10n_no/models/account_move.py b/addons/l10n_no/models/account_move.py new file mode 100644 index 00000000..f88cb3fd --- /dev/null +++ b/addons/l10n_no/models/account_move.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models +from stdnum import luhn + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _get_invoice_reference_no_invoice(self): + """ This computes the reference based on the Odoo format. + We calculat reference using invoice number and + partner id and added control digit at last. + """ + return self._get_kid_number() + + def _get_invoice_reference_no_partner(self): + """ This computes the reference based on the Odoo format. + We calculat reference using invoice number and + partner id and added control digit at last. + """ + return self._get_kid_number() + + def _get_kid_number(self): + self.ensure_one() + invoice_name = ''.join([i for i in self.name if i.isdigit()]).zfill(7) + ref = (str(self.partner_id.id).zfill(7)[-7:] + invoice_name[-7:]) + return ref + luhn.calc_check_digit(ref) |
