From b16cec65d225cfde7d1e00f11c72266682ccd3c6 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Tue, 11 May 2010 15:10:59 +0530 Subject: [PATCH] [ADD,IMP]:account chart for configurable chart and improvements bzr revid: nch@tinyerp.com-20100511094059-oiz2eyhw54su4lus --- addons/account/account_installer.xml | 8 +- addons/account/configurable_account_chart.xml | 516 ++++++++++++++++++ addons/account/installer.py | 309 +++++++++-- addons/base_setup/__init__.py | 17 +- addons/base_setup/base_setup_data.xml | 10 +- addons/base_setup/base_setup_installer.xml | 4 +- addons/base_setup/gtk_contact_form.py | 10 +- addons/hr/hr_installer.xml | 1 - addons/knowledge/knowledge_installer.xml | 5 +- addons/mrp/mrp_installer.xml | 1 - .../profile_accounting/profile_accounting.xml | 3 + addons/profile_tools/misc_tools_installer.xml | 1 - addons/project/project_installer.xml | 1 - addons/purchase/wizard/purchase_installer.xml | 1 - .../report_designer_installer.xml | 1 - addons/sale/sale_view.xml | 1 - addons/thunderbird/thunderbird_installer.xml | 11 +- 17 files changed, 830 insertions(+), 70 deletions(-) create mode 100644 addons/account/configurable_account_chart.xml diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 59c1240843b1..f67946ff7a23 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -26,19 +26,15 @@ <xpath expr='//separator[@string="vsep"]' position='attributes'> <attribute name='rowspan'>23</attribute> <attribute name='string'></attribute> - </xpath> - <xpath expr='//group[@string="progress"]' position='attributes'> - <attribute name='width'>190</attribute> - <attribute name='string'></attribute> </xpath> <group colspan="8"> <group colspan="4" height="450" width="600"> <field name="charts"/> - <group colspan="4" attrs="{'invisible':[('charts','!=','l10n_chart_configurable')]}"> + <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}"> <field name="sale_tax" colspan="2"/> <field name="purchase_tax" colspan="2"/> </group> - <group colspan="4" attrs="{'invisible':[('charts','!=','l10n_chart_configurable')]}"> + <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}"> <separator col="4" colspan="4" string="Bank and Cost Account"/> <field colspan="4" mode="tree" name="bank_accounts_id" nolabel="1" widget="one2many_list"> <form string="Bank Information"> diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml new file mode 100644 index 000000000000..a6b271bedcb3 --- /dev/null +++ b/addons/account/configurable_account_chart.xml @@ -0,0 +1,516 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data noupdate="1"> + + <!-- Types --> + <record model="account.account.type" id="conf_account_type_receivable" > + <field name="name">Receivable</field> + <field name="code">receivable</field> + <field name="close_method">unreconciled</field> + </record> + + <record model="account.account.type" id="conf_account_type_payable" > + <field name="name">Payable</field> + <field name="code">payable</field> + <field name="close_method">unreconciled</field> + </record> + + <record model="account.account.type" id="conf_account_type_view"> + <field name="name">View</field> + <field name="code">view</field> + <field name="close_method">none</field> + </record> + + <record model="account.account.type" id="conf_account_type_income" > + <field name="name">Income</field> + <field name="code">income</field> + <field name="close_method">none</field> + </record> + + <record model="account.account.type" id="conf_account_type_expense"> + <field name="name">Expense</field> + <field name="code">expense</field> + <field name="close_method">none</field> + </record> + + <record model="account.account.type" id="conf_account_type_tax"> + <field name="name">Tax</field> + <field name="code">tax</field> + <field name="close_method">unreconciled</field> + </record> + + <record model="account.account.type" id="conf_account_type_cash"> + <field name="name">Cash</field> + <field name="code">cash</field> + <field name="close_method">balance</field> + </record> + + <record model="account.account.type" id="conf_account_type_asset"> + <field name="name">Asset</field> + <field name="code">asset</field> + <field name="close_method">balance</field> + </record> + + <record model="account.account.type" id="conf_account_type_equity"> + <field name="name">Equity</field> + <field name="code">equity</field> + <field name="close_method">balance</field> + </record> + + <record model="account.account.type" id="conf_account_type_bnk"> + <field name="name">Bank</field> + <field name="code">bank</field> + <field name="close_method">balance</field> + </record> + <record model="account.account.type" id="conf_account_type_chk"> + <field name="name">Check</field> + <field name="code">check</field> + <field name="close_method">balance</field> + </record> + + + + <!-- Account Templates--> + <record id="conf_chart0" model="account.account.template"> + <field name="code">0</field> + <field name="name">Configurable Account Chart</field> + <field eval="0" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <!-- Balance Sheet --> + + <record id="conf_bal" model="account.account.template"> + <field name="code">1</field> + <field name="name">Balance Sheet</field> + <field ref="conf_chart0" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_fas" model="account.account.template"> + <field name="code">10</field> + <field name="name">Fixed Assets</field> + <field ref="conf_bal" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_xfa" model="account.account.template"> + <field name="code">100</field> + <field name="name">Fixed Asset Account</field> + <field ref="conf_fas" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_asset"/> + </record> + + <record id="conf_nca" model="account.account.template"> + <field name="code">11</field> + <field name="name">Net Current Assets</field> + <field ref="conf_bal" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_cas" model="account.account.template"> + <field name="code">110</field> + <field name="name">Current Assets</field> + <field ref="conf_nca" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_stk" model="account.account.template"> + <field name="code">1101</field> + <field name="name">Purchased Stocks</field> + <field ref="conf_cas" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_asset"/> + </record> + + <record id="conf_a_recv" model="account.account.template"> + <field name="code">1102</field> + <field name="name">Debtors</field> + <field ref="conf_cas" name="parent_id"/> + <field name="type">receivable</field> + <field eval="True" name="reconcile"/> + <field name="user_type" ref="conf_account_type_receivable"/> + </record> + + <!-- <record id="account.property_account_receivable" model="ir.property"> + <field eval="'account.account,'+str(a_recv)" name="value"/> + </record> --> + + <record id="conf_ova" model="account.account.template"> + <field name="code">1103</field> + <field name="name">Output VAT</field> + <field ref="conf_cas" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_tax"/> + </record> + + <record id="conf_bnk" model="account.account.template"> + <field name="code">1104</field> + <field name="name">Bank Current Account</field> + <field ref="conf_cas" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_cash"/> + </record> + + <record id="conf_cash" model="account.account.template"> + <field name="code">1105</field> + <field name="name">Cash</field> + <field ref="conf_cas" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_cash"/> + </record> + + <record id="conf_cli" model="account.account.template"> + <field name="code">111</field> + <field name="name">Current Liabilities</field> + <field ref="conf_nca" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_a_pay" model="account.account.template"> + <field name="code">1111</field> + <field name="name">Creditors</field> + <field ref="conf_cli" name="parent_id"/> + <field name="type">payable</field> + <field eval="True" name="reconcile"/> + <field name="user_type" ref="conf_account_type_payable"/> + </record> + + <!-- <record id="account.property_account_payable" model="ir.property"> + <field eval="'account.account,'+str(a_pay)" name="value"/> + </record>--> + + <record id="conf_iva" model="account.account.template"> + <field name="code">1112</field> + <field name="name">Input VAT</field> + <field ref="conf_cli" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_tax"/> + </record> + + <!-- Profit and Loss --> + + <record id="conf_gpf" model="account.account.template"> + <field name="code">2</field> + <field name="name">Profit and Loss</field> + <field ref="conf_chart0" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_rev" model="account.account.template"> + <field name="code">20</field> + <field name="name">Revenue</field> + <field ref="conf_gpf" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_a_sale" model="account.account.template"> + <field name="code">200</field> + <field name="name">Product Sales</field> + <field ref="conf_rev" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_income"/> + </record> + + <!-- <record id="account.property_account_income_categ" model="ir.property"> + <field eval="'account.account,'+str(a_sale)" name="value"/> + </record> --> + + <record id="conf_cos" model="account.account.template"> + <field name="code">21</field> + <field name="name">Cost of Sales</field> + <field ref="conf_gpf" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_cog" model="account.account.template"> + <field name="code">210</field> + <field name="name">Cost of Goods Sold</field> + <field ref="conf_cos" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_expense"/> + </record> + + <record id="conf_ovr" model="account.account.template"> + <field name="code">22</field> + <field name="name">Overheads</field> + <field ref="conf_gpf" name="parent_id"/> + <field name="type">view</field> + <field name="user_type" ref="conf_account_type_view"/> + </record> + + <record id="conf_a_expense" model="account.account.template"> + <field name="code">220</field> + <field name="name">Expenses</field> + <field ref="conf_ovr" name="parent_id"/> + <field name="type">other</field> + <field name="user_type" ref="conf_account_type_expense"/> + </record> + + <!-- <record id="account.property_account_expense_categ" model="ir.property"> + <field eval="'account.account,'+str(a_expense)" name="value"/> + </record> --> + + <!-- Taxes --> + <!-- VAT Code Definitions --> + + <!-- Invoiced VAT --> + + <!-- Input VAT --> + + <record id="vat_code_chart_root" model="account.tax.code.template"> + <field name="name">Plan Fees </field> + </record> + + <record id="vat_code_balance_net" model="account.tax.code.template"> + <field name="name">VAT Balance to Pay</field> + <field name="parent_id" ref="vat_code_chart_root"/> + </record> + + <record id="vat_code_input" model="account.tax.code.template"> + <field name="name">Input VAT</field> + <field name="parent_id" ref="vat_code_balance_net"/> + <field eval="-1" name="sign"/> + </record> + + <record id="vat_code_input_S" model="account.tax.code.template"> + <field name="name">Input VAT Rate S (15%)</field> + <field name="parent_id" ref="vat_code_input"/> + </record> + + <record id="vat_code_input_R" model="account.tax.code.template"> + <field name="name">Input VAT Rate R (5%)</field> + <field name="parent_id" ref="vat_code_input"/> + </record> + + <!-- Output VAT --> + + <record id="vat_code_output" model="account.tax.code.template"> + <field name="name">Output VAT</field> + <field name="parent_id" ref="vat_code_balance_net"/> + </record> + + <record id="vat_code_output_S" model="account.tax.code.template"> + <field name="name">Output VAT Rate S (15%)</field> + <field name="parent_id" ref="vat_code_output"/> + </record> + + <record id="vat_code_output_R" model="account.tax.code.template"> + <field name="name">Output VAT Rate R (5%)</field> + <field name="parent_id" ref="vat_code_output"/> + </record> + + <!-- Invoiced Base of VAT --> + + <!-- Purchases --> + + <record id="vat_code_base_net" model="account.tax.code.template"> + <field name="name">Tax Bases</field> + <field name="parent_id" ref="vat_code_chart_root"/> + </record> + + <record id="vat_code_base_purchases" model="account.tax.code.template"> + <field name="name">Taxable Purchases Base</field> + <field name="parent_id" ref="vat_code_base_net"/> + </record> + + <record id="vat_code_purch_S" model="account.tax.code.template"> + <field name="name">Taxable Purchases Rated S (15%)</field> + <field name="parent_id" ref="vat_code_base_purchases"/> + </record> + + <record id="vat_code_purch_R" model="account.tax.code.template"> + <field name="name">Taxable Purchases Rated R (5%)</field> + <field name="parent_id" ref="vat_code_base_purchases"/> + </record> + + <record id="vat_code_purch_Z" model="account.tax.code.template"> + <field name="name">Taxable Purchases Rated Z (0%)</field> + <field name="parent_id" ref="vat_code_base_purchases"/> + </record> + + <record id="vat_code_purch_X" model="account.tax.code.template"> + <field name="name">Taxable Purchases Type X (Exempt)</field> + <field name="parent_id" ref="vat_code_base_purchases"/> + </record> + + <record id="vat_code_purch_O" model="account.tax.code.template"> + <field name="name">Taxable Purchases Type O (Out of scope)</field> + <field name="parent_id" ref="vat_code_base_purchases"/> + </record> + + <!-- Sales --> + + <record id="vat_code_base_sales" model="account.tax.code.template"> + <field name="name">Base of Taxable Sales</field> + <field name="parent_id" ref="vat_code_base_net"/> + </record> + + <record id="vat_code_sales_S" model="account.tax.code.template"> + <field name="name">Taxable Sales Rated S (15%)</field> + <field name="parent_id" ref="vat_code_base_sales"/> + </record> + + <record id="vat_code_sales_R" model="account.tax.code.template"> + <field name="name">Taxable Sales Rated R (5%)</field> + <field name="parent_id" ref="vat_code_base_sales"/> + </record> + + <record id="vat_code_sales_Z" model="account.tax.code.template"> + <field name="name">Taxable Sales Rated Z (0%)</field> + <field name="parent_id" ref="vat_code_base_sales"/> + </record> + + <record id="vat_code_sales_X" model="account.tax.code.template"> + <field name="name">Taxable Sales Type X (Exempt)</field> + <field name="parent_id" ref="vat_code_base_sales"/> + </record> + + <record id="vat_code_sales_O" model="account.tax.code.template"> + <field name="name">Taxable Sales Type O (Out of scope)</field> + <field name="parent_id" ref="vat_code_base_sales"/> + </record> + + <record id="configurable_chart_template" model="account.chart.template"> + <field name="name">Configurable Account Chart Template</field> + <field name="account_root_id" ref="conf_chart0"/> + <field name="tax_code_root_id" ref="vat_code_chart_root"/> + <field name="bank_account_view_id" ref="conf_bnk"/> + <field name="property_account_receivable" ref="conf_a_recv"/> + <field name="property_account_payable" ref="conf_a_pay"/> + <field name="property_account_expense_categ" ref="conf_a_expense"/> + <field name="property_account_income_categ" ref="conf_a_sale"/> + </record> + + <!-- VAT Codes --> + <!-- Purchases + Input VAT --> + + <record id="ivats" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">IVAT S</field> + <field eval="0.15" name="amount"/> + <field name="type">percent</field> + <field name="account_collected_id" ref="conf_iva"/> + <field name="account_paid_id" ref="conf_iva"/> + <field name="base_code_id" ref="vat_code_purch_S"/> + <field name="tax_code_id" ref="vat_code_input_S"/> + <field name="ref_base_code_id" ref="vat_code_purch_S"/> + <field name="ref_tax_code_id" ref="vat_code_input_S"/> + <field name="type_tax_use">purchase</field> + </record> + + <record id="ivatr" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">IVAT R</field> + <field eval="0.005" name="amount"/> + <field name="type">percent</field> + <field name="account_collected_id" ref="conf_iva"/> + <field name="account_paid_id" ref="conf_iva"/> + <field name="base_code_id" ref="vat_code_purch_R"/> + <field name="tax_code_id" ref="vat_code_input_R"/> + <field name="ref_base_code_id" ref="vat_code_purch_R"/> + <field name="ref_tax_code_id" ref="vat_code_input_R"/> + <field name="type_tax_use">purchase</field> + </record> + + <record id="ivatz" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">IVAT Z</field> + <field eval="0.0" name="amount"/> + <field name="type">percent</field> + <field name="base_code_id" ref="vat_code_purch_Z"/> + <field name="ref_base_code_id" ref="vat_code_purch_Z"/> + <field name="type_tax_use">purchase</field> + </record> + + <record id="ivatx" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">IVAT X</field> + <field eval="0.0" name="amount"/> + <field name="type">percent</field> + <field name="base_code_id" ref="vat_code_purch_X"/> + <field name="ref_base_code_id" ref="vat_code_purch_X"/> + <field name="type_tax_use">purchase</field> + </record> + + <record id="ivato" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">IVAT O</field> + <field eval="0.0" name="amount"/> + <field name="type">percent</field> + <field name="base_code_id" ref="vat_code_purch_O"/> + <field name="ref_base_code_id" ref="vat_code_purch_O"/> + <field name="type_tax_use">purchase</field> + </record> + + <!-- Sales + Output VAT --> + + <record id="ovats" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">OVAT S</field> + <field eval="0.15" name="amount"/> + <field name="type">percent</field> + <field name="account_collected_id" ref="conf_ova"/> + <field name="account_paid_id" ref="conf_ova"/> + <field name="base_code_id" ref="vat_code_sales_S"/> + <field name="tax_code_id" ref="vat_code_output_S"/> + <field name="ref_base_code_id" ref="vat_code_sales_S"/> + <field name="ref_tax_code_id" ref="vat_code_output_S"/> + <field name="type_tax_use">sale</field> + </record> + + <record id="ovatr" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">OVAT R</field> + <field eval="0.005" name="amount"/> + <field name="type">percent</field> + <field name="account_collected_id" ref="conf_ova"/> + <field name="account_paid_id" ref="conf_ova"/> + <field name="base_code_id" ref="vat_code_sales_R"/> + <field name="tax_code_id" ref="vat_code_output_R"/> + <field name="ref_base_code_id" ref="vat_code_sales_R"/> + <field name="ref_tax_code_id" ref="vat_code_output_R"/> + <field name="type_tax_use">sale</field> + </record> + + <record id="ovatz" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">OVAT Z</field> + <field eval="0.0" name="amount"/> + <field name="type">percent</field> + <field name="base_code_id" ref="vat_code_sales_Z"/> + <field name="ref_base_code_id" ref="vat_code_sales_Z"/> + <field name="type_tax_use">sale</field> + </record> + + <record id="ovatx" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">OVAT X</field> + <field eval="0.0" name="amount"/> + <field name="type">percent</field> + <field name="base_code_id" ref="vat_code_sales_X"/> + <field name="ref_base_code_id" ref="vat_code_sales_X"/> + <field name="type_tax_use">sale</field> + </record> + + <record id="ovato" model="account.tax.template"> + <field name="chart_template_id" ref="configurable_chart_template"/> + <field name="name">OVAT O</field> + <field eval="0.0" name="amount"/> + <field name="type">percent</field> + <field name="base_code_id" ref="vat_code_sales_O"/> + <field name="ref_base_code_id" ref="vat_code_sales_O"/> + <field name="type_tax_use">sale</field> + </record> + </data> +</openerp> diff --git a/addons/account/installer.py b/addons/account/installer.py index 760518f90066..fd0d3836581e 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -21,10 +21,12 @@ import time import datetime from dateutil.relativedelta import relativedelta - +from tools.translate import _ from operator import itemgetter from osv import fields, osv import netsvc +import tools +from os.path import join as opj class account_installer(osv.osv_memory): _name = 'account.installer' @@ -37,19 +39,9 @@ class account_installer(osv.osv_memory): sorted(((m.name, m.shortdesc) for m in modules.browse(cr, uid, ids)), key=itemgetter(1))) + charts.insert(0,('configurable','Configurable Chart of Account')) return charts -# def default_get(self, cr, uid, fields_list=None, context=None): -# ''' set default accounts''' -# defaults = super(account_installer, self)\ -# .default_get(cr, uid, fields_list=fields_list, context=context) -# account = self.pool.get('account.bank.accounts.wizard') -# ids = [] -# for acc in ('Current','Deposit'): -# ids.append(account.create(cr, uid, {'acc_name':acc,'account_type':'cash','bank_account_id':self})) -# defaults.update({'bank_accounts_id':[(6,0,ids)]}) -# return defaults - _columns = { # Accounting 'charts':fields.selection(_get_charts, 'Chart of Accounts', @@ -84,7 +76,7 @@ class account_installer(osv.osv_memory): 'period':lambda *a:'month', 'sale_tax':lambda *a:0.0, 'purchase_tax':lambda *a:0.0, - 'charts':'l10n_chart_configurable', + 'charts':'configurable', } def on_change_start_date(self, cr, uid, id, start_date): @@ -94,37 +86,280 @@ class account_installer(osv.osv_memory): return {'value':{'date_stop':end_date.strftime('%Y-%m-%d')}} return {} + def generate_configurable_chart(self, cr, uid, ids, context=None): + mod_obj = self.pool.get('ir.model.data') + result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template') + id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] + obj_multi = self.pool.get('account.chart.template').browse(cr,uid, id) + + obj_acc = self.pool.get('account.account') + obj_acc_tax = self.pool.get('account.tax') + obj_journal = self.pool.get('account.journal') + obj_sequence = self.pool.get('ir.sequence') + obj_acc_template = self.pool.get('account.account.template') + obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') + obj_fiscal_position = self.pool.get('account.fiscal.position') + company_id = self.pool.get('res.users').browse(cr,uid,[uid],context)[0].company_id + seq_journal = True + + # Creating Account + obj_acc_root = obj_multi.account_root_id + tax_code_root_id = obj_multi.tax_code_root_id.id + + #new code + acc_template_ref = {} + tax_template_ref = {} + tax_code_template_ref = {} + todo_dict = {} + + #create all the tax code + children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') + children_tax_code_template.sort() + for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template): + vals={ + 'name': (tax_code_root_id == tax_code_template.id) and company_id.name or tax_code_template.name, + 'code': tax_code_template.code, + 'info': tax_code_template.info, + 'parent_id': tax_code_template.parent_id and ((tax_code_template.parent_id.id in tax_code_template_ref) and tax_code_template_ref[tax_code_template.parent_id.id]) or False, + 'company_id': company_id.id, + 'sign': tax_code_template.sign, + } + new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals) + #recording the new tax code to do the mapping + tax_code_template_ref[tax_code_template.id] = new_tax_code + + #create all the tax + for tax in obj_multi.tax_template_ids: + #create it + vals_tax = { + 'name':tax.name, + 'sequence': tax.sequence, + 'amount':tax.amount, + 'type':tax.type, + 'applicable_type': tax.applicable_type, + 'domain':tax.domain, + 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False, + 'child_depend': tax.child_depend, + 'python_compute': tax.python_compute, + 'python_compute_inv': tax.python_compute_inv, + 'python_applicable': tax.python_applicable, + 'tax_group':tax.tax_group, + 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, + 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, + 'base_sign': tax.base_sign, + 'tax_sign': tax.tax_sign, + 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, + 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, + 'ref_base_sign': tax.ref_base_sign, + 'ref_tax_sign': tax.ref_tax_sign, + 'include_base_amount': tax.include_base_amount, + 'description':tax.description, + 'company_id': company_id.id, + 'type_tax_use': tax.type_tax_use + } + new_tax = obj_acc_tax.create(cr,uid,vals_tax) + #as the accounts have not been created yet, we have to wait before filling these fields + todo_dict[new_tax] = { + 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, + 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, + } + tax_template_ref[tax.id] = new_tax + + #deactivate the parent_store functionnality on account_account for rapidity purpose + self.pool._init = True + + children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)]) + children_acc_template.sort() + for account_template in obj_acc_template.browse(cr, uid, children_acc_template): + tax_ids = [] + for tax in account_template.tax_ids: + tax_ids.append(tax_template_ref[tax.id]) + #create the account_account + + dig = 6 + code_main = account_template.code and len(account_template.code) or 0 + code_acc = account_template.code or '' + if code_main>0 and code_main<=dig and account_template.type != 'view': + code_acc=str(code_acc) + (str('0'*(dig-code_main))) + vals={ + 'name': (obj_acc_root.id == account_template.id) and company_id.name or account_template.name, + #'sign': account_template.sign, + 'currency_id': account_template.currency_id and account_template.currency_id.id or False, + 'code': code_acc, + 'type': account_template.type, + 'user_type': account_template.user_type and account_template.user_type.id or False, + 'reconcile': account_template.reconcile, + 'shortcut': account_template.shortcut, + 'note': account_template.note, + 'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False, + 'tax_ids': [(6,0,tax_ids)], + 'company_id': company_id.id, + } + new_account = obj_acc.create(cr,uid,vals) + acc_template_ref[account_template.id] = new_account + if account_template.name == 'Bank Current Account': + cash_result = mod_obj._get_id(cr, uid, 'account', 'conf_account_type_cash') + cash_type_id = mod_obj.read(cr, uid, [cash_result], ['res_id'])[0]['res_id'] + + bank_result = mod_obj._get_id(cr, uid, 'account', 'conf_account_type_bnk') + bank_type_id = mod_obj.read(cr, uid, [bank_result], ['res_id'])[0]['res_id'] + + check_result = mod_obj._get_id(cr, uid, 'account', 'conf_account_type_chk') + check_type_id = mod_obj.read(cr, uid, [check_result], ['res_id'])[0]['res_id'] + + record = self.browse(cr, uid, ids, context=context)[0] + code_cnt = 1 + for val in record.bank_accounts_id: + if val.account_type == 'cash':type = cash_type_id + elif val.account_type == 'bank':type = bank_type_id + else:type = check_type_id + vals = {'name': val.acc_name or '', + 'currency_id': val.currency_id.id or False, + 'code': str(110400 + code_cnt), + 'type': 'other', + 'user_type': type, + 'parent_id':new_account, + 'company_id': company_id.id } + obj_acc.create(cr, uid, vals) + code_cnt += 1 + + #reactivate the parent_store functionnality on account_account + self.pool._init = False + self.pool.get('account.account')._parent_store_compute(cr) + + for key,value in todo_dict.items(): + if value['account_collected_id'] or value['account_paid_id']: + obj_acc_tax.write(cr, uid, [key], { + 'account_collected_id': acc_template_ref[value['account_collected_id']], + 'account_paid_id': acc_template_ref[value['account_paid_id']], + }) + + # Creating Journals + vals_journal={} + view_id = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Journal View')])[0] + seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0] + + if seq_journal: + seq_id_sale = obj_sequence.search(cr,uid,[('name','=','Sale Journal')])[0] + seq_id_purchase = obj_sequence.search(cr,uid,[('name','=','Purchase Journal')])[0] + else: + seq_id_sale = seq_id + seq_id_purchase = seq_id + + vals_journal['view_id'] = view_id + + #Sales Journal + vals_journal['name'] = _('Sales Journal') + vals_journal['type'] = 'sale' + vals_journal['code'] = _('SAJ') + vals_journal['sequence_id'] = seq_id_sale + + if obj_multi.property_account_receivable: + vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id] + vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id] + + obj_journal.create(cr,uid,vals_journal) + + # Purchase Journal + vals_journal['name'] = _('Purchase Journal') + vals_journal['type'] = 'purchase' + vals_journal['code'] = _('EXJ') + vals_journal['sequence_id'] = seq_id_purchase + + if obj_multi.property_account_payable: + vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id] + vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id] + + obj_journal.create(cr,uid,vals_journal) + + # Bank Journals + view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0] + view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Multi-Currency Cash Journal View')])[0] + ref_acc_bank = obj_multi.bank_account_view_id + + + #create the properties + property_obj = self.pool.get('ir.property') + fields_obj = self.pool.get('ir.model.fields') + + todo_list = [ + ('property_account_receivable','res.partner','account.account'), + ('property_account_payable','res.partner','account.account'), + ('property_account_expense_categ','product.category','account.account'), + ('property_account_income_categ','product.category','account.account'), + ('property_account_expense','product.template','account.account'), + ('property_account_income','product.template','account.account') + ] + for record in todo_list: + r = [] + r = property_obj.search(cr, uid, [('name','=', record[0] ),('company_id','=',company_id.id)]) + account = getattr(obj_multi, record[0]) + field = fields_obj.search(cr, uid, [('name','=',record[0]),('model','=',record[1]),('relation','=',record[2])]) + vals = { + 'name': record[0], + 'company_id': company_id.id, + 'fields_id': field[0], + 'value': account and 'account.account,'+str(acc_template_ref[account.id]) or False, + } + if r: + #the property exist: modify it + property_obj.write(cr, uid, r, vals) + else: + #create the property + property_obj.create(cr, uid, vals) + + fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.id)]) + + if fp_ids: + for position in obj_fiscal_position_template.browse(cr, uid, fp_ids): + + vals_fp = { + 'company_id' : company_id.id, + 'name' : position.name, + } + new_fp = obj_fiscal_position.create(cr, uid, vals_fp) + + obj_tax_fp = self.pool.get('account.fiscal.position.tax') + obj_ac_fp = self.pool.get('account.fiscal.position.account') + + for tax in position.tax_ids: + vals_tax = { + 'tax_src_id' : tax_template_ref[tax.tax_src_id.id], + 'tax_dest_id' : tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False, + 'position_id' : new_fp, + } + obj_tax_fp.create(cr, uid, vals_tax) + + for acc in position.account_ids: + vals_acc = { + 'account_src_id' : acc_template_ref[acc.account_src_id.id], + 'account_dest_id' : acc_template_ref[acc.account_dest_id.id], + 'position_id' : new_fp, + } + obj_ac_fp.create(cr, uid, vals_acc) + def execute(self, cr, uid, ids, context=None): super(account_installer, self).execute(cr, uid, ids, context=context) record = self.browse(cr, uid, ids, context=context)[0] for res in self.read(cr,uid,ids): - if record.charts == 'l10n_chart_configurable': - obj_acc = self.pool.get('account.account') + if record.charts == 'configurable': + fp = tools.file_open(opj('account','configurable_account_chart.xml')) + tools.convert_xml_import(cr, 'account', fp, {}, 'init',True, None) + fp.close() + self.generate_configurable_chart(cr, uid, ids, context=context) obj_tax = self.pool.get('account.tax') - user_type = self.pool.get('account.account.type') obj_product = self.pool.get('product.product') ir_values = self.pool.get('ir.values') - u_type_id = user_type.search(cr, uid,[('name','ilike','view')])[0] - company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id - vals = {'name': company.name or '', - 'currency_id': company.currency_id.id or False, - 'code': 0 or '', - 'type': 'view', - 'user_type': u_type_id, - 'company_id': company.id } - main_account = obj_acc.create(cr, uid, vals) - for val in record.bank_accounts_id: - vals = {'name': val.acc_name or '', - 'currency_id': val.currency_id.id or False, - 'code': val.acc_name or '', - 'type': 'view', - 'user_type': u_type_id, - 'parent_id':main_account, - 'company_id': company.id } - obj_acc.create(cr, uid, vals) - - sales_tax = obj_tax.create(cr, uid,{'name':'sale Tax','amount':res.get('sale_tax',0.0)}) - purchase_tax = obj_tax.create(cr, uid,{'name':'purchase Tax','amount':res.get('purchase_tax',0.0)}) + s_tax = (res.get('sale_tax',0.0))/100 + p_tax = (res.get('purchase_tax',0.0))/100 + sales_tax = obj_tax.create(cr, uid, + {'name':'(%s)'%(s_tax*100), + 'amount':s_tax + }) + purchase_tax = obj_tax.create(cr, uid, + {'name':'(%s)'%(p_tax*100), + 'amount':p_tax + }) product_ids = obj_product.search(cr,uid, []) for product in obj_product.browse(cr, uid, product_ids): obj_product.write(cr, uid, product.id, {'taxes_id':[(6,0,[sales_tax])],'supplier_taxes_id':[(6,0,[purchase_tax])]}) diff --git a/addons/base_setup/__init__.py b/addons/base_setup/__init__.py index cda3e40111ba..3b78c6cb557a 100644 --- a/addons/base_setup/__init__.py +++ b/addons/base_setup/__init__.py @@ -23,7 +23,10 @@ import installer import todo import gtk_contact_form import wizard - +import os +import base64 +import random +import tools from osv import fields, osv import netsvc from tools.translate import _ @@ -34,6 +37,12 @@ class base_setup_config_choice(osv.osv_memory): _name = 'base.setup.config' logger = netsvc.Logger() + def _get_image(self, cr, uid, context=None): + file_no = str(random.randint(1,3)) + path = os.path.join('base','res','config_pixmaps/%s.png'%file_no) + file_data = tools.file_open(path,'rb').read() + return base64.encodestring(file_data) + def get_users(self, cr, uid, context={}): user_obj = self.pool.get('res.users') user_ids = user_obj.search(cr, uid, []) @@ -42,11 +51,13 @@ class base_setup_config_choice(osv.osv_memory): return _('The following users have been installed on your database: \n')+ user_str _columns = { - 'installed_users':fields.text('Installed Users', readonly=True) + 'installed_users':fields.text('Installed Users', readonly=True), + 'config_logo' : fields.binary('Image', readonly=True), } _defaults = { - 'installed_users':get_users + 'installed_users':get_users, + 'config_logo' : _get_image } def set_default_menu(self, cr, uid, menu, context=None): diff --git a/addons/base_setup/base_setup_data.xml b/addons/base_setup/base_setup_data.xml index e06facce0e8f..90d48de5ebad 100644 --- a/addons/base_setup/base_setup_data.xml +++ b/addons/base_setup/base_setup_data.xml @@ -7,11 +7,11 @@ <field name="type">form</field> <field name="arch" type="xml"> <form string="Setup"> - <group colspan="4" col="8"> - <group width="150"> - <image name="gtk-dialog-info"/> - </group> - <group> + <group colspan="4" col="8" width="600"> + <group> + <field name="config_logo" widget="image" width="150" height="100" nolabel="1" colspan="1"/> + </group> + <group colspan="6"> <separator string="Installation Done" colspan="8"/> <label align="0.0" string="Your new database is now fully installed." colspan="8"/> <field name="installed_users" nolabel= "1" colspan="8"/> diff --git a/addons/base_setup/base_setup_installer.xml b/addons/base_setup/base_setup_installer.xml index ba6b21d12680..2b4a870236a2 100644 --- a/addons/base_setup/base_setup_installer.xml +++ b/addons/base_setup/base_setup_installer.xml @@ -19,9 +19,7 @@ If you don't think you need any of these right now, you can easily install them </xpath> <xpath expr='//separator[@string="vsep"]' position='attributes'> <attribute name='string'></attribute> - </xpath> - <xpath expr='//group[@string="progress"]' position='attributes'> - <attribute name='string'></attribute> + <attribute name='rowspan'>15</attribute> </xpath> <separator string="title" position="attributes"> <attribute name="string">Install Generic Modules</attribute> diff --git a/addons/base_setup/gtk_contact_form.py b/addons/base_setup/gtk_contact_form.py index 6c576adf971d..b1d01cecb668 100644 --- a/addons/base_setup/gtk_contact_form.py +++ b/addons/base_setup/gtk_contact_form.py @@ -38,8 +38,10 @@ class base_gtkcontactform(osv.osv_memory): defaults = super(base_gtkcontactform, self)\ .default_get(cr, uid, fields_list=fields_list, context=context) company_id = self.pool.get('base.setup.company').search(cr, uid, []) - company = self.pool.get('base.setup.company').read(cr, uid, company_id)[0] - defaults.update({'email':company.get('email',''), + company = self.pool.get('base.setup.company').read(cr, uid, company_id) + company = company and company[0] or False + if company: + defaults.update({'email':company.get('email',''), 'phone': company.get('phone','')}) return defaults @@ -73,9 +75,9 @@ class base_gtkcontactform(osv.osv_memory): def execute(self, cr, uid, ids, context=None): company_id = self.pool.get('base.setup.company').search(cr, uid, []) company_data = self.pool.get('base.setup.company').read(cr, uid, company_id) - company_data = company_data and company_data[0] + company_data = company_data and company_data[0] or False country1 = '' - if company_data.get('country_id', False): + if company_data and company_data.get('country_id', False): country = self.pool.get('res.country').read(cr, uid, company_data['country_id'],['name'])['name'] for res in self.read(cr, uid, ids): email = res.get('email','') diff --git a/addons/hr/hr_installer.xml b/addons/hr/hr_installer.xml index a19476e1f195..b01f538b1937 100644 --- a/addons/hr/hr_installer.xml +++ b/addons/hr/hr_installer.xml @@ -15,7 +15,6 @@ <attribute name="string">Select Human Resources Modules To Install</attribute> </separator> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>8</attribute> <attribute name='string'></attribute> </xpath> <xpath expr="//label[@string='description']" diff --git a/addons/knowledge/knowledge_installer.xml b/addons/knowledge/knowledge_installer.xml index 30ac565addbb..e1da251fb9a4 100644 --- a/addons/knowledge/knowledge_installer.xml +++ b/addons/knowledge/knowledge_installer.xml @@ -16,14 +16,14 @@ >Knowledge Management</attribute> </separator> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>9</attribute> <attribute name='string'></attribute> </xpath> <xpath expr="//label[@string='description']" position="attributes"> <attribute name="string">From this screen, you can select various OpenERP applications which will help employees store information, distribute it and share it with one another.</attribute> </xpath> - <group colspan="8"> + <group colspan="8" position="replace"> + <group colspan="4"> <field name="document_ftp"/> <field name="document_webdav"/> <field name="wiki"/> @@ -31,6 +31,7 @@ <field name="wiki_faq"/> <field name="wiki_quality_manual"/> </group> + </group> <xpath expr="//button[@string='Install Modules']" position="attributes"> <attribute name="string">Configure</attribute> </xpath> diff --git a/addons/mrp/mrp_installer.xml b/addons/mrp/mrp_installer.xml index d40eb4535707..fe4fb6b83483 100644 --- a/addons/mrp/mrp_installer.xml +++ b/addons/mrp/mrp_installer.xml @@ -19,7 +19,6 @@ <attribute name="string">After having installed the core manufacturing application, you can extend it with a few more depending on the needs of your organization</attribute> </xpath> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>8</attribute> <attribute name='string'></attribute> </xpath> <group colspan="8"> diff --git a/addons/profile_accounting/profile_accounting.xml b/addons/profile_accounting/profile_accounting.xml index d54aaaf1e5b4..f9b143e10f4e 100644 --- a/addons/profile_accounting/profile_accounting.xml +++ b/addons/profile_accounting/profile_accounting.xml @@ -11,6 +11,9 @@ <form position="attributes"> <attribute name="string">Install Extra Modules</attribute> </form> + <xpath expr='//separator[@string="vsep"]' position='attributes'> + <attribute name='string'></attribute> + </xpath> <xpath expr="//label[@string='description']" position="attributes"> <attribute name="string" diff --git a/addons/profile_tools/misc_tools_installer.xml b/addons/profile_tools/misc_tools_installer.xml index 277ec90b81c7..efef1dc3649d 100644 --- a/addons/profile_tools/misc_tools_installer.xml +++ b/addons/profile_tools/misc_tools_installer.xml @@ -11,7 +11,6 @@ <attribute name="string">Tools Modules Installation</attribute> </form> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>10</attribute> <attribute name='string'></attribute> </xpath> diff --git a/addons/project/project_installer.xml b/addons/project/project_installer.xml index cbdd18ae29f4..a127333544f6 100644 --- a/addons/project/project_installer.xml +++ b/addons/project/project_installer.xml @@ -16,7 +16,6 @@ >Project Management</attribute> </separator> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>10</attribute> <attribute name='string'></attribute> </xpath> <xpath expr="//label[@string='description']" diff --git a/addons/purchase/wizard/purchase_installer.xml b/addons/purchase/wizard/purchase_installer.xml index 0916977e62a0..b105b6ba3aaf 100644 --- a/addons/purchase/wizard/purchase_installer.xml +++ b/addons/purchase/wizard/purchase_installer.xml @@ -12,7 +12,6 @@ <attribute name="string">Purchase Modules Installation</attribute> </form> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>6</attribute> <attribute name='string'></attribute> </xpath> <separator string="title" position="attributes"> diff --git a/addons/report_designer/report_designer_installer.xml b/addons/report_designer/report_designer_installer.xml index 89d655de0b2a..bcd0250fb7e5 100644 --- a/addons/report_designer/report_designer_installer.xml +++ b/addons/report_designer/report_designer_installer.xml @@ -11,7 +11,6 @@ <attribute name="string">Report Modules Installation</attribute> </form> <xpath expr='//separator[@string="vsep"]' position='attributes'> - <attribute name='rowspan'>7</attribute> <attribute name='string'></attribute> </xpath> <separator string="title" position="attributes"> diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 3db8c67281b0..5bf5967d58b9 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -508,7 +508,6 @@ </separator> <xpath expr="//label[@string='description']" position="attributes"> <attribute name="string">Setup your sales workflow and default values.</attribute> - <attribute name="width">100</attribute> </xpath> <xpath expr='//separator[@string="vsep"]' position='attributes'> <attribute name='rowspan'>6</attribute> diff --git a/addons/thunderbird/thunderbird_installer.xml b/addons/thunderbird/thunderbird_installer.xml index 59e0cc4f6043..356282d2de52 100644 --- a/addons/thunderbird/thunderbird_installer.xml +++ b/addons/thunderbird/thunderbird_installer.xml @@ -12,13 +12,17 @@ <attribute name="string">Thunderbird Module Installation</attribute> </form> <separator string="title" position="attributes"> - <attribute name="string">Configure Thunderbird Module</attribute> + <attribute name="string">Thunderbird</attribute> </separator> <xpath expr="//label[@string='description']" position="attributes"> <attribute name="string">This module is required for the thuderbird plug-in to work properly.This allows you to select an object that you had like to add to your email and its attachments. You can select a partner, a task, a project, an analytical account, or any other object and attach selected mail as .eml file in attachment of selected record.</attribute> </xpath> - <group colspan="8"> - <separator string="Thunderbird" colspan="4"/> + <xpath expr='//separator[@string="vsep"]' position='attributes'> + <attribute name='string'></attribute> + <attribute name='rowspan'>15</attribute> + </xpath> + <group colspan="8" position="replace"> + <group colspan="8" height="400" width="700"> <field name="thunderbird"/> <field name="name" invisible="1"/> <field name="pdf_name" invisible="1"/> @@ -33,6 +37,7 @@ <separator string="Thunderbird plugin installation note." colspan="4"/> <label colspan="8" string="Save The thunderbird plugÂin Follow the following step to install thunderbird plugÂin ? 1. From Menu Bar, Open Tools Â> Add ons. 2. Now click on install button and a browser window will appear. 3. Just select the (.xpi) file from thunderbird/plugin directory and click ok, a new software installation window will appear and within a short time Install Now button will be enabled. 4. Click on Install Now and restart Thunderbird. 5. Now Thunderbird plugÂin is installed."/> </group> + </group> </data> </field> </record> -- GitLab