mirror of
https://github.com/bringout/oca-ocb-l10n_europe.git
synced 2026-04-27 10:22:07 +02:00
Initial commit: L10N_Europe packages
This commit is contained in:
commit
9803722600
2377 changed files with 380711 additions and 0 deletions
7
odoo-bringout-oca-ocb-l10n_be/l10n_be/models/__init__.py
Normal file
7
odoo-bringout-oca-ocb-l10n_be/l10n_be/models/__init__.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import account_chart_template
|
||||
from . import account_journal
|
||||
from . import account_move
|
||||
from . import res_partner
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# -*- 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'})})
|
||||
50
odoo-bringout-oca-ocb-l10n_be/l10n_be/models/account_move.py
Normal file
50
odoo-bringout-oca-ocb-l10n_be/l10n_be/models/account_move.py
Normal file
|
|
@ -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(r'\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
|
||||
20
odoo-bringout-oca-ocb-l10n_be/l10n_be/models/res_partner.py
Normal file
20
odoo-bringout-oca-ocb-l10n_be/l10n_be/models/res_partner.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- 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.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
@api.depends('vat', 'country_id')
|
||||
def _compute_company_registry(self):
|
||||
# OVERRIDE
|
||||
# If a belgian company has a VAT number then it's company registry is it's VAT Number (without country code).
|
||||
super()._compute_company_registry()
|
||||
for partner in self.filtered(lambda p: p.country_id.code == 'BE' and p.vat):
|
||||
vat_country, vat_number = self._split_vat(partner.vat)
|
||||
if vat_country == 'be' and self.simple_vat_check(vat_country, vat_number):
|
||||
partner.company_registry = vat_number
|
||||
Loading…
Add table
Add a link
Reference in a new issue