diff --git a/account_financial_test_data/README.rst b/account_financial_test_data/README.rst new file mode 100644 index 00000000..8c82d9bb --- /dev/null +++ b/account_financial_test_data/README.rst @@ -0,0 +1,54 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=========================== +Account financial test data +=========================== + +This module provides demo data for the repo 'account-financial-reporting' +and will allow people to test all reports properly and make tests as well. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/91/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Taktik +* Alex Comba + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_financial_test_data/__init__.py b/account_financial_test_data/__init__.py new file mode 100644 index 00000000..997f4f71 --- /dev/null +++ b/account_financial_test_data/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Taktik +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . pos_install import post_init_hook diff --git a/account_financial_test_data/__openerp__.py b/account_financial_test_data/__openerp__.py new file mode 100644 index 00000000..f1af1f4b --- /dev/null +++ b/account_financial_test_data/__openerp__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# © 2016 Taktik +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Account financial test data', + 'version': '9.0.1.0.0', + 'license': 'AGPL-3', + 'author': "Taktik, Odoo Community Association (OCA)", + 'category': 'Other', + 'depends': [ + "account_accountant", + "l10n_fr", + ], + 'demo': [], + 'data': [ + "data/settings_data.xml", + "data/account_auto_installer.xml", + "data/partners_data.xml", + "data/products_data.xml", + ], + 'post_init_hook': 'post_init_hook', + '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..b39899c8 --- /dev/null +++ b/account_financial_test_data/data/account_auto_installer.xml @@ -0,0 +1,43 @@ + + + + + + + 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..9ffefb7e --- /dev/null +++ b/account_financial_test_data/data/partners_data.xml @@ -0,0 +1,81 @@ + + + + + + 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/products_data.xml b/account_financial_test_data/data/products_data.xml new file mode 100644 index 00000000..e06d477d --- /dev/null +++ b/account_financial_test_data/data/products_data.xml @@ -0,0 +1,9 @@ + + + + + SALES + 1 + + + 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..67def320 --- /dev/null +++ b/account_financial_test_data/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Taktik +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import account_installer 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..45f393a8 --- /dev/null +++ b/account_financial_test_data/models/account_installer.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# © 2016 Taktik +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging +from openerp import models, api + +_logger = logging.getLogger(__name__) + + +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/pos_install.py b/account_financial_test_data/pos_install.py new file mode 100644 index 00000000..7fbd15c7 --- /dev/null +++ b/account_financial_test_data/pos_install.py @@ -0,0 +1,221 @@ +# -*- coding: utf-8 -*- +from datetime import date, datetime +from openerp import SUPERUSER_ID, api + + +# -*- coding: utf-8 -*- +# © 2016 Taktik +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +def post_init_hook(cr, registry): + + def update_partners(): + """ + Set the right account on partners + """ + + partner_a = env.ref('account_financial_test_data.data_partner_a') + partner_b = env.ref('account_financial_test_data.data_partner_b') + partner_c = env.ref('account_financial_test_data.data_partner_c') + partner_d = env.ref('account_financial_test_data.data_partner_d') + partner_e = env.ref('account_financial_test_data.data_partner_e') + partner_f = env.ref('account_financial_test_data.data_partner_f') + partner_g = env.ref('account_financial_test_data.data_partner_g') + + account_a_receivable = env['account.account'].search( + [('code', '=', '411700')] + ) + + account_receivable = env['account.account'].search( + [('code', '=', '411100')] + ) + + account_payable = env['account.account'].search( + [('code', '=', '401100')] + ) + + partner_a.property_account_receivable_id = account_a_receivable[0] + partner_a.property_account_payable_id = account_payable[0] + + partners_list = [ + partner_b, + partner_c, + partner_d, + partner_e, + partner_f, + partner_g + ] + + for partner in partners_list: + partner.property_account_receivable_id = account_receivable[0] + partner.property_account_payable_id = account_payable[0] + + return True + + def update_account_settings(): + """ + Configure account settings + """ + account_setting_obj = env['account.config.settings'] + account_setting = account_setting_obj.create({}) + account_setting.group_multi_currency = True + account_setting.default_sale_tax_id = env.ref('l10n_fr.tva_normale').id + account_setting.default_purchase_tax_id = env.ref( + 'l10n_fr.tva_normale').id + account_setting.execute() + + return True + + def update_account(): + """ + Change the name and currency of 411700 + """ + account_to_update = env['account.account'].search( + [('code', '=', '411700')] + )[0] + account_to_update.name = "Clients - USD" + account_to_update.currency_id = env.ref('base.USD').id + + return True + + def update_product(): + """ + Update the product with the right settings + """ + product = env.ref('account_financial_test_data.data_product_a') + product.standard_price = 1000 + product.lst_price = 1000 + product.taxes_id = [ + (6, 0, [env.ref('l10n_fr.tva_normale').id]) + ] + + product.supplier_taxes_id = [ + (6, 0, [env.ref('l10n_fr.tva_acq_normale_TTC').id]) + ] + + income_account = env['account.account'].search([ + ('code', '=', '707100') + ])[0] + expense_account = env['account.account'].search([ + ('code', '=', '607100') + ])[0] + + product.property_account_income_id = income_account + product.property_account_expense_id = expense_account + + return True + + def create_invoices(): + """ + Creates all necessary invoices + """ + now = datetime.now() + this_year = now.year + last_year = now.year - 1 + + invoice_obj = env['account.invoice'] + + # invoice_a + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_c').id, + 'account_id': env.ref( + 'account_financial_test_data.data_partner_c' + ).property_account_receivable_id.id, + 'type': 'out_invoice', + 'date_invoice': date(last_year, 1, 5), + 'date_due': date(last_year, 1, 31), + }) + + # invoice_b + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_a').id, + 'type': 'out_invoice', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_a' + ).property_account_receivable_id.id, + 'date_invoice': date(last_year, 1, 5), + 'date_due': date(last_year, 2, 4), + }) + + # invoice_c + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_d').id, + 'type': 'out_invoice', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_d' + ).property_account_receivable_id.id, + 'date_invoice': date(last_year, 12, 11), + 'date_due': date(this_year, 3, 10), + }) + + # invoice_d + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_g').id, + 'type': 'out_refund', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_g' + ).property_account_receivable_id.id, + 'date_invoice': date(this_year, 1, 3), + 'date_due': date(this_year, 4, 15), + }) + + # invoice_e + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_b').id, + 'type': 'out_invoice', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_b' + ).property_account_receivable_id.id, + 'date_invoice': date(this_year, 2, 3), + 'date_due': date(this_year, 2, 15), + }) + + # invoice_f + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_a').id, + 'type': 'out_invoice', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_a' + ).property_account_receivable_id.id, + 'date_invoice': date(this_year, 2, 23), + 'date_due': date(this_year, 3, 24), + }) + + # invoice_g + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_g').id, + 'type': 'out_invoice', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_g' + ).property_account_receivable_id.id, + 'date_invoice': date(this_year, 3, 17), + 'date_due': date(this_year, 4, 15), + }) + + # invoice_h + invoice_obj.create({ + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_f').id, + 'type': 'out_invoice', + 'account_id': env.ref( + 'account_financial_test_data.data_partner_f' + ).property_account_receivable_id.id, + 'date_invoice': date(this_year, 3, 17), + 'date_due': date(this_year, 4, 15), + }) + + return True + + env = api.Environment(cr, SUPERUSER_ID, {}) + update_partners() + update_account_settings() + update_account() + update_product() + create_invoices() 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