Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3349 มุมมอง
class SunOrder(models.Model):

    _name = 'sun.order'
    manufacture_id = fields.Many2one(
    'product.product',

     @api.model
     def create(self, vals):
        Sequence = self.env['ir.sequence']
        vals['name'] = Sequence.next_by_code('sun.order')
        return super(SunOrder, self).create(vals)

here is simple create method that i use when creating data in my module. the goal is to create quotation with same CREATE method with same name and samemanufacture_id.I mean when i creat sun.order i need that the same time quotation would be created. So maybe some 1 can give me example or general idea how it can be done. because i have no clue.

class pos_quotation(models.Model):
    _name = "pos.quotation"
    name = fields.Char('Name')
    manufacture_id = fields.Many2one(
        'product.product',
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

here is an example of creating a record for a model

product = self.env['model.name'].create({
'field_1': 'value',
'field_2': 'value',
'field_3': True,
})


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 19
11451
Call method after creating record? แก้ไขแล้ว
1
มี.ค. 15
10595
0
มี.ค. 15
3916
0
เม.ย. 24
1948
1
ม.ค. 22
3785