我需要加载工人津贴和扣除额。
两种固定和可变津贴。
扣除额还有3种类型:固定、可变和特殊。
那么我的班级就有这样的关系
津贴1 2个固定
允许12个变量
扣除1个2个固定
减去一个2个变量
扣除一项2多项特殊费用
我的最后一次扣减的是两个
后来我写了一个方法_工人。但是它不起作用&希望您能帮助我解决这个问题
谢谢
(最初我为固定津贴编写代码)
函数在我的课堂上
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}
视图.xml
^{pr2}$仍然没有任何迹象请记录帮我整理一下
已编辑
需要像这样返回mu结果吗。?在
dict: {'fixed_allowance_ids': [{'allowance_ids': [{'allowance_id': 1, 'allowance_name': 1}]}]}
已编辑
完成以下代码
模型类
def on_change_worker(self、cr、uid、ids、worker_id): 修正了v={} 修正了列表v={} 固定列表=[] 固定的_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}
在视图.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>
现在结果是这样的,但仍然需要在树视图上获取值
如果有任何建议,以获得准确的价值,请张贴在这里
你需要这样回来:
它应该对你有用。在
相关问题 更多 >
编程相关推荐