Merge pull request '添加应用类别配置和隐藏my_school' (#47) from qtb into master
Reviewed-on: #47
This commit was merged in pull request #47.
This commit is contained in:
@@ -75,6 +75,7 @@ class SchoolCourse(models.Model):
|
||||
introduction = fields.Html(string='课程介绍', sanitize=True)
|
||||
objectives = fields.Html(string='课程目标', sanitize=True)
|
||||
features = fields.Html(string='课程特色', sanitize=True)
|
||||
syllabus = fields.Html(string='课程大纲', sanitize=True)
|
||||
business_scenario = fields.Html(string='业务情景', sanitize=True)
|
||||
|
||||
# 学员分配
|
||||
|
||||
@@ -267,3 +267,11 @@
|
||||
p, li { color: $o-main-text-color; }
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 隐藏右上角「公司切换器」(我的学校)
|
||||
// 项目为单学校场景,不需要用户切换公司。
|
||||
// ============================================================
|
||||
.o_switch_company_menu {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -392,4 +392,31 @@ else:
|
||||
action="action_yuthon_about_question_import"
|
||||
sequence="60"
|
||||
groups="college.group_teacher,base.group_system"/>
|
||||
|
||||
<!-- ===================== 应用类别配置(挂在「实训模块」下) ===================== -->
|
||||
<!-- Odoo 默认只有 form 视图,没有 list 视图,需要先补一个 -->
|
||||
<record id="view_yuthon_module_category_list" model="ir.ui.view">
|
||||
<field name="name">ir.module.category.list (college)</field>
|
||||
<field name="model">ir.module.category</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="应用类别">
|
||||
<field name="name" string="名称"/>
|
||||
<field name="description" string="描述"/>
|
||||
<field name="sequence" string="排序"/>
|
||||
<field name="parent_id" string="上级应用"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_yuthon_module_category" model="ir.actions.act_window">
|
||||
<field name="name">应用类别配置</field>
|
||||
<field name="res_model">ir.module.category</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_yuthon_module_category"
|
||||
name="应用类别配置"
|
||||
parent="menu_shixun_module"
|
||||
action="action_yuthon_module_category"
|
||||
sequence="10"/>
|
||||
</odoo>
|
||||
|
||||
@@ -35,15 +35,7 @@ class CourseHomework(models.Model):
|
||||
teaching_class_id = fields.Many2one('course.teaching_class', string='教学班',
|
||||
ondelete='cascade', domain="[('course_id', '=', course_id)]")
|
||||
submit_ids = fields.One2many('course.homework.submit', 'homework_id', string='提交记录')
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
score_item_ids = fields.One2many('course.score.item', 'homework_id', string='成绩项目')
|
||||
=======
|
||||
score_item_ids = fields.One2many('course.score.item', 'homework_id', string='成绩项')
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
=======
|
||||
score_item_ids = fields.One2many('course.score.item', 'homework_id', string='成绩项')
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
|
||||
# ====================== 新增:自动计算提交通道是否开启 ======================
|
||||
@api.depends('state', 'deadline')
|
||||
@@ -90,8 +82,6 @@ class CourseHomework(models.Model):
|
||||
self.publish_time = fields.Datetime.now()
|
||||
# 1. 批量为本班学生生成空白未提交记录
|
||||
self._auto_create_empty_submit()
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
# 新增:自动生成对应作业的学生成绩明细
|
||||
self._auto_create_homework_score_detail()
|
||||
# 2. 推送作业通知给学生
|
||||
@@ -147,15 +137,7 @@ class CourseHomework(models.Model):
|
||||
|
||||
if detail_vals_list:
|
||||
self.env['course.student.score.detail'].create(detail_vals_list)
|
||||
=======
|
||||
# 2. 推送作业通知给学生
|
||||
self._send_homework_notice_to_students()
|
||||
|
||||
=======
|
||||
# 2. 推送作业通知给学生
|
||||
self._send_homework_notice_to_students()
|
||||
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
def _send_homework_notice_to_students(self):
|
||||
"""发布作业后推送消息给教学班学生"""
|
||||
self.ensure_one()
|
||||
@@ -184,10 +166,6 @@ class CourseHomework(models.Model):
|
||||
partner_ids=student_users.mapped('partner_id').ids,
|
||||
subtype_xmlid='mail.mt_comment'
|
||||
)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
|
||||
def _auto_create_empty_submit(self):
|
||||
"""仅发布时执行:自动给教学班所有已选课学生生成空白未提交记录"""
|
||||
@@ -215,53 +193,12 @@ class CourseHomework(models.Model):
|
||||
batch_vals.append({
|
||||
'homework_id': self.id,
|
||||
'student_id': stu_id,
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
'course_score_item_id':self.course_score_item_id.id,
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
'state': 'unsubmit' # 默认未提交
|
||||
})
|
||||
# 批量创建空白提交记录
|
||||
submit_model.create(batch_vals)
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def _send_homework_notice_to_students(self):
|
||||
"""发布作业后推送消息给教学班学生"""
|
||||
self.ensure_one()
|
||||
if not self.teaching_class_id:
|
||||
return
|
||||
# 获取当前教学班所有已选课学生
|
||||
enrolls = self.env['course.teaching_class.enrollment'].search([
|
||||
('teaching_class_id', '=', self.teaching_class_id.id),
|
||||
('state', '=', 'enrolled')
|
||||
])
|
||||
student_users = enrolls.mapped('student_id.user_id').filtered(lambda u: u)
|
||||
if not student_users:
|
||||
return
|
||||
# 消息内容
|
||||
subject = f"新作业发布:{self.name}"
|
||||
body = f"""
|
||||
<p>课程:{self.course_id.name}</p>
|
||||
<p>作业名称:{self.name}</p>
|
||||
<p>截止时间:{self.deadline or '无'}</p>
|
||||
<p>作业要求:{self.requirement or '无'}</p>
|
||||
"""
|
||||
# 发送消息(关联当前作业记录,学生在消息中心可直接跳转)
|
||||
self.message_post(
|
||||
subject=subject,
|
||||
body=body,
|
||||
partner_ids=student_users.mapped('partner_id').ids,
|
||||
subtype_xmlid='mail.mt_note'
|
||||
)
|
||||
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
# ====================== 草稿/关闭作业 ======================
|
||||
def action_draft(self):
|
||||
self.state = 'draft'
|
||||
@@ -388,21 +325,14 @@ class CourseHomework(models.Model):
|
||||
def create(self, vals):
|
||||
homework_record = super().create(vals)
|
||||
# 草稿状态不执行自动生成提交记录,移到action_publish
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
target_a = self.env["course.score.item"].search([
|
||||
("name", "=", "作业"),
|
||||
("create_uid", "=", self.env.uid)
|
||||
], limit=1)
|
||||
|
||||
if target_a:
|
||||
# 将刚新建的B追加到A的多对多字段
|
||||
# 将新建的作业追加到"作业"成绩项目的多对多字段
|
||||
target_a.write({
|
||||
"homework_ids": [(4, homework_record.id)]
|
||||
})
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
return homework_record
|
||||
@@ -93,13 +93,6 @@ class CourseHomeworkSubmit(models.Model):
|
||||
def create(self, vals):
|
||||
submit_rec = super().create(vals)
|
||||
self._check_submit_change_state(submit_rec)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
=======
|
||||
>>>>>>> 0b2a587b69524dafde97f76bad27721afebdcddb
|
||||
return submit_rec
|
||||
|
||||
def write(self, vals):
|
||||
|
||||
Reference in New Issue
Block a user