添加功能

This commit is contained in:
zhou
2025-04-30 19:08:51 +08:00
parent b759c68337
commit 0fc92e1ed0
9 changed files with 94 additions and 8 deletions
+11 -2
View File
@@ -35,9 +35,9 @@ class RoomBooking(models.Model):
meeting_type = fields.Selection([('up', '线上'), ('down', '线下'), ('exterior', '外部')], default='down', string="会议形式",
required=True)
meeting_type_id = fields.Many2one('room.meeting.type', string="会议类型")
room_users_ids = fields.Many2many(related='meeting_type_id.users_ids', string="出席人员")
room_users_ids = fields.Many2many('res.users', string="出席人员")
other_company_id = fields.Many2one('res.partner', string="外部公司")
host = fields.Many2one(related='meeting_type_id.host_user_id', string="主持人")
host = fields.Many2one('res.users', string="主持人")
stationed_group = fields.Boolean(string="驻组参会")
other_company_user_ids = fields.One2many(related="other_company_id.child_ids", string="其他人员")
@@ -55,6 +55,15 @@ class RoomBooking(models.Model):
# 关联流程
relevancy_type = fields.Selection([('none', '无')], string="关联流程类型")
@api.onchange('meeting_type_id')
def _onchange_meeting_type_id(self):
if self.meeting_type_id:
self.room_users_ids = self.meeting_type_id.users_ids
self.host = self.meeting_type_id.host_user_id
else:
self.room_users_ids = [(5, 0, 0)]
self.host = False
@api.model_create_multi
def create(self, vals_list):
bookings = super(RoomBooking, self).create(vals_list)
+19 -4
View File
@@ -44,6 +44,15 @@
<i class="fa fa-long-arrow-right" title="Until"/>
<t t-out="stop_datetime.toFormat(' f')"/>
</li>
<li class="o_gantt_popover_content_item mt-2">
<strong>出席人员:</strong>
<t t-if="room_users_ids">
<t t-foreach="room_users_ids" t-as="user">
<t t-if="!loop.first">, </t>
<t t-out="user[1]"/>
</t>
</t>
</li>
</ul>
</div>
</div>
@@ -150,7 +159,6 @@
<field name="fleet_id" invisible="meeting_type != 'exterior'"/>
<field name="meeting_place" invisible="meeting_type != 'exterior'"/>
<field name="room_id" string="会议地点"/>
<field name="host"/>
</group>
<group>
<field name="department_id" widget="ztree_select"/>
@@ -159,7 +167,7 @@
</group>
<group col="4">
<group>
<field name="room_users_ids" widget="many2many_tags"/>
<field name="host"/>
</group>
<group>
<field name="stationed_group"/>
@@ -167,8 +175,15 @@
<group/>
<group/>
</group>
<group>
<field name="other_company_user_ids" widget="many2many_tags" readonly="1"/>
<group col="4">
<group>
<field name="room_users_ids" widget="many2many_tags"/>
</group>
<group>
<field name="other_company_user_ids" widget="many2many_tags" readonly="1"/>
</group>
<group/>
<group/>
</group>
<group col="5">
<group>
@@ -4,7 +4,7 @@
<field name="name">soong.user.role.tree</field>
<field name="model">soong.user.role</field>
<field name="arch" type="xml">
<tree>
<tree limit="20" advanced_filter="True">
<field name="number" required="1"/>
<field name="name" required="1"/>
<field name="department_id" widget="ztree_select"/>
@@ -2,6 +2,7 @@
from odoo import api, fields, models
from pypinyin import pinyin,lazy_pinyin
from odoo.osv import expression
from odoo.exceptions import ValidationError
class YuthonHrDepartment(models.Model):
_inherit = "hr.department"
@@ -67,4 +68,25 @@ class YuthonHrDepartment(models.Model):
domain = expression.AND([search_domain, domain])
return self._search(domain, limit=limit, order=order)
@api.constrains('department_code')
def _check_department_code_uniqueness(self):
for record in self:
if record.department_code:
existing_records = self.search([
('department_code', '=', record.department_code),
('id', '!=', record.id)
])
if existing_records:
raise ValidationError("部门序号必须唯一!")
@api.onchange('department_code')
def _onchange_department_code(self):
for record in self:
if record.department_code:
employee_ids = self.env['hr.employee'].search([('department_id', '=', record.id.origin), ('company_id', '=', record.company_id.id)])
for employee in employee_ids:
if employee.number and len(employee.number) >= 2:
old_suffix = employee.number[-2:]
employee.number = record.department_code + old_suffix
@@ -19,6 +19,10 @@
<field name="model">hr.job</field>
<field name="inherit_id" ref="hr.view_hr_job_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="limit">20</attribute>
<attribute name="advanced_filter">True</attribute>
</xpath>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="string">岗位</attribute>
</xpath>
@@ -10,6 +10,10 @@
<field name="model">hr.department</field>
<field name="inherit_id" ref="hr.view_department_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="limit">20</attribute>
<attribute name="advanced_filter">True</attribute>
</xpath>
<xpath expr="//field[@name='total_employee']" position="attributes">
<attribute name="column_invisible">1</attribute>
</xpath>
@@ -11,6 +11,7 @@
</xpath>
<xpath expr="//field[@name='parent_id']" position="attributes">
<attribute name="string">上级领导</attribute>
<attribute name="options">"{'no_create': True}"</attribute>
</xpath>
<xpath expr="//field[@name='coach_id']" position="attributes">
<attribute name="invisible">1</attribute>
@@ -83,7 +84,7 @@
</group>
<group string="家庭状态">
<field name="marital"/>
<field name="marriage_documents_id" invisible="marital != 'married'"
<field name="marriage_documents_id" invisible="marital != 'married'" options="{'no_create': True}"
widget="preview_many2one"/>
<field name="spouse_complete_name" invisible="marital not in ['married', 'cohabitant']"/>
<field name="spouse_birthdate" invisible="marital not in ['married', 'cohabitant']"/>
@@ -94,6 +95,9 @@
<xpath expr="//group[@name='identification_group']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='job_id']" position="attributes">
<attribute name="options">"{'no_create': True}"</attribute>
</xpath>
<xpath expr="//field[@name='job_id']" position="after">
<field name="number"/>
<field name="user_number"/>
@@ -329,6 +333,8 @@
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="banner_route">/employee/banner/route</attribute>
<attribute name="limit">20</attribute>
<attribute name="advanced_filter">True</attribute>
</xpath>
<xpath expr="//field[@name='activity_ids']" position="attributes">
<attribute name="column_invisible">1</attribute>
+1
View File
@@ -1,2 +1,3 @@
from . import yuthon_will_task
from . import yuthon_task_time
from . import inherit_room_booking
@@ -0,0 +1,25 @@
from odoo import api, fields, models
class InheritRoomBooking(models.Model):
_inherit = 'room.booking'
@api.model
def create(self, vals):
task_time_ids = self.env['yuthon.task.time'].search([('name', '=', '30分钟')])
new_record = super(InheritRoomBooking, self).create(vals)
employee_list = []
if new_record.room_users_ids:
for user_id in new_record.room_users_ids:
if user_id.employee_ids:
employee_list.append(user_id.employee_ids.id)
if task_time_ids:
self.env['yuthon.will.task'].sudo().create({
'task_content': new_record.name,
'users_ids': [(6, 0, new_record.room_users_ids.ids)],
'employee_ids': [(6, 0, employee_list)],
'task_time_ids': [(6, 0, task_time_ids.ids)],
'start_time': new_record.start_datetime,
'end_time': new_record.stop_datetime
})
return new_record