我需要负担工人的津贴和扣减。
津贴2类型固定和可变。
扣减也有3种类型固定,可变和特殊。
那么我的课就像这样的关系
one2many固定余量
余量one2many变量
演绎one2many固定
演绎one2many变量
演绎one2many专门性
我的最后一个要求是在两个'‘标签中加载这些扣减和免税额,然后我为onchange_worker.but编写了一个方法,它不起作用&希望您能帮助我解决这个问题
谢谢
(最初我为固定津贴编写了代码)
函数在我的类中
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>仍然没有显示任何records.please帮助我对此进行排序
编辑的
需要像这样回报穆结果。?
dict: {'fixed_allowance_ids': [{'allowance_ids': [{'allowance_id': 1, 'allowance_name': 1}]}]}编辑的
按以下代码完成
模型类
def on_change_worker(self,cr,uid,uid,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['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:50:20
你得像这样回来:
dict: {'fixed_allowance_ids': [{'allowance_id': 1, 'allowance_name': 1}, {'allowance_id': 2, 'allowance_name': 2}]}它应该对你有用。
https://stackoverflow.com/questions/16297230
复制相似问题