diff options
| author | Hardik Prajapati <hpr@odoo.com> | 2019-05-28 09:22:23 +0000 |
|---|---|---|
| committer | Ravi Gohil <rgo@odoo.com> | 2019-07-29 12:44:12 +0000 |
| commit | 22223e144ad94a72f4feb245a98f7acf683aa93f (patch) | |
| tree | 2f2d65e2f49c60855b73aef63bd24ed587718cc5 /addons | |
| parent | 81c7afb8339e5aef91fc39ad2b1d7ac57d7b443e (diff) | |
[IMP] l10n_no: generate payment reference called KID
the KID number is base on invoice and payment
the KID number control digit is calculated from the MOD10 (luan)
the last digit in the KID number is a control digit.
task-1969040
closes #33779
Signed-off-by: Josse Colpaert <jco@openerp.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/l10n_no/__init__.py | 2 | ||||
| -rw-r--r-- | addons/l10n_no/models/__init__.py | 5 | ||||
| -rw-r--r-- | addons/l10n_no/models/account_journal.py | 10 | ||||
| -rw-r--r-- | addons/l10n_no/models/account_move.py | 29 |
4 files changed, 46 insertions, 0 deletions
diff --git a/addons/l10n_no/__init__.py b/addons/l10n_no/__init__.py index 52c150be0f0..06d8262bb0a 100644 --- a/addons/l10n_no/__init__.py +++ b/addons/l10n_no/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import models + def _preserve_tag_on_taxes(cr, registry): from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes diff --git a/addons/l10n_no/models/__init__.py b/addons/l10n_no/models/__init__.py new file mode 100644 index 00000000000..d2409f022e4 --- /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 00000000000..b030052781d --- /dev/null +++ b/addons/l10n_no/models/account_journal.py @@ -0,0 +1,10 @@ +# -*- 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')]) diff --git a/addons/l10n_no/models/account_move.py b/addons/l10n_no/models/account_move.py new file mode 100644 index 00000000000..f88cb3fd768 --- /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) |
