-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][BIG] Large refactoring/improvement/cleanup of OCA/bank-payment #1174
base: 16.0
Are you sure you want to change the base?
Changes from 2 commits
caad76b
c7391e0
7924a94
8fe91c9
f1d288c
472145e
489f4fe
00cb70c
e0ccf2d
5f1e105
f814d98
43dd15e
7d08c20
5cb6f26
47c621b
c2518b2
c4770fe
8eb0b3e
e05f3dc
2e9a083
f1cd3db
518fbec
8ab98dd
5aae5bd
f98ab6c
713160e
4bae9e5
6ba906f
8ee86dc
8c2360b
795ec55
f68e96a
bf9da9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2023 Akretion France (http://www.akretion.com/) | ||
# @author: Alexis de Lattre <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountPainRegulatoryReporting(models.Model): | ||
_name = "account.pain.regulatory.reporting" | ||
_description = "Regulatory Reporting Codes for ISO 20022/PAIN banking standard" | ||
_order = "code, country_id" | ||
|
||
code = fields.Char(required=True, copy=False, size=10) | ||
name = fields.Char(required=True, translate=True, copy=False) | ||
country_id = fields.Many2one("res.country", ondelete="restrict", required=False) | ||
active = fields.Boolean(default=True) | ||
|
||
_sql_constraints = [ | ||
( | ||
"code_country_unique", | ||
"unique(code, country_id)", | ||
"This code already exists for that country.", | ||
) | ||
] | ||
|
||
@api.depends("code", "name") | ||
def name_get(self): | ||
res = [] | ||
for rec in self: | ||
res.append((rec.id, "[%s] %s" % (rec.code, rec.name))) | ||
return res | ||
|
||
def _name_search( | ||
self, name="", args=None, operator="ilike", limit=100, name_get_uid=None | ||
): | ||
if args is None: | ||
args = [] | ||
ids = [] | ||
if name and operator == "ilike": | ||
ids = list(self._search([("code", "=", name)] + args, limit=limit)) | ||
if ids: | ||
return ids | ||
return super()._name_search( | ||
name=name, | ||
args=args, | ||
operator=operator, | ||
limit=limit, | ||
name_get_uid=name_get_uid, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,7 +285,6 @@ def _validate_xml(self, xml_string, gen_args): | |
) | ||
% str(e) | ||
) from None | ||
return True | ||
|
||
def finalize_sepa_file_creation(self, xml_root, gen_args): | ||
xml_string = etree.tostring( | ||
|
@@ -461,7 +460,6 @@ def generate_initiating_party_block(self, parent_node, gen_args): | |
) | ||
% self.company_id.name | ||
) | ||
return True | ||
|
||
@api.model | ||
def generate_party_agent( | ||
|
@@ -495,7 +493,6 @@ def generate_party_agent( | |
# for Credit Transfers, in the 'C' block, if BIC is not provided, | ||
# we should not put the 'Creditor Agent' block at all, | ||
# as per the guidelines of the EPC | ||
return True | ||
|
||
@api.model | ||
def generate_party_id(self, parent_node, party_type, partner): | ||
|
@@ -519,7 +516,9 @@ def generate_party_acc_number( | |
party_account_other = etree.SubElement(party_account_id, "Othr") | ||
party_account_other_id = etree.SubElement(party_account_other, "Id") | ||
party_account_other_id.text = partner_bank.sanitized_acc_number | ||
return True | ||
if party_type == "Dbtr" and partner_bank.currency_id: | ||
party_account_current = etree.SubElement(party_account, "Ccy") | ||
party_account_current.text = partner_bank.currency_id.name | ||
|
||
@api.model | ||
def generate_address_block(self, parent_node, partner, gen_args): | ||
|
@@ -567,7 +566,6 @@ def generate_address_block(self, parent_node, partner, gen_args): | |
gen_args=gen_args, | ||
) | ||
adrline2.text = val | ||
return True | ||
|
||
@api.model | ||
def generate_party_block( | ||
|
@@ -625,13 +623,12 @@ def generate_party_block( | |
gen_args, | ||
bank_line=bank_line, | ||
) | ||
return True | ||
|
||
@api.model | ||
def generate_remittance_info_block(self, parent_node, line, gen_args): | ||
remittance_info = etree.SubElement(parent_node, "RmtInf") | ||
communication_type = line.payment_line_ids[:1].communication_type | ||
if communication_type == "normal": | ||
if communication_type == "free": | ||
remittance_info_unstructured = etree.SubElement(remittance_info, "Ustrd") | ||
remittance_info_unstructured.text = self._prepare_field( | ||
"Remittance Unstructured Information", | ||
|
@@ -640,7 +637,7 @@ def generate_remittance_info_block(self, parent_node, line, gen_args): | |
140, | ||
gen_args=gen_args, | ||
) | ||
else: | ||
elif communication_type == "structured": | ||
remittance_info_structured = etree.SubElement(remittance_info, "Strd") | ||
creditor_ref_information = etree.SubElement( | ||
remittance_info_structured, "CdtrRefInf" | ||
|
@@ -657,7 +654,7 @@ def generate_remittance_info_block(self, parent_node, line, gen_args): | |
creditor_ref_info_type_issuer = etree.SubElement( | ||
creditor_ref_info_type, "Issr" | ||
) | ||
creditor_ref_info_type_issuer.text = communication_type | ||
creditor_ref_info_type_issuer.text = "ISO" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexis-via please keep communication_type. We need it for belgium where (IIRC) it must become bba. cc/ @luc-demeyer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbidoul There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out. Let's talk about this during the next code sprint, because the datamodel for structured communication type is really messy and unclean. I'm confident that we'll agree on a nice and clear datamodel on this, that will make the l10n_be_iso20022_pain simpler and make the XML generation code simpler. |
||
creditor_reference = etree.SubElement( | ||
creditor_ref_information, "CdtrRef" | ||
) | ||
|
@@ -676,7 +673,7 @@ def generate_remittance_info_block(self, parent_node, line, gen_args): | |
creditor_ref_info_type_issuer = etree.SubElement( | ||
creditor_ref_info_type, "Issr" | ||
) | ||
creditor_ref_info_type_issuer.text = communication_type | ||
creditor_ref_info_type_issuer.text = "ISO" | ||
|
||
creditor_reference = etree.SubElement(creditor_ref_information, "Ref") | ||
|
||
|
@@ -687,7 +684,6 @@ def generate_remittance_info_block(self, parent_node, line, gen_args): | |
35, | ||
gen_args=gen_args, | ||
) | ||
return True | ||
|
||
@api.model | ||
def generate_creditor_scheme_identification( | ||
|
@@ -709,4 +705,3 @@ def generate_creditor_scheme_identification( | |
csi_scheme_name = etree.SubElement(csi_other, "SchmeNm") | ||
csi_scheme_name_proprietary = etree.SubElement(csi_scheme_name, "Prtry") | ||
csi_scheme_name_proprietary.text = scheme_name_proprietary | ||
return True |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_pain_regulatory_reporting_read,Read access on account.pain.regulatory.reporting,model_account_pain_regulatory_reporting,base.group_user,1,0,0,0 | ||
access_account_pain_regulatory_reporting_full,Full access on account.pain.regulatory.reporting,model_account_pain_regulatory_reporting,account.group_account_manager,1,1,1,1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be the full right access the "Payment" group? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, you can just put
_rec_names_search = ["code", "name"]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for your remark!