来一段odoo审批流的核心代码
时间: 2023-03-07 07:53:33 浏览: 249
请参考以下代码:from odoo import api, modelsclass Workflow(models.Model):
_name = 'workflow' @api.multi
def create_workflow(self):
self.ensure_one()
workflow_obj = self.env['workflow.workflow']
workflow_data = {
'name': self.name,
'description': self.description,
'state': self.state,
}
workflow = workflow_obj.create(workflow_data)
workflow_step_obj = self.env['workflow.step']
for step in self.steps:
workflow_step_data = {
'name': step.name,
'description': step.description,
'workflow_id': workflow.id,
}
workflow_step_obj.create(workflow_step_data)
return workflow
阅读全文