可以使用Odoo的sequence,以purchase为例。
0_1534987255443_7274581e-8423-43c6-a600-c4a0cefe69d6-image.png
创建采购单的时候自动获取流水号
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('purchase.order') or '/'
return super(PurchaseOrder, self).create(vals)