diff --git a/account_financial_test_data/__init__.py b/account_financial_test_data/__init__.py index cde864ba..fddd5ef9 100644 --- a/account_financial_test_data/__init__.py +++ b/account_financial_test_data/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- 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 index 408390eb..8f7c95e4 100644 --- a/account_financial_test_data/__openerp__.py +++ b/account_financial_test_data/__openerp__.py @@ -35,6 +35,8 @@ "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/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/pos_install.py b/account_financial_test_data/pos_install.py new file mode 100644 index 00000000..a93c1591 --- /dev/null +++ b/account_financial_test_data/pos_install.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- +from openerp import SUPERUSER_ID, api, tools, _ + + +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(): + + invoice_obj = env['account.invoice'] + invoice_line_obj = env['account.invoice.line'] + invoice_line_values = { + + } + + invoice_values = { + 'partner_id': env.ref( + 'account_financial_test_data.data_partner_c').id, + 'date_invoice': '05/01/2015', + 'user_id': env.ref('base.user_root').id, + 'currency_id': env.ref('base.EUR').id, + 'invoice_line_ids': [], + + } + + return True + + env = api.Environment(cr, SUPERUSER_ID, {}) + update_partners() + update_account_settings() + update_account() + update_product() + # create_invoices()