1
votes

I have problems with a new tree view created in the account.move.line object in OpenERP 6.1.

In a new module (account_summary) I have the following files:

account_summary.py

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()

account_summary.xml

<?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>

I install the module correctly but when I click on the new menu created, it triggers the default tree view of the account.move.line object instead of the new tree view created with only the new field created.

Any help comment?

Thank you

1

1 Answers

0
votes

I answer my own question:

The problem is solved adding in the action the next field:

<field name="context">{'view_mode': True}</field>