0
我需要加載工人津貼&扣除。
配額固定2種類型&變量。
扣除也固定3種類型,變數&特殊。
OpenERP one2many和one2many
然後我班有這樣
津貼one2many關係固定
津貼one2many變量
扣除one2many固定
扣one2many變量
扣one2many特殊
我最後需求量的是加載這些扣減和津貼在兩個''標籤 然後我寫了一個onchange_worker.but方法但它的否牛逼工作&希望你能幫助我sortout這個問題
謝謝
(固定津貼最初我寫的代碼)
功能在我的課
def on_change_worker(self, cr, uid, ids, worker_id):
fixed_v = {}
fixed_list_v = {}
fixed_list = []
fixed_list_data = []
if worker_id:
ind_allowance_id = self.pool.get('bpl.allowance.individual.data').search(cr, uid, [('worker_id', '=', worker_id)])
ind_allowance_obj = self.pool.get('bpl.allowance.individual.data').browse(cr, uid, ind_allowance_id)[0]
for allowance_record in ind_allowance_obj.fixed_allowance_ids:
fixed_list.append({'allowance_id':allowance_record.allowance_id.id, 'allowance_name': allowance_record.allowance_name.id })
fixed_v['allowance_ids'] = fixed_list
fixed_list_data.append(fixed_v)
fixed_list_v['fixed_allowance_ids'] = fixed_list_data
return {'value':fixed_list_v}
view.xml用
<form string='bpl_worker_summary' version='7.0'>
<sheet>
<group>
<group>
<field name='bpl_company_id' readonly="1" />
<field name='bpl_estate_id' />
<field name='worker_id' on_change="on_change_worker(worker_id)" />
</group>
</group>
<div name="Allowances"></div>
<separator string="Allowances" />
<notebook>
<page string="Allowances">
<field name='allowance_ids' nolabel='1'>
<tree string='List' editable='bottom'>
<field name='fixed_allowance_ids' nolabel='1'>
<tree string="fixed_allowance">
<field name='allowance_id' />
<field name='allowance_name' />
<field name='amount' />
</tree>
</field>
</tree>
</field>
</page>
<page string="Deductions">
<field name='deduction_ids' nolabel='1'>
</field>
</page>
</notebook>
</sheet>
</form>
還沒有顯示任何記錄。請大家幫我解決這
EDITED
需要返回畝導致這樣? fixed_v = {} fixed_list_v =:
dict: {'fixed_allowance_ids': [{'allowance_ids': [{'allowance_id': 1, 'allowance_name': 1}]}]}
編輯
與下面碼
模型類
DEF on_change_worker(個體,CR,UID,IDS,worker_id)來完成{} fixed_list = [] fixed_list_data = []
if worker_id:
ind_allowance_id = self.pool.get('bpl.allowance.individual.data').search(cr, uid, [('worker_id', '=', worker_id)])
ind_allowance_obj = self.pool.get('bpl.allowance.individual.data').browse(cr, uid, ind_allowance_id)[0]
for allowance_record in ind_allowance_obj.fixed_allowance_ids:
fixed_list.append({'allowance_id':allowance_record.allowance_id.id, 'allowance_name': allowance_record.allowance_name.id })
fixed_v['fixed_allowance_ids'] = fixed_list
fixed_list_data.append(fixed_v)
fixed_list_v['allowance_ids'] = fixed_list_data
return {'value':fixed_list_v}
view.xml用
<page string="Allowances">
<field name='allowance_ids' nolabel='1'>
<field name='fixed_allowance_ids' nolabel='1'>
<tree string="fixed_allowance">
<field name='allowance_id' />
<field name='allowance_name' />
<field name='amount' />
</tree>
</field>
</field>
</page>
現在導致就這樣產生了,但仍需要得到樹視圖
值,如果任何建議得到確切值,請張貼在這裏
帖子編輯 請檢查並建議 – 2013-04-30 11:58:57