تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3999 أدوات العرض

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
الصورة الرمزية
إهمال
الكاتب

easy

@api.one

def _get_creator_id(self):

self.create_uid = self.env.user.id

return True

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
نوفمبر 23
17298
3
نوفمبر 24
24888
1
أبريل 23
6055
6
يناير 23
11386
2
ديسمبر 22
6773