odoo审批流程实例
程序员文章站
2024-02-14 14:13:46
...
odoo审批流程实例
1.1 qc_inspection_view.py审批header
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'})
@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'
@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'})
上一篇: php优化解决方案
下一篇: 建模随手记4 --- 主成分分析