diff --git a/yuthon_sps_approval/__manifest__.py b/yuthon_sps_approval/__manifest__.py
index 9c80d0acd..6d505c411 100644
--- a/yuthon_sps_approval/__manifest__.py
+++ b/yuthon_sps_approval/__manifest__.py
@@ -10,8 +10,9 @@
'data': [
'security/ir.model.access.csv',
'data/sps_approval_code_data.xml',
+ 'views/inherit_hr_employee_views.xml',
'views/yuthon_office_supplies_views.xml',
- 'views/yuthon_office_borrow_views.xml',
+ 'views/yuthon_office_supplies_setting_views.xml',
],
'installable': True,
'application': True,
diff --git a/yuthon_sps_approval/models/__init__.py b/yuthon_sps_approval/models/__init__.py
index c33c3b3de..2adfc0bf6 100644
--- a/yuthon_sps_approval/models/__init__.py
+++ b/yuthon_sps_approval/models/__init__.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from . import yuthon_office_supplies
-from . import yuthon_office_borrow
\ No newline at end of file
+from . import yuthon_office_supplies_setting
+from . import inherit_hr_employee
\ No newline at end of file
diff --git a/yuthon_sps_approval/models/inherit_hr_employee.py b/yuthon_sps_approval/models/inherit_hr_employee.py
new file mode 100644
index 000000000..d0e34fa56
--- /dev/null
+++ b/yuthon_sps_approval/models/inherit_hr_employee.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from odoo import api, fields, models
+
+
+class YuthonHrEmployee(models.Model):
+ _inherit = "hr.employee"
+
+ office_supplies_ids = fields.One2many('yuthon.office.supplies.line', 'employee_id', string="办公用品明细行")
+
+
+class YuthonOfficeSuppliesLine(models.Model):
+ _name = 'yuthon.office.supplies.line'
+ _description = "办公用品明细行"
+
+ employee_id = fields.Many2one('hr.employee', string="关联员工")
+ product_id = fields.Many2one('product.product', string="办公用品")
+ number = fields.Integer(string="数量")
+ price = fields.Float(string="单价")
+ amount = fields.Float(string="金额")
diff --git a/yuthon_sps_approval/models/yuthon_office_borrow.py b/yuthon_sps_approval/models/yuthon_office_borrow.py
deleted file mode 100644
index 5393193d8..000000000
--- a/yuthon_sps_approval/models/yuthon_office_borrow.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from odoo import models, fields, api
-
-
-class YuthonOfficeBorrow(models.Model):
- _name = 'yuthon.office.borrow'
- _description = '办公用品借用单'
-
- name = fields.Char(string='标题', required=True)
- code = fields.Char(string="编号",
- default=lambda self: self.env['ir.sequence'].next_by_code('yuthon_office_borrow_code'))
- is_issues = fields.Boolean(string='是否上会')
- users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
- department_id = fields.Many2one('hr.department', string="部门", related='users_id.employee_id.department_id')
- reason_application = fields.Html(string="事由")
- date = fields.Date(string="申请日期", default=fields.Date.today())
- related_issues_id = fields.Many2one('issue.library', string="关联议题")
- yuthon_company = fields.Selection(related='users_id.employee_id.yuthon_company', string="公司")
- yuthon_office_borrow_line_ids = fields.One2many('yuthon.office.borrow.line', 'borrow_id', string="关联办公用品申请明细")
- active = fields.Boolean('Active', default=True, tracking=True)
-
-
-class YuthonOfficeBorrowLine(models.Model):
- _name = 'yuthon.office.borrow.line'
- _description = '办公用品申请明细'
-
- borrow_id = fields.Many2one('yuthon.office.borrow', string="关联办公用品申请")
- name = fields.Many2one('product.product', string="办公用品")
- number = fields.Integer(string="数量")
- price = fields.Float(string="单价")
- amount = fields.Float(string="金额")
-
diff --git a/yuthon_sps_approval/models/yuthon_office_supplies.py b/yuthon_sps_approval/models/yuthon_office_supplies.py
index 34b4b0542..b29fc21bf 100644
--- a/yuthon_sps_approval/models/yuthon_office_supplies.py
+++ b/yuthon_sps_approval/models/yuthon_office_supplies.py
@@ -16,16 +16,55 @@ class YuthonOfficeSupplies(models.Model):
related_issues_id = fields.Many2one('issue.library', string="关联议题")
yuthon_company = fields.Selection(related='users_id.employee_id.yuthon_company', string="公司")
yuthon_office_supplies_line_ids = fields.One2many('yuthon.office.supplies.line', 'supplies_id', string="关联办公用品申请明细")
+ yuthon_office_borrow_line_ids = fields.One2many('yuthon.office.borrow.line', 'supplies_id', string="关联办公用品借用明细")
active = fields.Boolean('Active', default=True, tracking=True)
+ office_supplies_id = fields.Many2one('yuthon.office.supplies.setting',string="办公用品")
+ @api.onchange('office_supplies_id')
+ def _onchange_office_supplies(self):
+ supplies_setting_line_ids = self.office_supplies_id.supplies_setting_line_ids
+ supplies_borrow_line_ids = self.office_supplies_id.supplies_borrow_line_ids
+
+ new_supplies_lines = []
+ for supplies_setting in supplies_setting_line_ids:
+ new_supplies_lines.append((0, 0, {
+ 'product_id': supplies_setting.product_id.id,
+ 'number': supplies_setting.number,
+ 'price': supplies_setting.price,
+ 'total': supplies_setting.total,
+ }))
+ self.yuthon_office_supplies_line_ids = new_supplies_lines
+
+ new_borrow_lines = []
+ for supplies_borrow in supplies_borrow_line_ids:
+ new_borrow_lines.append((0, 0, {
+ 'product_id': supplies_borrow.product_id.id,
+ 'number': supplies_borrow.number,
+ 'price': supplies_borrow.price,
+ 'total': supplies_borrow.total,
+ 'start_time': supplies_borrow.start_time,
+ 'end_time': supplies_borrow.end_time,
+ }))
+ self.yuthon_office_borrow_line_ids = new_borrow_lines
class YuthonOfficeSuppliesLine(models.Model):
_name = 'yuthon.office.supplies.line'
_description = '办公用品申请明细'
supplies_id = fields.Many2one('yuthon.office.supplies', string="关联办公用品申请")
- name = fields.Many2one('product.product', string="办公用品")
+ product_id = fields.Many2one('product.product', string="办公用品")
number = fields.Integer(string="数量")
price = fields.Float(string="单价")
amount = fields.Float(string="金额")
+class YuthonOfficeBorrowLine(models.Model):
+ _name = 'yuthon.office.borrow.line'
+ _description = '办公用品借用明细'
+
+ supplies_id = fields.Many2one('yuthon.office.supplies', string="关联办公用品申请")
+ product_id = fields.Many2one('product.product', string="办公用品")
+ number = fields.Integer(string="数量")
+ price = fields.Float(string="单价")
+ start_time = fields.Date(string="借用时间")
+ end_time = fields.Date(string="归还时间")
+ amount = fields.Float(string="金额")
diff --git a/yuthon_sps_approval/models/yuthon_office_supplies_setting.py b/yuthon_sps_approval/models/yuthon_office_supplies_setting.py
new file mode 100644
index 000000000..f15293537
--- /dev/null
+++ b/yuthon_sps_approval/models/yuthon_office_supplies_setting.py
@@ -0,0 +1,32 @@
+from odoo import models, fields, api
+
+
+class YuthonOfficeSuppliesSetting(models.Model):
+ _name = 'yuthon.office.supplies.setting'
+ _description = '办公用品套餐配置'
+
+ name = fields.Char(string='名称')
+ supplies_setting_line_ids = fields.One2many('office.supplies.setting.line', 'supplies_setting_id', string='关联明细')
+ supplies_borrow_line_ids = fields.One2many('office.supplies.borrow.line', 'supplies_setting_id', string='关联明细')
+
+class OfficeSuppliesSettingLine(models.Model):
+ _name = 'office.supplies.setting.line'
+ _description = '办公用品申用套餐配置明细'
+
+ supplies_setting_id = fields.Many2one('yuthon.office.supplies.setting', string='关联办公用品套餐配置')
+ product_id = fields.Many2one('product.product', string='办公用品')
+ number = fields.Integer(string="数量")
+ price = fields.Float(string="单价")
+ amount = fields.Float(string="金额")
+
+class OfficeSuppliesBorrowLine(models.Model):
+ _name = 'office.supplies.borrow.line'
+ _description = '办公用品申用明细'
+
+ supplies_setting_id = fields.Many2one('yuthon.office.supplies.setting', string='关联办公用品套餐配置')
+ product_id = fields.Many2one('product.product', string='办公用品')
+ number = fields.Integer(string="数量")
+ price = fields.Float(string="单价")
+ amount = fields.Float(string="金额")
+ start_time = fields.Date(string="借用时间")
+ end_time = fields.Date(string="归还时间")
diff --git a/yuthon_sps_approval/security/ir.model.access.csv b/yuthon_sps_approval/security/ir.model.access.csv
index 761691dfb..e6c6c0379 100644
--- a/yuthon_sps_approval/security/ir.model.access.csv
+++ b/yuthon_sps_approval/security/ir.model.access.csv
@@ -1,5 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_yuthon_office_supplies,yuthon_office_supplies,model_yuthon_office_supplies,base.group_user,1,1,1,1
access_yuthon_office_supplies_line,yuthon_office_supplies_line,model_yuthon_office_supplies_line,base.group_user,1,1,1,1
-access_yuthon_office_borrow,yuthon_office_borrow,model_yuthon_office_borrow,base.group_user,1,1,1,1
-access_yuthon_office_borrow_line,yuthon_office_borrow_line,model_yuthon_office_borrow_line,base.group_user,1,1,1,1
\ No newline at end of file
+access_yuthon_office_borrow_line,yuthon_office_borrow_line,model_yuthon_office_borrow_line,base.group_user,1,1,1,1
+access_yuthon_office_supplies_setting,yuthon_office_supplies_setting,model_yuthon_office_supplies_setting,base.group_user,1,1,1,1
+access_office_supplies_setting_line,office_supplies_setting_line,model_office_supplies_setting_line,base.group_user,1,1,1,1
+access_office_supplies_borrow_line,office_supplies_borrow_line,model_office_supplies_borrow_line,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/yuthon_sps_approval/views/inherit_hr_employee_views.xml b/yuthon_sps_approval/views/inherit_hr_employee_views.xml
new file mode 100644
index 000000000..e08a33967
--- /dev/null
+++ b/yuthon_sps_approval/views/inherit_hr_employee_views.xml
@@ -0,0 +1,21 @@
+
+
+
+ hr.employee.inherit.sps.form
+ hr.employee
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/yuthon_sps_approval/views/yuthon_office_borrow_views.xml b/yuthon_sps_approval/views/yuthon_office_borrow_views.xml
deleted file mode 100644
index 1b7c77b4d..000000000
--- a/yuthon_sps_approval/views/yuthon_office_borrow_views.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
- yuthon.office.borrow.tree
- yuthon.office.borrow
-
-
-
-
-
-
-
-
-
-
-
- yuthon.office.borrow.form
- yuthon.office.borrow
-
-
-
-
-
- 办公用品借用
- yuthon.office.borrow
- tree,form
-
-
\ No newline at end of file
diff --git a/yuthon_sps_approval/views/yuthon_office_supplies_setting_views.xml b/yuthon_sps_approval/views/yuthon_office_supplies_setting_views.xml
new file mode 100644
index 000000000..1f05d016c
--- /dev/null
+++ b/yuthon_sps_approval/views/yuthon_office_supplies_setting_views.xml
@@ -0,0 +1,59 @@
+
+
+
+ yuthon.office.supplies.setting.tree
+ yuthon.office.supplies.setting
+
+
+
+
+
+
+
+ yuthon.office.supplies.setting.form
+ yuthon.office.supplies.setting
+
+
+
+
+
+ 办公用品设置
+ yuthon.office.supplies.setting
+ tree,form
+
+
diff --git a/yuthon_sps_approval/views/yuthon_office_supplies_views.xml b/yuthon_sps_approval/views/yuthon_office_supplies_views.xml
index 7ce3aabaa..352d840ac 100644
--- a/yuthon_sps_approval/views/yuthon_office_supplies_views.xml
+++ b/yuthon_sps_approval/views/yuthon_office_supplies_views.xml
@@ -27,6 +27,7 @@
+
@@ -42,13 +43,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index a2102961f..9c69dcb43 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -159,11 +159,6 @@
parent="hr_menu_recruitment_process"
action="yuthon_sps_approval.view_yuthon_office_supplies_action"
sequence="12"/>
-
-
+