添加功能
This commit is contained in:
@@ -15,6 +15,25 @@ class ExpatriationApproval(models.Model):
|
|||||||
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
|
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
|
||||||
expatriates_ids = fields.Many2many('hr.employee', string="外派人员")
|
expatriates_ids = fields.Many2many('hr.employee', string="外派人员")
|
||||||
start_date = fields.Date(string="开始日期")
|
start_date = fields.Date(string="开始日期")
|
||||||
|
return_date = fields.Date(
|
||||||
|
string="返回日期",
|
||||||
|
compute="_compute_return_date",
|
||||||
|
)
|
||||||
|
approve_state = fields.Selection(
|
||||||
|
[("start", "草稿"), ("pending", "审批中"), ("end", "结束")],
|
||||||
|
string="审批状态",
|
||||||
|
compute="_compute_approve_state",
|
||||||
|
)
|
||||||
|
expatriation_state = fields.Selection(
|
||||||
|
[("expatriating", "外派中"), ("returned", "已返回")],
|
||||||
|
string="状态",
|
||||||
|
compute="_compute_expatriation_state",
|
||||||
|
)
|
||||||
|
reclaim_state = fields.Boolean(
|
||||||
|
string="已作废",
|
||||||
|
compute="_compute_reclaim_state",
|
||||||
|
search="_search_reclaim_state",
|
||||||
|
)
|
||||||
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
||||||
default='normal')
|
default='normal')
|
||||||
active = fields.Boolean('Active', default=True, tracking=True)
|
active = fields.Boolean('Active', default=True, tracking=True)
|
||||||
@@ -47,4 +66,63 @@ class ExpatriationApproval(models.Model):
|
|||||||
'approval_date': fields.Datetime.now(),
|
'approval_date': fields.Datetime.now(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def _compute_approve_state(self):
|
||||||
|
"""从关联的 back.approval 找到对应的 workflow.record,取其 approve_state"""
|
||||||
|
for rec in self:
|
||||||
|
wf = self.env['soong.workflow.record'].search([
|
||||||
|
('res_model', '=', 'expatriation.approval'),
|
||||||
|
('res_id', '=', rec.id),
|
||||||
|
('reclaim_state', '=', False),
|
||||||
|
], limit=1)
|
||||||
|
rec.approve_state = wf.approve_state if wf else False
|
||||||
|
|
||||||
|
def _compute_return_date(self):
|
||||||
|
"""取关联 back.approval 的 end_date,但需 workflow 已 end 才写入"""
|
||||||
|
for rec in self:
|
||||||
|
back = self.env['back.approval'].search([
|
||||||
|
('expatriation_id', '=', rec.id),
|
||||||
|
], limit=1)
|
||||||
|
if not back:
|
||||||
|
rec.return_date = False
|
||||||
|
continue
|
||||||
|
wf = self.env['soong.workflow.record'].search([
|
||||||
|
('res_model', '=', 'back.approval'),
|
||||||
|
('res_id', '=', back.id),
|
||||||
|
('reclaim_state', '=', False),
|
||||||
|
('approve_state', '=', 'end'),
|
||||||
|
], limit=1)
|
||||||
|
rec.return_date = back.end_date if wf else False
|
||||||
|
|
||||||
|
def _compute_reclaim_state(self):
|
||||||
|
"""从 workflow.record 取 reclaim_state"""
|
||||||
|
for rec in self:
|
||||||
|
wf = self.env['soong.workflow.record'].search([
|
||||||
|
('res_model', '=', 'expatriation.approval'),
|
||||||
|
('res_id', '=', rec.id),
|
||||||
|
], limit=1)
|
||||||
|
rec.reclaim_state = wf.reclaim_state if wf else False
|
||||||
|
|
||||||
|
def _search_reclaim_state(self, operator, value):
|
||||||
|
"""domain 搜索:按 workflow.record 的 reclaim_state 过滤"""
|
||||||
|
reclaimed_records = self.env['soong.workflow.record'].search([
|
||||||
|
('res_model', '=', 'expatriation.approval'),
|
||||||
|
('reclaim_state', '=', True),
|
||||||
|
])
|
||||||
|
reclaimed_ids = reclaimed_records.mapped('res_id')
|
||||||
|
if operator == '=':
|
||||||
|
return [('id', 'in' if value else 'not in', reclaimed_ids)]
|
||||||
|
elif operator == '!=':
|
||||||
|
return [('id', 'not in' if value else 'in', reclaimed_ids)]
|
||||||
|
return []
|
||||||
|
|
||||||
|
def _compute_expatriation_state(self):
|
||||||
|
"""有返回日期→已返回,审批结束→外派中,否则空"""
|
||||||
|
for rec in self:
|
||||||
|
if rec.return_date:
|
||||||
|
rec.expatriation_state = 'returned'
|
||||||
|
elif rec.approve_state == 'end':
|
||||||
|
rec.expatriation_state = 'expatriating'
|
||||||
|
else:
|
||||||
|
rec.expatriation_state = False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,14 @@
|
|||||||
<field name="model">expatriation.approval</field>
|
<field name="model">expatriation.approval</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="外派驻点审批">
|
<tree string="外派驻点审批">
|
||||||
<field name="name"/>
|
<field name="users_id" string="申请人"/>
|
||||||
<field name="users_id" options="{'no_create': True}"/>
|
<field name="expatriates_ids" widget="many2many_tags" string="外派人员"/>
|
||||||
<field name="expatriates_ids" widget="many2many_tags"/>
|
<field name="start_date" string="外派日期"/>
|
||||||
<field name="start_date"/>
|
<field name="reason_application" string="外派事由"/>
|
||||||
|
<field name="return_date"/>
|
||||||
|
<field name="expatriation_state" widget="badge" decoration-info="expatriation_state == 'expatriating'" decoration-success="expatriation_state == 'returned'"/>
|
||||||
|
<field name="approve_state" column_invisible="1"/>
|
||||||
|
<field name="reclaim_state" column_invisible="1"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -48,6 +52,8 @@
|
|||||||
<field name="expatriates_ids" widget="many2many_tags"/>
|
<field name="expatriates_ids" widget="many2many_tags"/>
|
||||||
<field name="work_end" invisible="1"/>
|
<field name="work_end" invisible="1"/>
|
||||||
<field name="start_date"/>
|
<field name="start_date"/>
|
||||||
|
<field name="return_date" readonly="1"/>
|
||||||
|
<field name="approve_state" readonly="1"/>
|
||||||
<field name="reason_application"/>
|
<field name="reason_application"/>
|
||||||
<field name="is_effect" invisible="1"/>
|
<field name="is_effect" invisible="1"/>
|
||||||
<field name="issues_result" invisible="is_issues == False"/>
|
<field name="issues_result" invisible="is_issues == False"/>
|
||||||
@@ -63,4 +69,27 @@
|
|||||||
<field name="res_model">expatriation.approval</field>
|
<field name="res_model">expatriation.approval</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record id="view_expatriation_approval_simple_tree" model="ir.ui.view">
|
||||||
|
<field name="name">expatriation.approval.simple.tree</field>
|
||||||
|
<field name="model">expatriation.approval</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="外派返回查询" default_order="start_date desc">
|
||||||
|
<field name="users_id" string="申请人"/>
|
||||||
|
<field name="expatriates_ids" widget="many2many_tags" string="外派人员"/>
|
||||||
|
<field name="start_date" string="外派日期"/>
|
||||||
|
<field name="return_date"/>
|
||||||
|
<field name="reason_application" string="外派事由"/>
|
||||||
|
<field name="expatriation_state" widget="badge" decoration-info="expatriation_state == 'expatriating'" decoration-success="expatriation_state == 'returned'"/>
|
||||||
|
<field name="approve_state" column_invisible="1"/>
|
||||||
|
<field name="reclaim_state" column_invisible="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="view_expatriation_approval_simple_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">外派返回查询</field>
|
||||||
|
<field name="res_model">expatriation.approval</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="domain">[('reclaim_state', '=', False)]</field>
|
||||||
|
<field name="view_id" ref="view_expatriation_approval_simple_tree"/>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -192,6 +192,10 @@
|
|||||||
<!-- parent="hr_attendance_root_board_menu"-->
|
<!-- parent="hr_attendance_root_board_menu"-->
|
||||||
<!-- action="yuthon_hr_attendance.view_staff_dining_report_action"-->
|
<!-- action="yuthon_hr_attendance.view_staff_dining_report_action"-->
|
||||||
<!-- sequence="15"/>-->
|
<!-- sequence="15"/>-->
|
||||||
|
<menuitem id="menu_hr_attendance_expatriation_simple" name="外派查询"
|
||||||
|
parent="hr_attendance_root_board_menu"
|
||||||
|
sequence="19"
|
||||||
|
action="yuthon_hr_attendance.view_expatriation_approval_simple_action"/>
|
||||||
<menuitem id="menu_hr_attendance_detail_view_attendances"
|
<menuitem id="menu_hr_attendance_detail_view_attendances"
|
||||||
name="打卡详情"
|
name="打卡详情"
|
||||||
parent="hr_attendance_root_board_menu"
|
parent="hr_attendance_root_board_menu"
|
||||||
|
|||||||
Reference in New Issue
Block a user