@@ -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:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<field name="company" string="公司" widget="radio" invisible="not is_jtbb"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='department_id']" position="after">
|
||||
<field name="employee_ids" widget="many2many_tags" options="{'no_create': True}" invisible="equipment_assign_to != 'department'"/>
|
||||
<field name="department_id1" options="{'no_create': True}" invisible="equipment_assign_to != 'employee'"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='technician_user_id']" position="attributes">
|
||||
<attribute name="string">管理员</attribute>
|
||||
|
||||
Reference in New Issue
Block a user