How i can achieve the idea of making three fields should be selectable the way that when i change one of them , the rest 2 fields will be automatically changed also one of those 3 fields should be type many2one field

Good morning everybody;

i want to ask about something if it can achievable on the tryton interface.
in a form exist on the tryton interface i have a fieldA that should be a many2one field and call a class (this class has 3 attributes,one of them type binary image )
in another side i have 2 another fields fieldB and fieldC that i want to know what i should give them as type .

those 2 fields are linked to the fieldA.

the thing here that those 3 fields are linked in such a way that if i change one of them , the other two fields will be changed automatically but every field will display certain information(certain attribute).

ps: i guess those fields should point on the same class that has 3 attributes but every field will display one attribute from those 3 attributes and on the same time the type of the three fields should be selectable the way that when i change one of them , the rest 2 fields will be automatically changed.

My question here how i can achieve this if it’s feasible to do it of course , and is it feasible if i make the three fields type many2one
and if i change one of them the two other fields will be changed .

am on a mess if can anyone help me to fix my ideas if it feasible to do it.

Best regards,thanks in advance

Why are you not using Function fields for the two other fields in such way that they are computed out of the value of the first field.

Hi;
the problem that one of the 3 fields should be type many2one field (has 3 attributes one of them is binary image ), the second obstacle that i want also the opposite change i mean not just if :
* i change fieldA,---->fieldB and fieldC should be changed automatically
But also i want if :
*i change fieldB,------>fiedlA and fieldC should be changed automatically
*i change fieldC,------>fiedlA and fieldB should be changed automatically

Are fieldB and fieldC “real” fields, or will you only store fieldA in the end?

You are looking for the “on_change” methods, which are used to update fields value based on another field modification.

If only fieldA is stored, fieldB and fieldC should be Function fields with a setter (so they can be modified) doing nothing (because the “on_change” calls will already sync everything). You can actually implement the setters if you want to be able to set them in some code or scripting, but usually a “no-op” setter will make do.

the 3 fields are real , the fieldA not just be stored because also i want it changeable i mean if i change fieldB or fieldC the fieldA will change automatically because the 3 fields are trying to convey the same information that’w why i want 3 things that : if i change fieldA,---->fieldB and fieldC should be changed automatically
*i change fieldB,------>fiedlA and fieldC should be changed automatically
*i change fieldC,------>fiedlA and fieldB should be changed automatically

should i make the three fields type many2one and point on the same class !
also if there was an example like i search on some of standard modules could you point me to where to find it?

If it is the same information then it should be a unique field. Otherwise you have data duplication which is bad.

*same information , i mean the information is linked to describe something like : fieldA is to select design_name(this field should be a many2one field because this field point to a classA has a binary image as an attribute and 2 another attributes positionB_design (attributeB) , positionC_design(attributeC)) .

also on the same form there was fieldB positionB_design point to the attributeB "positionB_design " of the many2one fieldA.

the same fieldC point to the attributeC “positionC_design” of the many2one fieldA.

the 3 fields that one of them should be Many2one field are linked in a way that:

--->if i select and change fieldA (design_name)---->fieldB (positionB_design)- and fieldC(positionC_design) will be changed automatically.

--->if i select and change fieldB (positionB_design)---->fieldA(design_name) and field3(positionC_design) will be changed automatically.

also 
--->if i select and change fieldC (positionC_design)---->fieldA(design_name) and fieldB(positionB_design) will be changed automatically.

That’s exactly what I said. It is the same information so there is the need only for one field otherwise data it duplicated.
And yes Tryton will make it hard to design models with duplicate data because we do not want such bad design.

1 Like