Odoo Help


2 Answers

Hiral Patel (hip) India

--Hiral Patel (hip)--
| 3 2 7
Gandhinagar, India
--Hiral Patel (hip)--

Hiral Patel (hip) India
6/14/13, 8:46 AM


You can do like :

<label for="name" string="Company" attrs="{'invisible': [('is_company','=',False)]}"/>

<label for="name" string="First Name" attrs="{'invisible': [('is_company','=',True)]}"/>


Alexander Moldavia
6/14/13, 9:14 AM

Hi, Do you test that? I tryed that solution, but when is_company equals True, Form is can not be saved.

Hiral Patel (hip) India
6/14/13, 9:25 AM

I have tested this and it's working at my end. I have tested on runbot with latest revision and it's allow me to save record even when is_company equals True.

wjn Poland
6/14/13, 9:32 AM

Thanks, I will give it a try. Most things I tried before messed up the format (how it's display on the view).

Hiral Patel (hip) India
6/14/13, 9:39 AM

In res_partner_view.xml you will get record for partner form (having id ="view_partner_form"). In place of <label for="name"/> apply the code and then update your server. Otherwise enable debug mode and change it for your test purpose that it's working or not. I hope it will solve your problem.

George India
9/2/15, 12:14 AM

Dear Friends, I would like to change field label(string) while onchange many2one field. I have configured few items in that object. I could not use fields_view_get. While i onchange i am able to update field string but is not reflected in the view. def onchange_ini_temp_id(self, cr, uid, ids, initiative_category_id, context=None): val = {} view_id=None view_type='form' toolbar=False submenu=False res = super(project_project, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) fields = res.get('fields', {}) doc = etree.XML(res['arch']) for node in doc.xpath("//field[@name='release']"): node.set('invisible', "0") node.set('string', 'Test Data') setup_modifiers(node, res['fields']['release']) res['arch'] = etree.tostring(doc) self.fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False) return res Thank you

Dr Obx United Kingdom
11/3/15, 5:28 AM

The easiest option is as Hiral suggested, just show or hide label depending on some field value. Looking for better solution as well :) However it doesn't work as good as it should ;)

Alexander Moldavia
6/8/13, 7:59 PM

In your case, better way to define two fields and hide one of them when you change is_company.

For example:

<field name="name" attrs="{'invisible': [('is_company','=',True)]}"/>
<field name="company_name" attrs="{'invisible': [('is_company','=',False)]}"/>
1 Comment
wjn Poland
6/8/13, 8:44 PM

The field "name" is the default field from res.partner, used for companies AND contacts in V7. I want to keep OpenERP's database as stock as possible, hence my question about dynamic label fields.

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

Odoo Training Center

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

Test it now