bank-payment/account_banking_pain_base/models/res_company.py

56 lines
2.1 KiB
Python
Raw Permalink Normal View History

2024-05-03 08:36:50 +00:00
# Copyright 2013-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# Copyright 2013 Noviat (http://www.noviat.com) - Luc de Meyer
# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging
from flectra import fields, models
logger = logging.getLogger(__name__)
class ResCompany(models.Model):
_inherit = "res.company"
initiating_party_issuer = fields.Char(
size=35,
help="This will be used as the 'Initiating Party Issuer' in the "
"PAIN files generated by Flectra.",
)
initiating_party_identifier = fields.Char(
size=35,
help="This will be used as the 'Initiating Party Identifier' in "
"the PAIN files generated by Flectra.",
)
initiating_party_scheme = fields.Char(
size=35,
help="This will be used as the 'Initiating Party Scheme Name' in "
"the PAIN files generated by Flectra.",
)
def _default_initiating_party(self):
"""This method is called from post_install.py"""
self.ensure_one()
party_issuer_per_country = {
"BE": "KBO-BCE" # KBO-BCE = the registry of companies in Belgium
}
logger.debug("Calling _default_initiating_party on company %s", self.name)
country_code = self.country_id.code
if not self.initiating_party_issuer:
if country_code and country_code in party_issuer_per_country:
self.write(
{"initiating_party_issuer": party_issuer_per_country[country_code]}
)
logger.info("Updated initiating_party_issuer on company %s", self.name)
party_identifier = False
if not self.initiating_party_identifier:
if self.vat and country_code:
if country_code == "BE":
party_identifier = self.vat[2:].replace(" ", "")
if party_identifier:
self.write({"initiating_party_identifier": party_identifier})
logger.info(
"Updated initiating_party_identifier on company %s", self.name
)