Odoo Help

0
3 Answers
1
Irfankhan Juneja
7/18/18, 1:51 PM

Try This

<field name="x_uom1" domain="[('category_id.name', '=', 'Length / Distance')]" options="{'no_create_edit': True, 'no_create':True}"/>

2 Comments
Michael Yeung
7/19/18, 1:23 AM

It works! Thanks! One more question. Can I set a default value for this? options="{'default':'m'}" or default="m", or the unit ID? Thanks so much

Michael Yeung
7/23/18, 7:36 AM

Big issue! I found it does not work when the user switch to another language. The domain refers the name only as the name of the language. I change the category_id.name as category_id.id, since 'Length / Distance' is one of the main category of units, and the id is 4. Now I have to manually set the Area, since its not in the base. (I created it by myself)

0
Sehrish
7/19/18, 3:58 AM
def default_xuom1(self):    
    # your logic goes here and return desired result   
    return your_result   
x_uom1 = fields.Many2one('product.uom','New Field',default=default_xuom1)

Hope this will helps you


1 Comment
Michael Yeung
7/20/18, 5:57 AM

umm... could you show me how to write it on QWEB please?

Ask a Question
Writer
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