diff --git a/account_banking_pain_base/__openerp__.py b/account_banking_pain_base/__manifest__.py similarity index 78% rename from account_banking_pain_base/__openerp__.py rename to account_banking_pain_base/__manifest__.py index 809182e29..173527f99 100644 --- a/account_banking_pain_base/__openerp__.py +++ b/account_banking_pain_base/__manifest__.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- # © 2013-2016 Akretion - Alexis de Lattre -# © 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 PAIN Base Module', 'summary': 'Base module for PAIN file generation', - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'license': 'AGPL-3', 'author': "Akretion, " "Noviat, " - "Serv. Tecnol. Avanzados - Pedro M. Baeza, " - "Antiun Ingeniería S.L., " + "Tecnativa, " "Odoo Community Association (OCA)", 'website': 'https://github.com/OCA/bank-payment', 'contributors': ['Pedro M. Baeza '], @@ -26,7 +25,7 @@ 'views/account_payment_order.xml', 'views/bank_payment_line_view.xml', 'views/account_payment_mode.xml', - 'views/res_company_view.xml', + 'views/account_config_settings.xml', 'views/account_payment_method.xml', ], 'post_init_hook': 'set_default_initiating_party', diff --git a/account_banking_pain_base/migrations/8.0.0.2/post-migration.py b/account_banking_pain_base/migrations/8.0.0.2/post-migration.py deleted file mode 100644 index 1a2815795..000000000 --- a/account_banking_pain_base/migrations/8.0.0.2/post-migration.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2015 Akretion - Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp.addons.account_banking_pain_base.post_install\ - import set_default_initiating_party -from openerp import pooler - - -def migrate(cr, version): - if not version: - return - - pool = pooler.get_pool(cr.dbname) - set_default_initiating_party(cr, pool) diff --git a/account_banking_pain_base/models/__init__.py b/account_banking_pain_base/models/__init__.py index 1e4dfae26..828efee19 100644 --- a/account_banking_pain_base/models/__init__.py +++ b/account_banking_pain_base/models/__init__.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- -# © 2013-2016 Akretion - Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import account_payment_line from . import account_payment_order from . import bank_payment_line from . import account_payment_mode from . import res_company +from . import account_config_settings from . import account_payment_method diff --git a/account_banking_pain_base/models/account_config_settings.py b/account_banking_pain_base/models/account_config_settings.py new file mode 100644 index 000000000..0a7caba0f --- /dev/null +++ b/account_banking_pain_base/models/account_config_settings.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# © 2016 Akretion - Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class AccountConfigSettings(models.TransientModel): + _inherit = 'account.config.settings' + + initiating_party_issuer = fields.Char( + related='company_id.initiating_party_issuer') + initiating_party_identifier = fields.Char( + related='company_id.initiating_party_identifier') diff --git a/account_banking_pain_base/models/account_payment_line.py b/account_banking_pain_base/models/account_payment_line.py index f599860e9..c430b5cff 100644 --- a/account_banking_pain_base/models/account_payment_line.py +++ b/account_banking_pain_base/models/account_payment_line.py @@ -3,7 +3,7 @@ # © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields +from odoo import models, fields class AccountPaymentLine(models.Model): diff --git a/account_banking_pain_base/models/account_payment_method.py b/account_banking_pain_base/models/account_payment_method.py index 9d9499036..f7623a5d6 100644 --- a/account_banking_pain_base/models/account_payment_method.py +++ b/account_banking_pain_base/models/account_payment_method.py @@ -2,8 +2,8 @@ # © 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 openerp.exceptions import UserError +from odoo import models, fields, api, _ +from odoo.exceptions import UserError class AccountPaymentMethod(models.Model): diff --git a/account_banking_pain_base/models/account_payment_mode.py b/account_banking_pain_base/models/account_payment_mode.py index e0e628a59..95ff0be79 100644 --- a/account_banking_pain_base/models/account_payment_mode.py +++ b/account_banking_pain_base/models/account_payment_mode.py @@ -4,7 +4,7 @@ # © 2016 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields +from odoo import models, fields class AccountPaymentMode(models.Model): diff --git a/account_banking_pain_base/models/account_payment_order.py b/account_banking_pain_base/models/account_payment_order.py index 917df61dc..4e62f6a99 100644 --- a/account_banking_pain_base/models/account_payment_order.py +++ b/account_banking_pain_base/models/account_payment_order.py @@ -4,12 +4,11 @@ # © 2016 Antiun Ingenieria S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields, api, _ -from openerp.exceptions import UserError -from openerp.tools.safe_eval import safe_eval +from odoo import models, fields, api, _, tools +from odoo.exceptions import UserError +from odoo.tools.safe_eval import safe_eval from datetime import datetime from lxml import etree -from openerp import tools import logging diff --git a/account_banking_pain_base/models/bank_payment_line.py b/account_banking_pain_base/models/bank_payment_line.py index bf802ce6e..dde080637 100644 --- a/account_banking_pain_base/models/bank_payment_line.py +++ b/account_banking_pain_base/models/bank_payment_line.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# © 2013-2015 Akretion - Alexis de Lattre +# © 2013-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 BankPaymentLine(models.Model): diff --git a/account_banking_pain_base/models/res_company.py b/account_banking_pain_base/models/res_company.py index aed1c1ca1..82e9d2711 100644 --- a/account_banking_pain_base/models/res_company.py +++ b/account_banking_pain_base/models/res_company.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# © 2013-2015 Akretion - Alexis de Lattre +# © 2013-2016 Akretion - Alexis de Lattre # © 2013 Noviat (http://www.noviat.com) - Luc de Meyer # © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza # 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 import logging logger = logging.getLogger(__name__) @@ -22,32 +22,31 @@ class ResCompany(models.Model): help="This will be used as the 'Initiating Party Identifier' in " "the PAIN files generated by Odoo.") - @api.model - def _default_initiating_party(self, company): - '''This method is called from post_install.py, which itself is also - called from migrations/8.0.0.2/post-migration.py''' + @api.one + def _default_initiating_party(self): + '''This method is called from post_install.py''' party_issuer_per_country = { 'BE': 'KBO-BCE', # KBO-BCE = the registry of companies in Belgium } logger.debug( - 'Calling _default_initiating_party on company %s', company.name) - country_code = company.country_id.code - if not company.initiating_party_issuer: + '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: - company.write({ + self.write({ 'initiating_party_issuer': party_issuer_per_country[country_code]}) logger.info( 'Updated initiating_party_issuer on company %s', - company.name) + self.name) party_identifier = False - if not company.initiating_party_identifier: - if company.vat and country_code: + if not self.initiating_party_identifier: + if self.vat and country_code: if country_code == 'BE': - party_identifier = company.vat[2:].replace(' ', '') + party_identifier = self.vat[2:].replace(' ', '') if party_identifier: - company.write({ + self.write({ 'initiating_party_identifier': party_identifier}) logger.info( 'Updated initiating_party_identifier on company %s', - company.name) + self.name) diff --git a/account_banking_pain_base/post_install.py b/account_banking_pain_base/post_install.py index 14a9259f9..df73e14d7 100644 --- a/account_banking_pain_base/post_install.py +++ b/account_banking_pain_base/post_install.py @@ -3,13 +3,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import SUPERUSER_ID +from odoo import api, SUPERUSER_ID -def set_default_initiating_party(cr, pool): - company_ids = pool['res.company'].search(cr, SUPERUSER_ID, []) - companies = pool['res.company'].browse(cr, SUPERUSER_ID, company_ids) - for company in companies: - pool['res.company']._default_initiating_party( - cr, SUPERUSER_ID, company) +def set_default_initiating_party(cr, registry): + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + companies = env['res.company'].search([]) + companies._default_initiating_party() return diff --git a/account_banking_pain_base/views/account_config_settings.xml b/account_banking_pain_base/views/account_config_settings.xml new file mode 100644 index 000000000..059b3e02e --- /dev/null +++ b/account_banking_pain_base/views/account_config_settings.xml @@ -0,0 +1,24 @@ + + + + + + + pain.group.on.account.config.settings + account.config.settings + + + + + + + + + + + + + diff --git a/account_banking_pain_base/views/account_payment_line.xml b/account_banking_pain_base/views/account_payment_line.xml index 640175857..e84958e63 100644 --- a/account_banking_pain_base/views/account_payment_line.xml +++ b/account_banking_pain_base/views/account_payment_line.xml @@ -1,11 +1,10 @@ - - + + pain.base.account.payment.line @@ -19,5 +18,5 @@ - - + + diff --git a/account_banking_pain_base/views/account_payment_method.xml b/account_banking_pain_base/views/account_payment_method.xml index 8d223b2b0..00685f7d6 100644 --- a/account_banking_pain_base/views/account_payment_method.xml +++ b/account_banking_pain_base/views/account_payment_method.xml @@ -1,6 +1,5 @@ - - + @@ -28,5 +27,4 @@ - - + diff --git a/account_banking_pain_base/views/account_payment_mode.xml b/account_banking_pain_base/views/account_payment_mode.xml index 29546b84e..5cb2b4d02 100644 --- a/account_banking_pain_base/views/account_payment_mode.xml +++ b/account_banking_pain_base/views/account_payment_mode.xml @@ -1,12 +1,10 @@ - - + @@ -23,5 +21,4 @@ - - + diff --git a/account_banking_pain_base/views/account_payment_order.xml b/account_banking_pain_base/views/account_payment_order.xml index e99928637..6c1e02900 100644 --- a/account_banking_pain_base/views/account_payment_order.xml +++ b/account_banking_pain_base/views/account_payment_order.xml @@ -1,11 +1,10 @@ - - + + pain.base.account.payment.order.form @@ -20,5 +19,5 @@ - - + + diff --git a/account_banking_pain_base/views/bank_payment_line_view.xml b/account_banking_pain_base/views/bank_payment_line_view.xml index 672e4bbbe..f9496dffd 100644 --- a/account_banking_pain_base/views/bank_payment_line_view.xml +++ b/account_banking_pain_base/views/bank_payment_line_view.xml @@ -1,11 +1,10 @@ - - + + pain.base.bank.payment.line.form @@ -19,5 +18,5 @@ - - + + diff --git a/account_banking_pain_base/views/res_company_view.xml b/account_banking_pain_base/views/res_company_view.xml deleted file mode 100644 index fd3af4755..000000000 --- a/account_banking_pain_base/views/res_company_view.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - pain.group.on.res.company.form - res.company - - - - - - - - - - - - -