Procházet zdrojové kódy

create employee model

yu yang před 1 rokem
rodič
revize
a24c40ce8b
2 změnil soubory, kde provedl 45 přidání a 0 odebrání
  1. 2 0
      employee/models/__init__.py
  2. 43 0
      employee/models/employee.py

+ 2 - 0
employee/models/__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from . import employee

+ 43 - 0
employee/models/employee.py

@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+import base64
+import logging
+
+from odoo import api, fields, models
+from odoo.modules.module import get_module_resource
+from odoo import tools, _
+
+_logger = logging.getLogger(__name__)
+
+GENDER = [
+    ('male', '男'),
+    ('female', '女'),
+    ('other', '其他')
+]
+
+MARITAL = [
+    ('single', '单身'),
+    ('married', '已婚'),
+    ('cohabitant', '合法同居'),
+    ('widower', '丧偶'),
+    ('divorced', '离婚')
+]
+
+
+class Employee(models.Model):
+    _name = 'ml.employee'
+    _description = '''员工信息'''
+
+    name = fields.Char(string='姓名')
+    company_id = fields.Many2one('res.company', string='公司')
+    gender = fields.Selection(GENDER, string='性别')
+    country_id = fields.Many2one('res.country', string='国籍')
+    birthday = fields.Date(string='生日')
+    marital = fields.Selection(MARITAL, string='婚姻状况', default='single')
+
+    address = fields.Char(string='家庭住址')
+    mobile_phone = fields.Char(string='手机号')
+    work_email = fields.Char(string='工作邮箱')
+    leader_id = fields.Many2one('ml.employee', string='所属上级')
+    subordinate_ids = fields.One2many('ml.employee', 'leader_id', string='下属')
+    note = fields.Text(string='备注信息')
+