我需要在分析帐户的“费用和收入”行中显示每种货币,我需要为每张发票所具有的不同货币动态添加列,并在下面显示总计(模仿“金额”列的行为已经存在),有没有办法做到这一点或解决方法得到类似的结果?
分析科目行已经以原始货币存储了金额,并将转换后的货币转换为公司货币。
我想通过为每种货币手工添加一个字段来避免发疯。
这里是一个例子。
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(MailThread, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
if view_type == 'form':
doc = etree.XML(res['arch'])
for node in doc.xpath("//field[@name='message_ids']"):
# the 'Log a note' button is employee only
options = safe_eval(node.get('options', '{}'))
is_employee = self.env.user.has_group('base.group_user')
options['display_log_button'] = is_employee
# save options on the node
node.set('options', repr(options))
res['arch'] = etree.tostring(doc, encoding='unicode')
return res
将其放入模型中。用doc.xpath
查找列字段,并用node.set
实际上是胡安·萨尔塞多在评论中说的话