欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

odoo审批流程实例

程序员文章站 2024-02-14 14:13:46
...

odoo审批流程实例

1.1 qc_inspection_view.py审批header

![在这里插入图片描述](https://img-blog.csdnimg.cn/20200216151306802.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L21yYmVsbA==,size_16,color_FFFFFF,t_70) ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200216151354849.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L21yYmVsbA==,size_16,color_FFFFFF,t_70) 1.2 qc_inspection.py
state = fields.Selection(
    [('draft', '草稿'),
     ('ready', '提交'),
     ('waiting', '等待审批'),
     ('success', '确认通过'),
     ('failed', '确认报废'),
     ('canceled', '关闭')],
    string='State', readonly=True, default='draft',
    track_visibility='onchange')

@api.multi
def action_draft(self):
    self.write({'state': 'draft'})

@api.multi
def action_todo(self):
    for inspection in self:
        if not inspection.test:
            raise exceptions.UserError(
                _("You must first set the test to perform."))
    self.write({'state': 'ready'})

odoo审批流程实例
odoo审批流程实例
odoo审批流程实例

@api.multi
def action_confirm(self):
    for inspection in self:
        for line in inspection.inspection_lines:
            if line.question_type == 'qualitative':
                if not line.qualitative_value:
                    raise exceptions.UserError(
                        _("You should provide an answer for all "
                          "qualitative questions."))
            else:
                if not line.uom_id:
                    raise exceptions.UserError(
                        _("You should provide a unit of measure for "
                          "quantitative questions."))
        if inspection.success:
            inspection.state = 'success'
        else:
            inspection.state = 'waiting'

odoo审批流程实例
odoo审批流程实例
@api.multi
def action_approve(self):
for inspection in self:
if inspection.success:
inspection.state = ‘success’
else:
inspection.state = ‘failed’

@api.multi
def action_cancel(self):
    self.write({'state': 'canceled'})

odoo审批流程实例
odoo审批流程实例
odoo审批流程实例

相关标签: odoo