Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
4086 Visualizzazioni

Hi, 

I would like to know how can I achieve this

I have a field called demofield that has the value 10 for example

And I would like that my field demofield2 has as default the value of the first demofield but it can be editable.

I have tried with  @api.onchange but always set the value of demofield2 as demofield and I can't change it.

Thank you for your help

Avatar
Abbandona
Risposta migliore

You have to set your demofield2 as a computed field;

demofield2 = fields.Float(compute='_compute_demofield2', store=True)
@api.depends('demofield')
def _compute_demofield2(self):
    self.demofield2 = self.demofield

The store=True parameter is very important to make the field editable.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
mag 22
4180
1
dic 21
6527
0
nov 21
3147
1
ott 21
3953
0
apr 21
2221