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

My custom module create a new products. It's logic based on eCommerce. But i want to overwrite value of field "Created by" (create_uid) - it must be equal to the name of current user on the moment of creation (user_id.partner_id.name).
How compute field only on creation?

class New(models.Model):
    _inherit = 'product.template'
    new_product = fields.Char(string='Your product')
    create_uid = fields.One2many('res.users', compute='_computed_author')
@api.multi
def _computed_author(self):
    self.create_uid = user_id.partner_id.name
    return True
Avatar
Abbandona
Autore

easy

@api.one

def _get_creator_id(self):

self.create_uid = self.env.user.id

return True

Post correlati Risposte Visualizzazioni Attività
3
nov 23
17340
3
nov 24
24982
1
apr 23
6091
6
gen 23
11449
2
dic 22
6834