From 621b40231e91591553cfc4a96bd55fa9effaf32f Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 29 Jul 2025 15:33:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inherit_maintenance_equipment.py | 27 +++---------------- .../views/maintenance_equipment_views.xml | 2 +- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/yuthon_maintain/models/inherit_maintenance_equipment.py b/yuthon_maintain/models/inherit_maintenance_equipment.py index f8b871786..9a7508a37 100644 --- a/yuthon_maintain/models/inherit_maintenance_equipment.py +++ b/yuthon_maintain/models/inherit_maintenance_equipment.py @@ -31,12 +31,12 @@ class InheritMaintenanceEquipment(models.Model): h5_url = fields.Char(string="二维码扫码地址", compute='_compute_h5_url') h5_url_qrcode = fields.Image(string="二维码", compute='_compute_h5_url') - company = fields.Selection([('jtbb', '集团本部'), ('ttcj', '天投城建')], string="公司") - employee_ids = fields.Many2many('hr.employee', string="员工") + company = fields.Selection([('jtbb', '天河投资'), ('ttcj', '天投城建')], string="公司") + department_id1 = fields.Many2one('hr.department', string="部门") is_jtbb = fields.Boolean(compute='_compute_company_id') mainten_state = fields.Selection([('ing', '使用中'), ('finish', '暂停')], string="设备状态") equipment_number = fields.Char(string="数量") - equipment_unit = fields.Char(string="单位") + equipment_unit = fields.Many2one('uom.uom', string="单位") @api.depends('company_id') def _compute_company_id(self): @@ -46,27 +46,6 @@ class InheritMaintenanceEquipment(models.Model): else: rec.is_jtbb = False - @api.onchange('department_id') - def _onchange_department_id(self): - def get_all_sub_department_ids(department): - sub_ids = [] - sub_departments = self.env['hr.department'].search([('parent_id', '=', department.id)]) - for sub in sub_departments: - sub_ids.append(sub.id) - sub_ids.extend(get_all_sub_department_ids(sub)) - return sub_ids - - if self.equipment_assign_to == 'department': - for record in self: - if record.department_id: - dept_ids = [record.department_id.id] - dept_ids.extend(get_all_sub_department_ids(record.department_id)) - employees = self.env['hr.employee'].search([('department_id', 'in', dept_ids)]) - record.employee_ids = [(6, 0, employees.ids)] if employees else [(5, 0, 0)] - else: - record.employee_ids = [(5, 0, 0)] - - @api.depends('name') def _compute_h5_url(self): for rec in self: diff --git a/yuthon_maintain/views/maintenance_equipment_views.xml b/yuthon_maintain/views/maintenance_equipment_views.xml index a0db32d6b..dc5d90a80 100644 --- a/yuthon_maintain/views/maintenance_equipment_views.xml +++ b/yuthon_maintain/views/maintenance_equipment_views.xml @@ -13,7 +13,7 @@ - + 管理员