我在OpenERP 6.1中的account.move.line对象中创建了一个新的树视图时出现问题。
在新模块(account_summary)中,我有以下文件:
from osv import fields,osv
class account_summary(osv.osv):
_inherit = "account.move.line"
_name = "account.move.line"
def _get_balance_inv(self, cr, uid, ids, field_name, arg, context=None):
if context is None:
context = {}
lines_obj = self.browse(cr,uid,ids,context=context)
result={}
for line in lines_obj:
result[line.id]= line.balance*(-1)
return result
_columns = {
'balance_inv':fields.function(_get_balance_inv, string="balance inverso"),
}
account_summary()
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_summary_tree" model="ir.ui.view">
<field name="name">account.summary.tree</field>
<field name="model">account.move.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Vista de resumen de cuentas">
<field name="balance_inv"/>
</tree>
</field>
</record>
<record id="action_view_account_summary_tree" model="ir.actions.act_window">
<field name="name">Abrir resumen de cuentas</field>
<field name="res_model">account.move.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_account_summary_tree"/>
</record>
<menuitem id="menu_account_summary1" name="Resumen de cuentas" sequence="4" parent="account.menu_finance_reporting"/>
<menuitem action="action_view_account_summary_tree" icon="terp-graph" id="menu_account_summary2" parent="menu_account_summary1" sequence="1"/>
</data>
</openerp>
我正确安装模块但是当我点击创建的新菜单时,它会触发account.move.line对象的默认树视图,而不是仅使用新字段创建的新树视图。
任何帮助评论?
谢谢
答案 0 :(得分:0)
我回答我自己的问题:
问题解决了在下一个字段中添加操作:
<field name="context">{'view_mode': True}</field>