Odoo Help

0

How to implement indicator icon in tree and form view?

By
Antanas
on 9/12/13, 9:08 AM 1,297 views

Hello,

What I want to achieve is having an indicator icon in tree view, red or green depending on value of another field of same record. Something similar can be seen in account.bank.statement lines, on the right. An icon is red or green, depending on some kind of conditions apparently. Interestingly, that field in lines uses widget="many2onebutton", which is used only once in all OpenERP source code.

My options are using the above mentioned example, which I don't understand, or finding some other solution. Please explain how do indicators of bank statement lines work, or give me a direction how to implement this other way.

<!-- Account Voucher module -->
<record id="view_bank_statement_form_voucher" model="ir.ui.view">
    <field name="name">account.bank.statement.voucher.tree.inherit</field>
    <field name="model">account.bank.statement</field>
    <field name="inherit_id" ref="account.view_bank_statement_form"/>
    <field name="arch" type="xml">
        <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='amount']" position="after">
            <field name="voucher_id" string="" widget="many2onebutton" options="{'label':{'create':'Reconcile','edit':'Edit Reconciliation'}}" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name, 'default_active': False}"/>
        </xpath>
        <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/form/group/field[@name='sequence']" position="before">
            <field name="voucher_id" widget="many2onebutton" options="{'label':{'create':'Reconcile','edit':'Edit Reconciliation'}}" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name, 'default_active': False}"/>
        </xpath>
        <field name="amount" position="attributes">
            <attribute name="on_change">onchange_amount(amount)</attribute>
        </field>
    </field>
</record>

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 9/12/13, 9:08 AM
Seen: 1297 times
Last updated: 3/16/15, 8:10 AM