Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
7674 Visualizzazioni

i have module which has three field.name,firstname and lastname,when user save it firstname and lastname

concatenate in name field,here name field must be readonly mod.

Avatar
Abbandona
Risposta migliore

Hello Vijay,

This will help you.

name = fields.Char(compute='_compute_name', store="True")
firstname = fields.Char()
lastname = fields.Char()

@api.depends('firstname', 'lastname')
def _compute_name(self):
    for record in self:
        record.name = record.firstname + record.lastname

Avatar
Abbandona
Risposta migliore

Hello, I think you've three options.

- Overriding the create and write functions.

-Use onchange method in the firstname and lastname: but if you used onchange method to modify a readonly field this will not update the field in DB, so you need to make an invisible field, as workaround.

-Make the name field as a functional field.

Avatar
Abbandona
Autore

how to make name as functional field any demo function?

Post correlati Risposte Visualizzazioni Attività
1
ott 24
6291
9
lug 21
63513
8
nov 19
8117
8
apr 25
29371
3
ago 24
16382