Initial commit on branch odoo_DuyDat
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from . import add_employee_wizard,models,employee_report
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
from odoo import models, fields
|
||||
|
||||
class AddEmployeeWizard(models.TransientModel):
|
||||
_name = 'add.employee.wizard'
|
||||
_description = 'Add Employee Wizard'
|
||||
|
||||
# Thông tin từ res.partner
|
||||
name = fields.Char(string='Name', required=True)
|
||||
email = fields.Char(string='Email')
|
||||
phone = fields.Char(string='Phone')
|
||||
image_1920 = fields.Image(string="Avatar")
|
||||
|
||||
# Thông tin riêng của employee
|
||||
employee_code = fields.Char(string='Employee Code', required=True)
|
||||
department = fields.Char(string='Department')
|
||||
position = fields.Char(string='Position')
|
||||
|
||||
def action_add_employee(self):
|
||||
|
||||
self.ensure_one()
|
||||
|
||||
# Tạo partner
|
||||
partner = self.env['res.partner'].create({
|
||||
'name': self.name,
|
||||
'email': self.email,
|
||||
'phone': self.phone,
|
||||
'image_1920': self.image_1920,
|
||||
})
|
||||
|
||||
# Tạo employee.profile gắn với partner_id
|
||||
employee = self.env['employee.profile'].create({
|
||||
'partner_id': partner.id,
|
||||
'employee_code': self.employee_code,
|
||||
'department': self.department,
|
||||
'position': self.position,
|
||||
})
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'employee.profile',
|
||||
'res_id': employee.id,
|
||||
'view_mode': 'form',
|
||||
'target': 'current',
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
from odoo import models
|
||||
|
||||
class MyReport(models.AbstractModel):
|
||||
_name = 'report.employee_management.my_report_template' # module.template
|
||||
_description = 'Employee Profile Report'
|
||||
|
||||
def _get_report_values(self, docids, data=None):
|
||||
# Lấy tất cả bản ghi employee.profile
|
||||
docs = self.env['employee.profile'].browse(docids)
|
||||
|
||||
return {
|
||||
'doc_model': 'employee.profile',
|
||||
'docs': docs,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
from odoo import models, fields
|
||||
|
||||
class EmployeeProfile(models.Model):
|
||||
_name = 'employee.profile'
|
||||
_inherits = {'res.partner': 'partner_id'}
|
||||
_description = 'Employee Profile'
|
||||
|
||||
partner_id = fields.Many2one('res.partner', string='Partner', required=True, ondelete='cascade')
|
||||
employee_code = fields.Char(string='Employee Code', required=True, unique=True)
|
||||
department = fields.Char(string='Department')
|
||||
position = fields.Char(string='Position')
|
||||
Reference in New Issue
Block a user