Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
12580 Vizualizări

Hello there 

I'm  concatenating some custom fields with the function CREATE and it works good but if i edit my fields then the cocatenation doesn't change anymore.

Render ------- CAPEX-12.0-2-15-8-3

My concatenation Code : 

@api.model
def create(self, values):
res = super(Lead, self).create(values)
name1 = "{}-{}-{}-{}-{}-{}".format(
res.service_type,
res.dc,
res.ac,
res.panel,
res.voltaje,
res.voltaje_type,
)
res.name1 = name1
return res 


So i think that i have to use the Write Function  but i don't know how to make it work...



Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

You can override the write function of the corresponding model and concatenate the field values as you have done by overriding the create method.

def write(self, vals):
return super(ClassName, self).write(vals)

For overriding the write method, see: How To Override Write Function in Odoo

Also you can achieve the same using a compute field, so that you dont need to override both the create and write function: How to Write Compute Field and its Function in Odoo12


Thanks

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
oct. 22
3635
2
dec. 23
14636
0
oct. 23
33
3
oct. 23
788
1
oct. 23
569