diff --git a/yuthon_holiday/__manifest__.py b/yuthon_holiday/__manifest__.py
index f49979893..3097d3d50 100644
--- a/yuthon_holiday/__manifest__.py
+++ b/yuthon_holiday/__manifest__.py
@@ -9,7 +9,8 @@
'security/ir.model.access.csv',
'views/inherit_hr_type_views.xml',
'views/inherit_hr_leave_allocation_views.xml',
- 'views/inherit_hr_leave_view.xml',
+ 'views/hr_leave_batch.xml',
+ # 'views/inherit_hr_leave_view.xml',
],
'demo': [],
'depends': ['hr_holidays'],
diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py
index 4a7ba4598..944ca4e00 100644
--- a/yuthon_holiday/models/inherit_hr_leave.py
+++ b/yuthon_holiday/models/inherit_hr_leave.py
@@ -1,23 +1,58 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
+from odoo.exceptions import ValidationError
class HrLeave(models.Model):
_inherit = 'hr.leave'
- leave_line_ids = fields.One2many('hr.leave.line', 'leave_id', string="假期明细")
+ batch_id = fields.Many2one(string='Batch', comodel_name='hr.leave.batch', required=True, ondelete='cascade')
-class HrLeaveLine(models.Model):
- _name = 'hr.leave.line'
+class HolidaysRequestBatch(models.Model):
+ _name = 'hr.leave.batch'
+ _description = 'Time Off Batches'
+ _inherit = ['mail.thread.main.attachment', 'mail.activity.mixin']
- leave_id = fields.Many2one('hr.leave', string="关联审批")
- holiday_status_id = fields.Many2one('hr.leave.type', string="假期种类")
- days_available = fields.Float(string="可用天数", store=True)
- applicants = fields.Selection([('hour', '按小时'), ('day', '天'), ('half_day', '半天')], string="申请单位", store=True)
- date_start = fields.Datetime(string="开始时间", default=fields.Datetime.now)
- date_end = fields.Datetime(string="结束时间")
- leave_days = fields.Float(string='请假天数', store=True)
- surplus_days = fields.Float(string="剩余天数")
- leave_documents_id = fields.Many2many(related="holiday_status_id.leave_documents_id", string="假期详细说明")
+ def _get_default_emp(self):
+ emp = self.env['hr.employee']._get_contextual_employee()
+ if not emp:
+ raise
+ return emp
+
+ name = fields.Char(string='Description')
+ employee_id = fields.Many2one(string='Employee', comodel_name='hr.employee', required=True, default=_get_default_emp, index=True)
+ leave_ids = fields.One2many(string='Details', comodel_name='hr.leave', inverse_name='batch_id')
+ state = fields.Selection(string='State', selection=[
+ ('draft', 'To Submit'),
+ ('confirm', 'To Approve'),
+ ('refuse', 'Refused'),
+ ('validate', 'Approved')
+ ], default='draft', tracking=True, copy=False)
+
+ @api.constrains('leave_ids')
+ def _check_leave_ids(self):
+ for rec in self:
+ if len(rec.leave_ids) < 1:
+ raise ValidationError(_('You must have at least one leave request in the batch.'))
+
+ # 提交
+ def action_submit(self):
+ self.state = 'confirm'
+ self.leave_ids.action_confirm()
+
+ # 拒绝
+ def action_refuse(self):
+ self.state = 'refuse'
+ self.leave_ids.action_refuse()
+
+ # 通过
+ def action_validate(self):
+ self.state = 'validate'
+ self.leave_ids.action_validate()
+
+ # 撤回
+ def action_draft(self):
+ self.state = 'draft'
+ self.leave_ids.action_draft()
diff --git a/yuthon_holiday/security/ir.model.access.csv b/yuthon_holiday/security/ir.model.access.csv
index f312a536c..f4129e1d0 100644
--- a/yuthon_holiday/security/ir.model.access.csv
+++ b/yuthon_holiday/security/ir.model.access.csv
@@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_hr_leave_line,hr_leave_line,model_hr_leave_line,base.group_user,1,1,1,1
+access_hr_leave_batch,hr.leave.batch,model_hr_leave_batch,,1,1,1,1
diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml
new file mode 100644
index 000000000..2a299707d
--- /dev/null
+++ b/yuthon_holiday/views/hr_leave_batch.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+ hr.leave.batch.tree
+ hr.leave.batch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hr.leave.batch.form
+ hr.leave.batch
+
+
+
+
+
+
+
+ hr.leave.batch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ My Time Off
+ hr.leave.batch
+ tree,form
+ {}
+
+ [('employee_id.user_id', '=', uid)]
+
+
+
+
+
+
+ All Time Off
+ hr.leave.batch
+ tree,form
+ {}
+
+ []
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/yuthon_holiday/views/inherit_hr_type_views.xml b/yuthon_holiday/views/inherit_hr_type_views.xml
index 48ebb8b36..6fe23035f 100644
--- a/yuthon_holiday/views/inherit_hr_type_views.xml
+++ b/yuthon_holiday/views/inherit_hr_type_views.xml
@@ -8,9 +8,9 @@
假期类型
-
-
-
+
+
+
1
diff --git a/yuthon_hr_employee/__manifest__.py b/yuthon_hr_employee/__manifest__.py
index 517a581a5..1d7e09055 100644
--- a/yuthon_hr_employee/__manifest__.py
+++ b/yuthon_hr_employee/__manifest__.py
@@ -11,7 +11,7 @@
'license': 'LGPL-3',
'author': 'pengyuthon',
'website': 'https://www.pengyuthon.com',
- 'depends': ['base', 'hr', 'hr_recruitment',],
+ 'depends': ['base', 'hr', 'hr_recruitment'],
'data': [
'data/yuthon.job.lv.csv',
'data/employee_code_data.xml',
diff --git a/yuthon_hr_employee/static/others/user_templat.xlsx b/yuthon_hr_employee/static/others/user_template.xlsx
similarity index 100%
rename from yuthon_hr_employee/static/others/user_templat.xlsx
rename to yuthon_hr_employee/static/others/user_template.xlsx
diff --git a/yuthon_property/views/menuitem.xml b/yuthon_property/views/menuitem.xml
index 6ed1f9c84..b8250427e 100644
--- a/yuthon_property/views/menuitem.xml
+++ b/yuthon_property/views/menuitem.xml
@@ -63,11 +63,11 @@
parent="yuthon_property_menu_data"
action="action_property_rental_form"/>
-
+
+
+
+
+
-
+
+
+
+
+
-
-
-
-
-
+