62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
import datetime
|
|
from odoo import models, fields, api, _, modules
|
|
from odoo.exceptions import ValidationError, UserError
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
MODEL_DOMAIN = """[
|
|
('is_workflow', '=', True),
|
|
('state', '=', 'base'),
|
|
('transient', '=', False),
|
|
'!',
|
|
'|',
|
|
'|',
|
|
'|',
|
|
'|',
|
|
'|',
|
|
'|',
|
|
'|',
|
|
('model', '=ilike', 'res.%'),
|
|
('model', '=ilike', 'ir.%'),
|
|
('model', '=ilike', 'soong.workflow%'),
|
|
('model', '=ilike', 'bus.%'),
|
|
('model', '=ilike', 'base.%'),
|
|
('model', '=ilike', 'base_%'),
|
|
('model', '=', 'base'),
|
|
('model', '=', '_unknown'),
|
|
]"""
|
|
|
|
|
|
class SoongWorkflowEntrust(models.Model):
|
|
_name = "soong.workflow.entrust"
|
|
_description = "工作流委托"
|
|
|
|
name = fields.Many2one("ir.model", string="名称", domain=MODEL_DOMAIN, default=lambda self: self.env['ir.model'].search([('model', '=', 'entrust.all')]))
|
|
entrust_user_id = fields.Many2one('res.users', string='委托人')
|
|
entrust_user_id2 = fields.Many2one('res.users', string='被委托人')
|
|
is_expiration_date = fields.Boolean(string="一直有效", default=True)
|
|
start_time = fields.Datetime(string="生效日期", copy=False, default=fields.Datetime.now)
|
|
end_time = fields.Datetime(string="失效日期", copy=False)
|
|
is_enable = fields.Boolean(string="是否启用", default=False, compute="compute_is_enable", store=True)
|
|
entrust_notice = fields.Boolean(string="发送事务提醒消息", default=True)
|
|
|
|
@api.depends('start_time', 'end_time', 'is_expiration_date')
|
|
def compute_is_enable(self):
|
|
for rec in self:
|
|
if rec.is_expiration_date:
|
|
rec.is_enable = True
|
|
elif rec.start_time and rec.end_time:
|
|
if rec.start_time < datetime.datetime.now() and rec.end_time > datetime.datetime.now():
|
|
rec.is_enable = True
|
|
else:
|
|
rec.is_enable = False
|
|
|
|
|
|
class EntrustAll(models.Model):
|
|
_name = "entrust.all"
|
|
_inherit = 'soong.workflow.mixin'
|
|
_description = "全部流程"
|
|
|
|
name = fields.Char(string='name') |