Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4012 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
How to track One2many field in Odoo12? แก้ไขแล้ว
3
พ.ย. 23
17305
Error: Couldn't load module web แก้ไขแล้ว
3
พ.ย. 24
24904
How I get the current ID of a record ? แก้ไขแล้ว
1
เม.ย. 23
6062
6
ม.ค. 23
11407
2
ธ.ค. 22
6788