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

Dynamically changed field name (label) is it possible ?

By
Dr Obx
on 5/10/15, 11:32 AM 1,840 views

To create a product I'm using my own module which also create automatically product name combining specified fields values. I't quiet good idea if you want have always the same form of names or same details in title (product name). Because my company is multinational and people have always problem with naming products so to avoid mistakes or misspelled names I decided to built this module to help them and make it easier/quicker/safer and foolproof. Since then nobody except department manager can add new names to the lists used for name creation. Because i would like to avoid increasing amount of fields i need a little advice and help. Because list of fields depends on product type which is the first field in form (fields.selection()) i would like to change some or at least one field label/string but I'm not sure is it possible without writing special program in JavaScript for example.

So if product type = Computer currently named field Variant need to be changed to Speed.

In php it could be so simple ex:

<?php

if($item_type = 'Computer'){

$field_name = 'Variant';}

if($item_type = 'Monitor'){

$field_name = 'Display Size';}

php> and then field name will be changed regarding item type chosen.

Guys, is it possible to change field name (string or label) depending on value selected in selection field in some easy way ?

Of course i can create a dedicated field but if i can just change name ...


"Another silly question" isn't an appropriate title for a question - please review https://www.odoo.com/forum/help-1/faq and https://www.odoo.com/forum/help-1/question/meta-why-do-some-questions-get-answers-and-others-dont-25620

Bista Solutions US, Ray Carnes
on 5/10/15, 3:50 PM

Yes you absolutely right.

Dr Obx
on 5/11/15, 5:38 AM
1
GrupoCITEC
On 10/30/15, 3:02 PM

I had same situation some time ago. What I did was:

- Create two auxiliary fields, each of one with its own label

- Put both fields in the form view

- Put the main field too in the view, but hidden

- Hide each one depending on the value of your item_type

- Inherit write or on_change method so when the value changes, you can set the main hidden field

This is actually solution I used to have, multiple fields hide or displayed depending on value in other(parent) field. But it's not what I tried to achieve. I wanted to change "Label" rather than whole field :) Why ? I'm not a fan of millions of fields ;) so I wanted to limit fields to it's minimum. So if I could change only a 'Label' conditionally it would be much much better solution :)

Dr Obx
on 11/2/15, 10:38 AM
-1

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 5/11/15, 2:38 AM

Hi, you can use a functional field (called compute field in new v8 api) for that.

Problem is (again) new API (8.0) allow you to do a lot of things but in old API .... not really. I need it for old unfortunately.

Dr Obx
on 5/11/15, 5:39 AM

@Robert, is an on_change event enough for you? This goes of when something is triggered and you can then change any other field as you'd like. The only requirement is an event happening.

Yenthe
on 5/11/15, 5:58 AM

@Yanthe, you suggest that using on_change i can do it ? I can change string in ? Interesting, can you give me an example how should it look like ?

Dr Obx
on 5/11/15, 7:50 AM

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

1 follower(s)

Stats

Asked: 5/10/15, 11:32 AM
Seen: 1840 times
Last updated: 11/2/15, 10:39 AM