[MERGE]: Merged with main project branch

bzr revid: rpa@tinyerp.com-20110802063849-xu8x3nz4dqrtf2i0
This commit is contained in:
Rucha (Open ERP)
2011-08-02 12:08:49 +05:30
4 changed files with 103 additions and 15 deletions
+27 -13
View File
@@ -2476,6 +2476,8 @@ class account_chart_template(osv.osv):
_columns={
'name': fields.char('Name', size=64, required=True),
'parent_id': fields.many2one('account.chart.template', 'Parent Chart Template'),
'visible': fields.boolean('Can be Visible?', help="Set this to False if you don't want this template to be used actively in the wizard that generate Chart of Accounts from templates, this is useful when you want to generate accounts of this template only when loading its child template."),
'set_tax_complete': fields.boolean('Complete Set Of Tax', help="Set this False, then instead of the 2 many2one for default sale and purchase taxes, we display the default sale and purchase rates float field in the wizard that generate Chart of Accounts from templates"),
'account_root_id': fields.many2one('account.account.template', 'Root Account', domain=[('parent_id','=',False)]),
'tax_code_root_id': fields.many2one('account.tax.code.template', 'Root Tax Code', domain=[('parent_id','=',False)]),
'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'),
@@ -2634,21 +2636,24 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."),
"sale_tax": fields.many2one("account.tax.template", "Default Sale Tax"),
"purchase_tax": fields.many2one("account.tax.template", "Default Purchase Tax"),
'sale_tax_rate': fields.float('Sale Tax(%)'),
'purchase_tax_rate': fields.float('Purchase Tax(%)'),
'complete_tax': fields.boolean('Complete Tax'),
}
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None):
res = {}
res['value'] = {}
res['value']["sale_tax"] = False
res['value']["purchase_tax"] = False
tax_templ_obj = self.pool.get('account.tax.template')
res['value'] = {'complete_tax': False, 'sale_tax': False, 'purchase_tax': False}
if chart_template_id:
complete_tax = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context).set_tax_complete
if complete_tax:
# default tax is given by the lowesst sequence. For same sequence we will take the latest created as it will be the case for tax created while isntalling the generic chart of account
sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id"
, "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence, id desc")
purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id"
, "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence, id desc")
res['value']["sale_tax"] = sale_tax_ids and sale_tax_ids[0] or False
res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False
sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id"
, "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence, id desc")
purchase_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id"
, "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence, id desc")
res['value'].update({'sale_tax': sale_tax_ids and sale_tax_ids[0] or False, 'purchase_tax': purchase_tax_ids and purchase_tax_ids[0] or False})
res['value'].update({'complete_tax': complete_tax})
return res
@@ -2667,7 +2672,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
if 'seq_journal' in fields:
res.update({'seq_journal': True})
ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context)
ids = self.pool.get('account.chart.template').search(cr, uid, [('visible', '=', True)], context=context)
if ids:
if 'chart_template_id' in fields:
res.update({'chart_template_id': ids[0]})
@@ -2685,7 +2690,11 @@ class wizard_multi_charts_accounts(osv.osv_memory):
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(wizard_multi_charts_accounts, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
cmp_select = []
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context)
acc_template_obj = self.pool.get('account.chart.template')
company_obj = self.pool.get('res.company')
template_ids = acc_template_obj.search(cr, uid, [('visible', '=', True)], context=context)
company_ids = company_obj.search(cr, uid, [], context=context)
#display in the widget selection of companies, only the companies that haven't been configured yet (but don't care about the demo chart of accounts)
cr.execute("SELECT company_id FROM account_account WHERE active = 't' AND account_account.parent_id IS NULL AND name != %s", ("Chart For Automated Tests",))
configured_cmp = [r[0] for r in cr.fetchall()]
@@ -2695,8 +2704,13 @@ class wizard_multi_charts_accounts(osv.osv_memory):
res['fields'][field]['domain'] = unconfigured_cmp
res['fields'][field]['selection'] = [('', '')]
if unconfigured_cmp:
cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)]
cmp_select = [(line.id, line.name) for line in company_obj.browse(cr, uid, unconfigured_cmp)]
res['fields'][field]['selection'] = cmp_select
if field == 'chart_template_id':
res['fields'][field]['selection'] = [('', '')]
if template_ids:
template_select = [(template.id, template.name) for template in acc_template_obj.browse(cr, uid, template_ids)]
res['fields'][field]['selection'] = template_select
return res
def execute(self, cr, uid, ids, context=None):
+7 -2
View File
@@ -2145,6 +2145,8 @@
<field name="bank_account_view_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="tax_code_root_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="parent_id" />
<field name="visible" />
<field name="set_tax_complete" />
</group>
<field name="tax_template_ids" colspan="4" readonly="1" nolabel="1"/>
<separator string="Properties" colspan="4"/>
@@ -2398,8 +2400,11 @@
<field name ="code_digits" groups="base.group_extended"/>
<field name="chart_template_id" widget="selection" on_change="onchange_chart_template_id(chart_template_id)"/>
<field name ="seq_journal" groups="base.group_extended"/>
<field name="sale_tax" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('sale','all'))]"/>
<field name="purchase_tax" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('purchase', 'all'))]"/>
<field name="sale_tax" attrs="{'invisible': [('complete_tax', '!=', True)]}" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('sale','all'))]"/>
<field name="purchase_tax" attrs="{'invisible': [('complete_tax', '!=', True)]}" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('purchase', 'all'))]"/>
<field name ="sale_tax_rate" attrs="{'invisible': [('complete_tax', '=', True)]}"/>
<field name ="purchase_tax_rate" attrs="{'invisible': [('complete_tax', '=', True)]}"/>
<field name ="complete_tax" invisible="1"/>
<newline/> <!-- extended view because the web UI is not good for one2many -->
<field colspan="4" mode="tree" name="bank_accounts_id" nolabel="1" widget="one2many_list" groups="base.group_extended">
<form string="Bank Information">
+24
View File
@@ -96,11 +96,20 @@ class wizard_multi_charts_accounts(osv.osv_memory):
obj_mod = self.pool.get('ir.module.module')
obj_acc_template = self.pool.get('account.account.template')
obj_acc = self.pool.get('account.account')
obj_tax_code_template = self.pool.get('account.tax.code.template')
obj_tax_code = self.pool.get('account.tax.code')
obj_tax_template = self.pool.get('account.tax.template')
obj_tax = self.pool.get('account.tax')
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
obj_fiscal_position = self.pool.get('account.fiscal.position')
resource_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'l10n_multilang', 'view_translate_message_wizard')
company_id = obj_multi.company_id.id
acc_template_root_id = obj_multi.chart_template_id.account_root_id.id
acc_root_id = obj_acc.search(cr, uid, [('company_id', '=', company_id), ('parent_id', '=', None)])[0]
tax_code_template_root_id = obj_multi.chart_template_id.tax_code_root_id.id
tax_code_root_id = obj_tax_code.search(cr, uid, [('company_id', '=', company_id), ('parent_id', '=', None)])[0]
# load languages
langs = []
@@ -116,6 +125,21 @@ class wizard_multi_charts_accounts(osv.osv_memory):
out_ids = obj_acc.search(cr, uid, [('id', 'child_of', [acc_root_id])], order='id')[1:]
warn_msg += self.copy_translations(cr, uid, langs, obj_acc_template, 'name', in_ids, obj_acc, out_ids)
# copy account.tax.code translations
in_ids = obj_tax_code_template.search(cr, uid, [('id', 'child_of', [tax_code_template_root_id])], order='id')[1:]
out_ids = obj_tax_code.search(cr, uid, [('id', 'child_of', [tax_code_root_id])], order='id')[1:]
warn_msg += self.copy_translations(cr, uid, langs, obj_tax_code_template, 'name', in_ids, obj_tax_code, out_ids)
# copy account.tax translations
in_ids = sorted([x.id for x in obj_multi.chart_template_id.tax_template_ids])
out_ids = obj_tax.search(cr, uid, [('company_id', '=', company_id)], order='id')
warn_msg += self.copy_translations(cr, uid, langs, obj_tax_template, 'name', in_ids, obj_tax, out_ids)
# copy account.fiscal.position translations
in_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)], order='id')
out_ids = obj_fiscal_position.search(cr, uid, [('company_id', '=', company_id)], order='id')
warn_msg += self.copy_translations(cr, uid, langs, obj_fiscal_position_template, 'name', in_ids, obj_fiscal_position, out_ids)
#open new wizard its for displaying warning message
if warn_msg:
res_id = self.pool.get('translate.message').create(cr, uid, {'message': warn_msg})
@@ -148,6 +148,51 @@
<field name="parent_id" ref="account_chart_template_a"/>
</record>
<!-- Tax for template A-->
<record id="attn_VAT-OUT-21-S" model="account.tax.template">
<field name="sequence">10</field>
<field name="description">VAT-OUT-21-S</field>
<field name="name">VAT 21%</field>
<field name="amount">0.21</field>
<field name="type">percent</field>
<field name="chart_template_id" ref="account_chart_template_a"/>
</record>
<!-- Tax for template B-->
<record id="attn_VAT-OUT-4-S" model="account.tax.template">
<field name="sequence">12</field>
<field name="description">VAT-OUT-4-S</field>
<field name="name">VAT 4%</field>
<field name="amount">0.4</field>
<field name="type">percent</field>
<field name="chart_template_id" ref="account_chart_template_b"/>
</record>
<record id="attn_VAT-OUT-12-S" model="account.tax.template">
<field name="sequence">12</field>
<field name="description">VAT-OUT-12-S</field>
<field name="name">VAT 12%</field>
<field name="amount">0.12</field>
<field name="type">percent</field>
<field name="chart_template_id" ref="account_chart_template_b"/>
</record>
<!-- account.fiscal.position.template -->
<record id="afptn_national" model="account.fiscal.position.template">
<field name="name">National Regime</field>
<field name="chart_template_id" ref="account_chart_template_a"/>
</record>
<record id="afptn_intracom" model="account.fiscal.position.template">
<field name="name">Intra Community Regime </field>
<field name="chart_template_id" ref="account_chart_template_a"/>
</record>
<record id="afptn_extracom" model="account.fiscal.position.template">
<field name="name">Extra Community Regime</field>
<field name="chart_template_id" ref="account_chart_template_b"/>
</record>
</data>
</openerp>