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_be/models | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/l10n_be/models')
| -rw-r--r-- | addons/l10n_be/models/__init__.py | 6 | ||||
| -rw-r--r-- | addons/l10n_be/models/account_chart_template.py | 17 | ||||
| -rw-r--r-- | addons/l10n_be/models/account_invoice.py | 50 | ||||
| -rw-r--r-- | addons/l10n_be/models/account_journal.py | 12 |
4 files changed, 85 insertions, 0 deletions
diff --git a/addons/l10n_be/models/__init__.py b/addons/l10n_be/models/__init__.py new file mode 100644 index 00000000..e7cc9c9e --- /dev/null +++ b/addons/l10n_be/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import account_chart_template +from . import account_invoice +from . import account_journal diff --git a/addons/l10n_be/models/account_chart_template.py b/addons/l10n_be/models/account_chart_template.py new file mode 100644 index 00000000..a1bdf04f --- /dev/null +++ b/addons/l10n_be/models/account_chart_template.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models, fields + + +class AccountChartTemplate(models.Model): + _inherit = 'account.chart.template' + + @api.model + def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None): + journal_data = super(AccountChartTemplate, self)._prepare_all_journals( + acc_template_ref, company, journals_dict) + for journal in journal_data: + if journal['type'] in ('sale', 'purchase') and company.country_id.code == "BE": + journal.update({'refund_sequence': True}) + return journal_data diff --git a/addons/l10n_be/models/account_invoice.py b/addons/l10n_be/models/account_invoice.py new file mode 100644 index 00000000..3ee6d699 --- /dev/null +++ b/addons/l10n_be/models/account_invoice.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +# Copyright (c) 2011 Noviat nv/sa (www.noviat.be). All rights reserved. + +import random +import re + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError + +""" +account.move object: add support for Belgian structured communication +""" + + +class AccountMove(models.Model): + _inherit = 'account.move' + + def _get_invoice_reference_be_partner(self): + """ This computes the reference based on the belgian national standard + “OGM-VCS”. + For instance, if an invoice is issued for the partner with internal + reference 'food buyer 654', the digits will be extracted and used as + the data. This will lead to a check number equal to 72 and the + reference will be '+++000/0000/65472+++'. + If no reference is set for the partner, its id in the database will + be used. + """ + self.ensure_one() + bbacomm = (re.sub('\D', '', self.partner_id.ref or '') or str(self.partner_id.id))[-10:].rjust(10, '0') + base = int(bbacomm) + mod = base % 97 or 97 + reference = '+++%s/%s/%s%02d+++' % (bbacomm[:3], bbacomm[3:7], bbacomm[7:], mod) + return reference + + def _get_invoice_reference_be_invoice(self): + """ This computes the reference based on the belgian national standard + “OGM-VCS”. + The data of the reference is the database id number of the invoice. + For instance, if an invoice is issued with id 654, the check number + is 72 so the reference will be '+++000/0000/65472+++'. + """ + self.ensure_one() + base = self.id + bbacomm = str(base).rjust(10, '0') + base = int(bbacomm) + mod = base % 97 or 97 + reference = '+++%s/%s/%s%02d+++' % (bbacomm[:3], bbacomm[3:7], bbacomm[7:], mod) + return reference diff --git a/addons/l10n_be/models/account_journal.py b/addons/l10n_be/models/account_journal.py new file mode 100644 index 00000000..9fc1baf7 --- /dev/null +++ b/addons/l10n_be/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=[ + ('be', 'Belgium') + ], ondelete={'be': lambda recs: recs.write({'invoice_reference_model': 'odoo'})}) + |
