From 4fc963b816e9be32367b90ad6aef50e244f3d541 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 20 Oct 2016 01:41:41 +0200 Subject: [PATCH] Port almost all modules to v10 (#305) Port almost all modules to v10 * Update to EPC Rulebook v9.2 that start to apply on 2016-11-20 (bug #300) --- .../README.rst | 2 +- .../__manifest__.py | 6 +-- .../data/account_payment_method.xml | 6 +-- .../demo/sepa_credit_transfer_demo.xml | 7 ++- .../migrations/8.0.0.3/post-migration.py | 52 ------------------- .../migrations/8.0.0.3/pre-migration.py | 32 ------------ .../models/account_payment_method.py | 2 +- .../models/account_payment_order.py | 4 +- .../post_install.py | 24 ++++----- .../tests/test_sct.py | 11 ++-- 10 files changed, 30 insertions(+), 116 deletions(-) delete mode 100644 account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py delete mode 100644 account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py diff --git a/account_banking_sepa_credit_transfer/README.rst b/account_banking_sepa_credit_transfer/README.rst index 6cdee145d..209255356 100644 --- a/account_banking_sepa_credit_transfer/README.rst +++ b/account_banking_sepa_credit_transfer/README.rst @@ -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 ====================== diff --git a/account_banking_sepa_credit_transfer/__manifest__.py b/account_banking_sepa_credit_transfer/__manifest__.py index 9c8cfe01d..26e8ebc85 100644 --- a/account_banking_sepa_credit_transfer/__manifest__.py +++ b/account_banking_sepa_credit_transfer/__manifest__.py @@ -7,10 +7,10 @@ { '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, " + "Tecnativa, " "Antiun Ingeniería S.L., " "Odoo Community Association (OCA)", 'website': 'https://github.com/OCA/bank-payment', @@ -24,5 +24,5 @@ 'demo/sepa_credit_transfer_demo.xml' ], 'post_init_hook': 'update_bank_journals', - 'installable': False, + 'installable': True, } diff --git a/account_banking_sepa_credit_transfer/data/account_payment_method.xml b/account_banking_sepa_credit_transfer/data/account_payment_method.xml index 438346067..515314b5a 100644 --- a/account_banking_sepa_credit_transfer/data/account_payment_method.xml +++ b/account_banking_sepa_credit_transfer/data/account_payment_method.xml @@ -1,6 +1,5 @@ - - + @@ -12,5 +11,4 @@ - - + diff --git a/account_banking_sepa_credit_transfer/demo/sepa_credit_transfer_demo.xml b/account_banking_sepa_credit_transfer/demo/sepa_credit_transfer_demo.xml index 224237ed1..c11d6ff76 100644 --- a/account_banking_sepa_credit_transfer/demo/sepa_credit_transfer_demo.xml +++ b/account_banking_sepa_credit_transfer/demo/sepa_credit_transfer_demo.xml @@ -1,7 +1,6 @@ + - - SEPA Credit Transfer to suppliers @@ -21,5 +20,5 @@ - - + + diff --git a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py b/account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py deleted file mode 100644 index 333651147..000000000 --- a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/post-migration.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# -# 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 . -# -############################################################################## - -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 diff --git a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py b/account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py deleted file mode 100644 index f1f5f7b0f..000000000 --- a/account_banking_sepa_credit_transfer/migrations/8.0.0.3/pre-migration.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com/) -# @author: Alexis de Lattre -# -# 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 . -# -############################################################################## - - -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') diff --git a/account_banking_sepa_credit_transfer/models/account_payment_method.py b/account_banking_sepa_credit_transfer/models/account_payment_method.py index 13f8930db..99dc6d0bf 100644 --- a/account_banking_sepa_credit_transfer/models/account_payment_method.py +++ b/account_banking_sepa_credit_transfer/models/account_payment_method.py @@ -2,7 +2,7 @@ # © 2016 Akretion (Alexis de Lattre ) # 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): diff --git a/account_banking_sepa_credit_transfer/models/account_payment_order.py b/account_banking_sepa_credit_transfer/models/account_payment_order.py index 85c94c724..6e629112d 100644 --- a/account_banking_sepa_credit_transfer/models/account_payment_order.py +++ b/account_banking_sepa_credit_transfer/models/account_payment_order.py @@ -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 diff --git a/account_banking_sepa_credit_transfer/post_install.py b/account_banking_sepa_credit_transfer/post_install.py index 631bef653..573ece934 100644 --- a/account_banking_sepa_credit_transfer/post_install.py +++ b/account_banking_sepa_credit_transfer/post_install.py @@ -2,18 +2,18 @@ # © 2016 Akretion (Alexis de Lattre ) # 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 diff --git a/account_banking_sepa_credit_transfer/tests/test_sct.py b/account_banking_sepa_credit_transfer/tests/test_sct.py index 76cb72aab..7a5ef853c 100644 --- a/account_banking_sepa_credit_transfer/tests/test_sct.py +++ b/account_banking_sepa_credit_transfer/tests/test_sct.py @@ -2,9 +2,9 @@ # © 2016 Akretion (Alexis de Lattre ) # 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