pengyuthon
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# -*- 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')
|
||||
def compute_is_enable(self):
|
||||
for rec in self:
|
||||
if rec.start_time and rec.end_time:
|
||||
if rec.start_time < datetime.datetime.now() and rec.end_time > datetime.datetime.now() or rec.is_enable:
|
||||
rec.is_enable = True
|
||||
else:
|
||||
rec.is_enable = False
|
||||
else:
|
||||
rec.is_enable = False
|
||||
|
||||
|
||||
class EntrustAll(models.Model):
|
||||
_name = "entrust.all"
|
||||
_inherit = 'soong.workflow.mixin'
|
||||
_description = "全部流程"
|
||||
|
||||
name = fields.Char(string='name')
|
||||
Reference in New Issue
Block a user