mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_banking_sepa_credit_transfer: Migration to 10.0
This commit is contained in:
committed by
Dũng (Trần Đình)
parent
81e1e6ccf3
commit
9f2c5b55de
@@ -49,7 +49,7 @@ Transfer that you created during the configuration step.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/173/9.0
|
||||
:target: https://runbot.odoo-community.org/runbot/173/10.0
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2010-2016 Akretion (www.akretion.com)
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||
# © 2014 Tecnativa - Pedro M. Baeza
|
||||
# © 2016 Tecnativa - Antonio Espinosa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Banking SEPA Credit Transfer',
|
||||
'summary': 'Create SEPA XML files for Credit Transfers',
|
||||
'version': '9.0.1.0.0',
|
||||
'version': '10.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': "Akretion, "
|
||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
|
||||
"Antiun Ingeniería S.L., "
|
||||
"Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/bank-payment',
|
||||
'category': 'Banking addons',
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
<odoo noupdate="1">
|
||||
|
||||
|
||||
<record id="sepa_credit_transfer" model="account.payment.method">
|
||||
@@ -12,5 +11,4 @@
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="payment_mode_outbound_sepa_ct1" model="account.payment.mode">
|
||||
<field name="name">SEPA Credit Transfer to suppliers</field>
|
||||
@@ -21,5 +20,5 @@
|
||||
<field name="supplier_payment_mode_id" ref="payment_mode_outbound_sepa_ct1"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import pooler, SUPERUSER_ID
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
cr.execute('''
|
||||
SELECT
|
||||
old_sepa.file,
|
||||
rel.account_order_id AS payment_order_id,
|
||||
payment_order.reference
|
||||
FROM migration_banking_export_sepa old_sepa
|
||||
LEFT JOIN migration_account_payment_order_sepa_rel rel
|
||||
ON old_sepa.id=rel.banking_export_sepa_id
|
||||
LEFT JOIN payment_order ON payment_order.id=rel.account_order_id
|
||||
''')
|
||||
|
||||
for sepa_file in cr.dictfetchall():
|
||||
if not sepa_file['payment_order_id']:
|
||||
continue
|
||||
filename = 'sct_%s.xml' % sepa_file['reference'].replace('/', '-')
|
||||
pool['ir.attachment'].create(
|
||||
cr, SUPERUSER_ID, {
|
||||
'name': filename,
|
||||
'res_id': sepa_file['payment_order_id'],
|
||||
'res_model': 'payment.order',
|
||||
'datas': str(sepa_file['file']),
|
||||
})
|
||||
return
|
||||
@@ -1,32 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
|
||||
cr.execute(
|
||||
'ALTER TABLE banking_export_sepa '
|
||||
'RENAME TO migration_banking_export_sepa')
|
||||
cr.execute(
|
||||
'ALTER TABLE account_payment_order_sepa_rel '
|
||||
'RENAME TO migration_account_payment_order_sepa_rel')
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
from . import account_payment_method
|
||||
from . import account_payment_order
|
||||
from . import account_payment_line
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class AccountPaymentLine(models.Model):
|
||||
_inherit = 'account.payment.line'
|
||||
|
||||
# local_instrument 'INST' used for instant credit transfers
|
||||
# which will begin on November 21st 2017, cf
|
||||
# https://www.europeanpaymentscouncil.eu/document-library/
|
||||
# rulebooks/2017-sepa-instant-credit-transfer-rulebook
|
||||
local_instrument = fields.Selection(
|
||||
selection_add=[('INST', 'Instant Transfer')])
|
||||
@@ -2,7 +2,7 @@
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields, api
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class AccountPaymentMethod(models.Model):
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, api, _
|
||||
from openerp.exceptions import UserError
|
||||
from odoo import models, api, _
|
||||
from odoo.exceptions import UserError
|
||||
from lxml import etree
|
||||
|
||||
|
||||
@@ -78,34 +78,37 @@ class AccountPaymentOrder(models.Model):
|
||||
transactions_count_a = 0
|
||||
amount_control_sum_a = 0.0
|
||||
lines_per_group = {}
|
||||
# key = (requested_date, priority, local_instrument)
|
||||
# key = (requested_date, priority, local_instrument, categ_purpose)
|
||||
# values = list of lines as object
|
||||
for line in self.bank_line_ids:
|
||||
priority = line.priority
|
||||
local_instrument = line.local_instrument
|
||||
categ_purpose = line.category_purpose
|
||||
# The field line.date is the requested payment date
|
||||
# taking into account the 'date_prefered' setting
|
||||
# cf account_banking_payment_export/models/account_payment.py
|
||||
# in the inherit of action_open()
|
||||
key = (line.date, priority, local_instrument)
|
||||
key = (line.date, priority, local_instrument, categ_purpose)
|
||||
if key in lines_per_group:
|
||||
lines_per_group[key].append(line)
|
||||
else:
|
||||
lines_per_group[key] = [line]
|
||||
for (requested_date, priority, local_instrument), lines in\
|
||||
lines_per_group.items():
|
||||
for (requested_date, priority, local_instrument, categ_purpose),\
|
||||
lines in lines_per_group.items():
|
||||
# B. Payment info
|
||||
payment_info, nb_of_transactions_b, control_sum_b = \
|
||||
self.generate_start_payment_info_block(
|
||||
pain_root,
|
||||
"self.name + '-' "
|
||||
"+ requested_date.replace('-', '') + '-' + priority + "
|
||||
"'-' + local_instrument",
|
||||
priority, local_instrument, False, requested_date, {
|
||||
"'-' + local_instrument + '-' + category_purpose",
|
||||
priority, local_instrument, categ_purpose,
|
||||
False, requested_date, {
|
||||
'self': self,
|
||||
'priority': priority,
|
||||
'requested_date': requested_date,
|
||||
'local_instrument': local_instrument or 'NOinstr',
|
||||
'category_purpose': categ_purpose or 'NOcateg',
|
||||
}, gen_args)
|
||||
self.generate_party_block(
|
||||
payment_info, 'Dbtr', 'B',
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def update_bank_journals(cr, pool):
|
||||
ajo = pool['account.journal']
|
||||
journal_ids = ajo.search(
|
||||
cr, SUPERUSER_ID, [('type', '=', 'bank')])
|
||||
sct_id = pool['ir.model.data'].xmlid_to_res_id(
|
||||
cr, SUPERUSER_ID,
|
||||
'account_banking_sepa_credit_transfer.sepa_credit_transfer')
|
||||
if sct_id:
|
||||
ajo.write(cr, SUPERUSER_ID, journal_ids, {
|
||||
'outbound_payment_method_ids': [(4, sct_id)],
|
||||
})
|
||||
def update_bank_journals(cr, registry):
|
||||
with api.Environment.manage():
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
ajo = env['account.journal']
|
||||
journals = ajo.search([('type', '=', 'bank')])
|
||||
sct = env.ref(
|
||||
'account_banking_sepa_credit_transfer.sepa_credit_transfer')
|
||||
if sct:
|
||||
journals.write({
|
||||
'outbound_payment_method_ids': [(4, sct.id)],
|
||||
})
|
||||
return
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp.addons.account.tests.account_test_classes\
|
||||
from odoo.addons.account.tests.account_test_classes\
|
||||
import AccountingTestCase
|
||||
from openerp.tools import float_compare
|
||||
from odoo.tools import float_compare
|
||||
import time
|
||||
from lxml import etree
|
||||
|
||||
@@ -56,6 +56,9 @@ class TestSCT(AccountingTestCase):
|
||||
self.eur_currency = self.env.ref('base.EUR')
|
||||
self.usd_currency = self.env.ref('base.USD')
|
||||
self.main_company.currency_id = self.eur_currency.id
|
||||
# Trigger the recompute of account type on res.partner.bank
|
||||
for bank_acc in self.partner_bank_model.search([]):
|
||||
bank_acc.acc_number = bank_acc.acc_number
|
||||
|
||||
def test_eur_currency_sct(self):
|
||||
invoice1 = self.create_invoice(
|
||||
@@ -126,7 +129,6 @@ class TestSCT(AccountingTestCase):
|
||||
self.assertEquals(attachment.datas_fname[-4:], '.xml')
|
||||
xml_file = attachment.datas.decode('base64')
|
||||
xml_root = etree.fromstring(xml_file)
|
||||
# print "xml_file=", etree.tostring(xml_root, pretty_print=True)
|
||||
namespaces = xml_root.nsmap
|
||||
namespaces['p'] = xml_root.nsmap[None]
|
||||
namespaces.pop(None)
|
||||
@@ -204,7 +206,6 @@ class TestSCT(AccountingTestCase):
|
||||
self.assertEquals(attachment.datas_fname[-4:], '.xml')
|
||||
xml_file = attachment.datas.decode('base64')
|
||||
xml_root = etree.fromstring(xml_file)
|
||||
# print "xml_file=", etree.tostring(xml_root, pretty_print=True)
|
||||
namespaces = xml_root.nsmap
|
||||
namespaces['p'] = xml_root.nsmap[None]
|
||||
namespaces.pop(None)
|
||||
@@ -247,5 +248,5 @@ class TestSCT(AccountingTestCase):
|
||||
'name': 'Great service',
|
||||
'account_id': self.account_expense.id,
|
||||
})
|
||||
invoice.signal_workflow('invoice_open')
|
||||
invoice.action_invoice_open()
|
||||
return invoice
|
||||
|
||||
Reference in New Issue
Block a user