forked from OCA/l10n-italy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14.0-super-merge' of git+ssh://github.com/aion-tech/l10…
…n-italy into 14.0-super-merge-rb
- Loading branch information
Showing
23 changed files
with
370 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
20 changes: 20 additions & 0 deletions
20
l10n_it_account_banking_sepa_credit_transfer/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Addebito diretto SEPA per l'Italia", | ||
"summary": "Crea file SEPA per l'addebito diretto", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Carlo Vettore, berim, Ooops404, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/l10n-italy", | ||
"category": "Banking addons", | ||
"external_dependencies": {"python": ["fintech>=7.2.10"]}, | ||
"depends": ["account_banking_sepa_credit_transfer", "account_payment_order"], | ||
"data": [ | ||
"data/account_payment_method.xml", | ||
"views/account_payment_line.xml", | ||
"views/res_partner_bank.xml", | ||
], | ||
"installable": True, | ||
"auto_install": False, | ||
} |
10 changes: 10 additions & 0 deletions
10
l10n_it_account_banking_sepa_credit_transfer/data/account_payment_method.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
<record id="sepa_credit_transfer_it" model="account.payment.method"> | ||
<field name="name">SEPA CBI Credit Transfer to suppliers</field> | ||
<field name="code">sepa_credit_transfer_it</field> | ||
<field name="payment_type">outbound</field> | ||
<field name="bank_account_required" eval="True" /> | ||
<field name="pain_version">pain.00.04.00</field> | ||
</record> | ||
</odoo> |
4 changes: 4 additions & 0 deletions
4
l10n_it_account_banking_sepa_credit_transfer/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import account_payment_line | ||
from . import account_payment_method | ||
from . import account_payment_order | ||
from . import res_partner_bank |
15 changes: 15 additions & 0 deletions
15
l10n_it_account_banking_sepa_credit_transfer/models/account_payment_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import logging | ||
|
||
from odoo import fields, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class AccountPaymentLine(models.Model): | ||
_inherit = "account.payment.line" | ||
|
||
line_sequence = fields.Integer(string="#", compute="_compute_line_sequence") | ||
|
||
def _compute_line_sequence(self): | ||
for _id, record in enumerate(self.order_id.payment_line_ids): | ||
record.line_sequence = _id + 1 |
17 changes: 17 additions & 0 deletions
17
l10n_it_account_banking_sepa_credit_transfer/models/account_payment_method.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2016-2020 Akretion (Alexis de Lattre <[email protected]>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountPaymentMethod(models.Model): | ||
_inherit = "account.payment.method" | ||
|
||
pain_version = fields.Selection( | ||
selection_add=[ | ||
("pain.00.04.00", "pain.00.04.00 (credit transfer in Italy)"), | ||
], | ||
ondelete={ | ||
"pain.00.04.00": "set null", | ||
}, | ||
) |
112 changes: 112 additions & 0 deletions
112
l10n_it_account_banking_sepa_credit_transfer/models/account_payment_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import logging | ||
|
||
from odoo import _, models | ||
from odoo.exceptions import RedirectWarning, ValidationError | ||
|
||
_logger = logging.getLogger(__name__) | ||
try: | ||
import fintech | ||
|
||
fintech.register() | ||
from fintech.sepa import Account, SEPACreditTransfer | ||
|
||
except ImportError: | ||
_logger.debug("Cannot `import fintech`, use `pip install fintech`") | ||
|
||
|
||
class AccountPaymentOrder(models.Model): | ||
_inherit = "account.payment.order" | ||
|
||
def generate_payment_file(self): | ||
|
||
self.ensure_one() | ||
if self.payment_method_id.pain_version != "pain.00.04.00": | ||
return super().generate_payment_file() | ||
|
||
# Create the debtor account from a tuple (ACCOUNT, BANKCODE) | ||
iban = self.company_partner_bank_id.acc_number.replace(" ", "") | ||
bic = self.company_partner_bank_id.bank_id.bic | ||
cuc = self.company_partner_bank_id.cuc | ||
acc_holder_name = ( | ||
self.company_partner_bank_id.acc_holder_name | ||
or self.company_partner_bank_id.partner_id.name | ||
) | ||
|
||
if not cuc: | ||
action = self.env.ref("base.action_res_partner_bank_account_form") | ||
action_dict = action.read()[0] | ||
action_dict.update( | ||
{ | ||
"res_id": self.company_partner_bank_id.id, | ||
"domain": [("id", "=", self.company_partner_bank_id.id)], | ||
} | ||
) | ||
raise RedirectWarning( | ||
message=_( | ||
f"Incorrect CUC for '{self.company_partner_bank_id.display_name}'\n" | ||
), | ||
action=action_dict, | ||
button_text=_("Bank Settings"), | ||
) | ||
|
||
if not bic: | ||
action = self.env.ref("base.action_res_bank_form") | ||
action_dict = action.read()[0] | ||
action_dict.update( | ||
{ | ||
"res_id": self.company_partner_bank_id.bank_id.id, | ||
"domain": [("id", "=", self.company_partner_bank_id.bank_id.id)], | ||
} | ||
) | ||
raise RedirectWarning( | ||
message=_( | ||
f"Incorrect BIC for '{self.company_partner_bank_id.bank_id.display_name}'\n" | ||
), | ||
action=action_dict, | ||
button_text=_("Bank Settings"), | ||
) | ||
|
||
debtor = Account(iban=(iban, bic), name=acc_holder_name) | ||
try: | ||
debtor.set_originator_id(cuc=cuc) | ||
except Exception as e: | ||
raise ValidationError(_("Error while setting originator id: {}".format(e))) | ||
|
||
# Create a SEPACreditTransfer instance | ||
sct = SEPACreditTransfer(debtor, cat_purpose="SUPP") | ||
|
||
for line in self.payment_line_ids: | ||
sequence = line.line_sequence | ||
if line.partner_bank_id.acc_type != "iban": | ||
action = self.env.ref("base.action_res_partner_bank_account_form") | ||
action_dict = action.read()[0] | ||
action_dict.update( | ||
{ | ||
"res_id": line.partner_bank_id.id, | ||
} | ||
) | ||
raise RedirectWarning( | ||
message=_( | ||
f"Incorrect IBAN for '{line.partner_id.display_name}' line {sequence}" | ||
), | ||
action=action_dict, | ||
button_text=_("Bank Settings"), | ||
) | ||
|
||
creditor_iban = line.partner_bank_id.acc_number.replace(" ", "") | ||
creditor_name = line.partner_id.name | ||
# Create the creditor account | ||
creditor = Account(creditor_iban, creditor_name) | ||
# Add the transaction | ||
sct.add_transaction( | ||
creditor, | ||
amount=line.amount_currency, | ||
purpose=line.communication, | ||
eref=f"{sequence}", | ||
due_date=line.date, | ||
) | ||
|
||
# Render the SEPA document | ||
xml_string = sct.render() | ||
filename = f"{self.name}.xml" | ||
return xml_string, filename |
13 changes: 13 additions & 0 deletions
13
l10n_it_account_banking_sepa_credit_transfer/models/res_partner_bank.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResPartnerBank(models.Model): | ||
_inherit = "res.partner.bank" | ||
|
||
cuc = fields.Char( | ||
string="CUC Code", | ||
size=35, | ||
help="Unique CBI code provided by your bank", | ||
) |
15 changes: 15 additions & 0 deletions
15
l10n_it_account_banking_sepa_credit_transfer/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
**English** | ||
|
||
This module allows to execute SEPA CBI payments, exporting a valid XML file accepted by italian banks. | ||
|
||
This module extends :code:`bank-payment/account_banking_sepa_credit_transfer`, adding to it the schema pain.00.04.00 (credit transfer in Italy). | ||
|
||
Configuration and usage are the same of module :code:`bank-payment/account_banking_sepa_credit_transfer`. | ||
|
||
**Italiano** | ||
|
||
Questo modulo consente di eseguire pagamenti SEPA CBI, ed esportare un file XML accettato dalle banche italiane. | ||
|
||
Questo modulo estende :code:`bank-payment/account_banking_sepa_credit_transfer`, aggiungendovi lo schema pain.00.04.00 (bonifico per l'Italia). | ||
|
||
La configurazione ed il funzionamento seguono quelle del modulo :code:`bank-payment/account_banking_sepa_credit_transfer`. |
53 changes: 53 additions & 0 deletions
53
l10n_it_account_banking_sepa_credit_transfer/readme/USAGE.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
English | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
**Configuration** | ||
|
||
You need to configure a bank account for the company that makes the payment, having at least the following data: | ||
|
||
- IBAN | ||
- BIC | ||
- CUC | ||
|
||
In addition, it is necessary to create a payment *mode* dedicated to the SEPA Credit Transfer, selecting SEPA CBI Credit Transfer to Suppliers as a *method*, automatically created upon module installation. | ||
|
||
This method is already configured to use the correct PAIN version (Pain.00.04.00). | ||
|
||
|
||
**Operation** | ||
|
||
When creating a supplier invoice, you must select the created SCT payment mode as a way of payment of the same. | ||
|
||
The invoice field *Payment reference* contains information that will be reported in the payment order field *Communication*, which is a mandatory field for the payment to be issued. | ||
|
||
Once the invoice is confirmed, it is necessary to add it to a payment order. | ||
|
||
Confirming the payment order, you can create and export the XML file for the bank. | ||
|
||
|
||
|
||
Italiano | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
**Configurazione** | ||
|
||
È necessario configurare un conto bancario per l'azienda che esegue il pagamento, che abbia almeno le seguenti informazioni: | ||
|
||
- IBAN | ||
- BIC | ||
- CUC | ||
|
||
Inoltre è necessario creare una *modalità* di pagamento dedicata al bonifico SEPA, selezionando come *metodo* "Bonifico SEPA CBI a fornitori", creato automaticamente all'installazione del modulo. | ||
|
||
Questo metodo è già configurato per utilizzare la corretta versione PAIN (pain.00.04.00). | ||
|
||
|
||
**Operatività** | ||
|
||
Quando si crea una fattura fornitore bisogna selezionare come modo di pagamento della stessa la modalità di pagamento SEPA SCT creata. | ||
|
||
Il campo della fattura *Riferimento di pagamento* contiene informazioni che verranno riportate nel campo *Comunicazione* dell'ordine di pagamento, che è un campo obbligatorio perché il pagamento venga emesso. | ||
|
||
Quindi, una volta confermata, è necessario aggiungere la fattura a un ordine di pagamento. | ||
|
||
Una volta confermato l'ordine di pagamento, è possibile creare ed esportare il file XML da passare alla banca. |
Binary file added
BIN
+9.23 KB
l10n_it_account_banking_sepa_credit_transfer/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
l10n_it_account_banking_sepa_credit_transfer/views/account_payment_line.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record id="account_payment_line_tree_inherit" model="ir.ui.view"> | ||
<field name="name">account.payment.line.tree.inherit</field> | ||
<field name="model">account.payment.line</field> | ||
<field | ||
name="inherit_id" | ||
ref="account_payment_order.account_payment_line_tree" | ||
/> | ||
<field name="arch" type="xml"> | ||
<field name="partner_id" position="before"> | ||
<field name="line_sequence" /> | ||
</field> | ||
|
||
</field> | ||
</record> | ||
|
||
</odoo> |
15 changes: 15 additions & 0 deletions
15
l10n_it_account_banking_sepa_credit_transfer/views/res_partner_bank.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="res_partner_bank_form_view"> | ||
<field name="name">res.partner.bank.form (add cuc)</field> | ||
<field name="model">res.partner.bank</field> | ||
<field name="inherit_id" ref="base.view_partner_bank_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="acc_holder_name" position="before"> | ||
<field name="cuc" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.