Odoo Help

0

0
1 Answer
3
Avatar

Akhil P Sivan

--Akhil P Sivan--

4449
| 6 4 9
Kochi, India
--Akhil P Sivan--

Odoo Developer

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
2/5/17, 3:24 PM

Hi,

While passing domain as strings on xml files, on the left hand side of condition you are supposed to give a field name and on the right side you can provide variables or strings. Try like this:

class AccountInvoiceLine(models.Model):
    _inherit = "account.invoice.line"
    
    tracking = fields.Selection(related='product_id.product_tmpl_id.tracking', String="Tracking")

And in the xml file:

<record id="invoice_form" model="ir.ui.view">    
    <field name="name">account.invoice.form.inherit.vtm2</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form" />
    <field name="arch" type="xml">
         
        <xpath expr="//field[@name='invoice_line_ids']//field[@name='discount']" position="after">
            <field name="tracking" invisible="1" />
            <button name="split_lot" string="Lot Split" type="object" icon="fa-list" groups="stock.group_production_lot"
                 attrs="{'invisible': [('tracking', '=', 'none')]}"/>
        </xpath>
    </field>
</record>
3 Comments
Pascal Tremblay
2/5/17, 4:49 PM

Your explanation is great! Your code is great. All your words are great! It is magic!

Pascal Tremblay
2/5/17, 4:51 PM

How do you explain the fact that we have to put the field 'tracking' (invisible) on the view? I have tried without this field on the view and it doesn't work. The view have to absolutely have this field on it?

Akhil P Sivan
2/5/17, 10:48 PM

Yes the field has to be present on the tree view, to use conditions based on that.

Ask a Question
Writer
Keep Informed
1 follower(s)
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