Odoo Help

Welcome!

This community 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.

0

How to implement indicator icon in tree and form view?

By
Antanas
on 9/12/13, 9:08 AM 1,130 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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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