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)下面是我在模块中创建数据时使用的简单创建方法。目标是创建具有相同名称的相同创建方法的引用,samemanufacture_id.I意味着当我创建sun.order时,需要创建相同的时间引号。所以,也许大约1可以给我举个例子,或者给我一个大致的想法。因为我不知道。
class pos_quotation(models.Model):
_name = "pos.quotation"
name = fields.Char('Name')
manufacture_id = fields.Many2one(
'product.product',发布于 2017-10-16 14:52:38
您可以按照以下方式重写create方法:
@api.model
def create(self, vals):
Sequence = self.env['ir.sequence']
vals['name'] = Sequence.next_by_code('sun.order')
#set your pos_quotation dictionary
vals_quot = {'manufacture_id': vals['manufacture_id'],
#... other fields for pos.quotation model
}
self.env['pos.quotation'].create(vals_quot)
return super(SunOrder, self).create(vals)希望这能帮到你。
https://stackoverflow.com/questions/46772565
复制相似问题