Browse Source

[IMP] Se agrega on_changes al modelo afr

6.0
Humberto Arocha 12 years ago
parent
commit
21171e8286
  1. 27
      account_financial_report/model/account_financial_report.py
  2. 15
      account_financial_report/view/account_financial_report_view.xml
  3. 2
      account_financial_report/wizard/wizard.py

27
account_financial_report/model/account_financial_report.py

@ -79,4 +79,31 @@ class account_financial_report(osv.osv):
defaults['name'] = new_name defaults['name'] = new_name
return super(account_financial_report,self).copy(cr, uid, id, defaults, context=context) return super(account_financial_report,self).copy(cr, uid, id, defaults, context=context)
def onchange_columns(self,cr,uid,ids,columns,fiscalyear_id,period_ids,context=None):
if context is None:
context = {}
res = {'value':{}}
if columns in ('qtr', 'thirteen'):
p_obj = self.pool.get("account.period")
period_ids = p_obj.search(cr,uid,[('fiscalyear_id','=',fiscalyear_id),('special','=',False)],context=context)
res['value'].update({'period_ids':period_ids})
else:
res['value'].update({'period_ids':[]})
return res
def onchange_company_id(self,cr,uid,ids,company_id,context=None):
if context is None:
context = {}
context['company_id']=company_id
res = {'value':{}}
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context)
res['value'].update({'fiscalyear_id':fy_id})
res['value'].update({'currency_id':cur_id})
res['value'].update({'account_ids':[]})
res['value'].update({'period_ids':[]})
return res
account_financial_report() account_financial_report()

15
account_financial_report/view/account_financial_report_view.xml

@ -7,20 +7,20 @@
<field name="model">afr</field> <field name="model">afr</field>
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Account Financial Report">
<form string="Account Financial Report (Templates)">
<group colspan="4"> <group colspan="4">
<field name="name" colspan="4"/> <field name="name" colspan="4"/>
</group> </group>
<group colspan="4"> <group colspan="4">
<group colspan="2"> <group colspan="2">
<separator string="Company Info" colspan="4"/> <separator string="Company Info" colspan="4"/>
<field name="company_id" colspan="4"/>
<field name="company_id" on_change='onchange_company_id(company_id)' colspan="4"/>
<field name="currency_id" domain="[('company_id','=',company_id)]" colspan="4"/> <field name="currency_id" domain="[('company_id','=',company_id)]" colspan="4"/>
</group> </group>
<group colspan="2"> <group colspan="2">
<separator string="Report Info" colspan="4"/> <separator string="Report Info" colspan="4"/>
<field name="inf_type" colspan="4"/> <field name="inf_type" colspan="4"/>
<field name="columns" colspan="4"/>
<field name="columns" on_change='onchange_columns(columns,fiscalyear_id,period_ids)' colspan="4"/>
</group> </group>
</group> </group>
<group colspan='2'> <group colspan='2'>
@ -31,7 +31,7 @@
</group> </group>
<group colspan="2"> <group colspan="2">
<separator string="FiscalYear Info" colspan="4"/> <separator string="FiscalYear Info" colspan="4"/>
<field name="fiscalyear_id" domain="[('company_id','=',company_id)]"/>
<field name="fiscalyear_id" on_change='onchange_columns(columns,fiscalyear_id,period_ids)' domain="[('company_id','=',company_id)]"/>
<newline/> <newline/>
</group> </group>
</group> </group>
@ -43,12 +43,17 @@
<field name='code'/> <field name='code'/>
<field name='name'/> <field name='name'/>
<field name='type'/> <field name='type'/>
<field name='level'/>
</tree> </tree>
</field> </field>
</group> </group>
<group colspan="1"> <group colspan="1">
<separator string="Periods to Include" colspan="4"/> <separator string="Periods to Include" colspan="4"/>
<field name="period_ids" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear_id),('special','=',False),('company_id','=',company_id)]">
<field name="period_ids"
colspan="4" nolabel="1"
domain="[('fiscalyear_id','=',fiscalyear_id),('special','=',False),('company_id','=',company_id)]"
attrs="{'readonly':[('columns','in',('qtr','thirteen'))],}"
>
<tree> <tree>
<field name='code'/> <field name='code'/>

2
account_financial_report/wizard/wizard.py

@ -109,6 +109,8 @@ class wizard_report(osv.osv_memory):
res['value'].update({'fiscalyear':afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id}) res['value'].update({'fiscalyear':afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id})
res['value'].update({'account_list':[acc.id for acc in afr_brw.account_ids]}) res['value'].update({'account_list':[acc.id for acc in afr_brw.account_ids]})
res['value'].update({'periods':[p.id for p in afr_brw.period_ids]}) res['value'].update({'periods':[p.id for p in afr_brw.period_ids]})
res['value'].update({'tot_check':afr_brw.tot_check or False})
res['value'].update({'lab_str':afr_brw.lab_str or _('Write a Description for your Summary Total')})
return res return res
def _get_defaults(self, cr, uid, data, context=None): def _get_defaults(self, cr, uid, data, context=None):

Loading…
Cancel
Save