@@ -11,7 +11,7 @@
|
||||
'license': 'LGPL-3',
|
||||
'author': 'pengyuthon',
|
||||
'website': 'https://www.pengyuthon.com',
|
||||
'depends': ['hr'],
|
||||
'depends': ['base', 'hr'],
|
||||
'data': [
|
||||
'data/hr_department_data.xml',
|
||||
'data/user_role_data.xml',
|
||||
@@ -21,6 +21,7 @@
|
||||
'views/yuthon_hr_department_views.xml',
|
||||
'views/yuthon_job_lv_views.xml',
|
||||
'views/yuthon_user_role_views.xml',
|
||||
'views/inherit_res_user_views.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from . import yuthon_hr_employee
|
||||
from . import yuthon_job_lv
|
||||
from . import yuthon_user_role
|
||||
from . import yuthon_hr_department
|
||||
from . import yuthon_hr_department
|
||||
from . import inherit_res_user
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
def all_create_users(self):
|
||||
employee_ids = self.browse(self._context.get('active_ids', self._context.get('active_id')))
|
||||
for employee in employee_ids:
|
||||
employee_id = self.env['hr.employee'].search([('name', '=', employee.name)])
|
||||
if not employee_id:
|
||||
employee_data = {
|
||||
'name': employee.name,
|
||||
'company_id': employee.env.company.id,
|
||||
}
|
||||
self.env['hr.employee'].create(employee_data)
|
||||
else:
|
||||
raise UserError('该用户:%s已经创建员工,请不要重复操作' % employee_id.name)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="all_data_create_user" model="ir.actions.server">
|
||||
<field name="name">批量创建员工</field>
|
||||
<field name="model_id" ref="base.model_res_users"/>
|
||||
<field name="binding_model_id" ref="base.model_res_users" />
|
||||
<field name="state">code</field>
|
||||
<field name="code">records.all_create_users()</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user