diff --git a/account_financial_test_data/__init__.py b/account_financial_test_data/__init__.py index e69de29b..cde864ba 100644 --- a/account_financial_test_data/__init__.py +++ b/account_financial_test_data/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/account_financial_test_data/__openerp__.py b/account_financial_test_data/__openerp__.py index 8c69071f..408390eb 100644 --- a/account_financial_test_data/__openerp__.py +++ b/account_financial_test_data/__openerp__.py @@ -1,15 +1,40 @@ -# -*- coding: utf-8 -*- -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# +# 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 . +# +############################################################################## + { - "name": "Account financial test data", - "summary": "Add all necessary data to test financial modules", - "version": "9.0.1.0.0", - "category": "Uncategorized", - "website": "https://odoo-community.org/", - "author": "Taktik, Odoo Community Association (OCA)", - "license": "AGPL-3", - "application": False, - "installable": True, - "data": [ - ] + 'name': 'Account financial test data', + 'version': '9.0.1.0.0', + 'license': 'AGPL-3', + 'author': "Taktik, Odoo Community Association (OCA)", + 'category': 'Other', + 'depends': [ + "base", + "account", + "account_accountant", + "l10n_fr", + ], + 'demo': [], + 'data': [ + "data/settings_data.xml", + "data/account_auto_installer.xml", + "data/partners_data.xml", + ], + 'installable': True, } diff --git a/account_financial_test_data/data/account_auto_installer.xml b/account_financial_test_data/data/account_auto_installer.xml new file mode 100644 index 00000000..1778da35 --- /dev/null +++ b/account_financial_test_data/data/account_auto_installer.xml @@ -0,0 +1,63 @@ + + + + + + + Set Accounting Options for all Companies + True + ir.actions.server + + code + +self.auto_execute(cr, uid, context=context) +config = self.next(cr, uid, [], context=context) or {} +if config.get('type') not in ('ir.actions.act_window_close',): + action = config + + + + + + 10 + automatic + open + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/account_financial_test_data/data/partners_data.xml b/account_financial_test_data/data/partners_data.xml new file mode 100644 index 00000000..a529e047 --- /dev/null +++ b/account_financial_test_data/data/partners_data.xml @@ -0,0 +1,76 @@ + + + + + + PARTNER A + + + + always + + + + + + PARTNER B + + + + always + + + + + PARTNER C + + + + always + + + + + PARTNER D + + + + always + + + + + PARTNER E + + + + always + + + + + PARTNER F + + + + always + + + + + PARTNER G + + + + always + + + + diff --git a/account_financial_test_data/data/settings_data.xml b/account_financial_test_data/data/settings_data.xml new file mode 100644 index 00000000..b297de1c --- /dev/null +++ b/account_financial_test_data/data/settings_data.xml @@ -0,0 +1,8 @@ + + + + + Europe/Paris + + + diff --git a/account_financial_test_data/models/__init__.py b/account_financial_test_data/models/__init__.py new file mode 100644 index 00000000..ad489180 --- /dev/null +++ b/account_financial_test_data/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +import account_installer +import setting diff --git a/account_financial_test_data/models/account_installer.py b/account_financial_test_data/models/account_installer.py new file mode 100644 index 00000000..be79c1bf --- /dev/null +++ b/account_financial_test_data/models/account_installer.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +from openerp.osv import orm +import logging +from openerp import models, fields, api, _, exceptions + +_logger = logging.getLogger(__name__) + + +class WizardMultiChartsAccounts(orm.TransientModel): + """ + Execute wizard automatically without showing the wizard popup window + """ + _inherit = 'wizard.multi.charts.accounts' + + def auto_execute(self, cr, uid, ids=False, context=None): + if not context: + context = {} + context['lang'] = 'en_US' + if not ids: + ids = self.search(cr, uid, [], context=context) + account_obj = self.pool.get('account.account') + for wz in self.browse(cr, uid, ids, context=context): + account_id = account_obj.search( + cr, + uid, + [('company_id', '=', wz.company_id.id)], + limit=1, + context=context + ) + if not account_id: + # execute original wizard method + _logger.info( + 'Configure Accounting Data for Company: %s' % + wz.company_id.name + ) + self.execute(cr, uid, [wz.id], context=context) + + +class AccountAccountTemplate(models.Model): + _inherit = "account.account.template" + + @api.model + def generate_account( + self, + chart_template_id, + tax_template_ref, + acc_template_ref, + code_digits, + company_id): + res = super(AccountAccountTemplate, self).generate_account( + chart_template_id, + tax_template_ref, + acc_template_ref, + code_digits, + company_id + ) + main_company_id = self.env['ir.model.data'].xmlid_to_res_id( + 'base.main_company' + ) + if company_id == main_company_id: + account_ids = [] + for template_account_id in res: + account_ids.append(res[template_account_id]) + return res diff --git a/account_financial_test_data/models/setting.py b/account_financial_test_data/models/setting.py new file mode 100644 index 00000000..41d2e4ce --- /dev/null +++ b/account_financial_test_data/models/setting.py @@ -0,0 +1,38 @@ +from openerp import api, models, fields, exceptions, _ +from openerp.modules.module import get_module_resource + + +class SettingCurrency(models.Model): + _name = 'setting.currency' + + @api.model + def _update_currency(self): + data_obj = self.env['ir.model.data'] + + eur = data_obj.xmlid_to_object('base.EUR') + usd = data_obj.xmlid_to_object('base.USD') + + eur.base = False + self.env['res.currency.rate'].search([ + ('currency_id', '=', eur.id) + ]).write({'rate': 0.8000}) + + main_company = data_obj.xmlid_to_object('base.main_company') + main_company.auto_currency_up = True + + services = self.env['currency.rate.update.service'].search( + [('company_id', '=', main_company.id), + ('service', '=', 'ECB_getter')] + ) + if services: + main_company.services_to_use = services[0] + else: + main_company.services_to_use = self.env[ + 'currency.rate.update.service' + ].create({ + 'service': 'ECB_getter', + 'max_delta_days': 1, + 'currency_to_update': [(6, 0, [eur.id, usd.id])] + }) + + main_company.button_refresh_currency() diff --git a/account_financial_test_data/static/description/icon.png b/account_financial_test_data/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_financial_test_data/static/description/icon.png differ