Skip to content

Commit

Permalink
[MIG] hr_course_survey: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luisDIXMIT committed Jul 18, 2024
1 parent aa4653f commit 6fcc1f7
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 22 deletions.
10 changes: 5 additions & 5 deletions hr_course_survey/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Hr Course Survey
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github
:target: https://github.com/OCA/hr/tree/14.0/hr_course_survey
:target: https://github.com/OCA/hr/tree/16.0/hr_course_survey
:alt: OCA/hr
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-14-0/hr-14-0-hr_course_survey
:target: https://translation.odoo-community.org/projects/hr-16-0/hr-16-0-hr_course_survey
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -58,7 +58,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_course_survey%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_course_survey%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -89,6 +89,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/hr <https://github.com/OCA/hr/tree/14.0/hr_course_survey>`_ project on GitHub.
This module is part of the `OCA/hr <https://github.com/OCA/hr/tree/16.0/hr_course_survey>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 1 addition & 2 deletions hr_course_survey/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Hr Course Survey",
"summary": """
Evaluate a course using a Schedule""",
"version": "14.0.1.0.2",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr",
Expand All @@ -14,7 +14,6 @@
"data/mail.xml",
"views/hr_course_attendee.xml",
"views/hr_course.xml",
"views/hr_course_schedule.xml",
],
"demo": [],
}
2 changes: 1 addition & 1 deletion hr_course_survey/models/hr_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class HrCourse(models.Model):

examination_survey_id = fields.Many2one(
"survey.survey",
domain=[("state", "=", "open"), ("scoring_type", "!=", "no_scoring")],
domain=[("scoring_type", "!=", "no_scoring")],
)
7 changes: 3 additions & 4 deletions hr_course_survey/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">Hr Course Survey</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9106aa496f0813d33af06a01289e734c8bc3215a3a3967eeffb414c14713b316
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr/tree/14.0/hr_course_survey"><img alt="OCA/hr" src="https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-14-0/hr-14-0-hr_course_survey"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr/tree/16.0/hr_course_survey"><img alt="OCA/hr" src="https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-16-0/hr-16-0-hr_course_survey"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to add a survey to your employee’s training courses.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -399,7 +398,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/hr/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/hr/issues/new?body=module:%20hr_course_survey%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/hr/issues/new?body=module:%20hr_course_survey%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -424,7 +423,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/hr/tree/14.0/hr_course_survey">OCA/hr</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/hr/tree/16.0/hr_course_survey">OCA/hr</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
53 changes: 50 additions & 3 deletions hr_course_survey/tests/test_hr_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def setUp(self):
"access_mode": "public",
"users_login_required": True,
"users_can_go_back": False,
"state": "open",
"scoring_type": "scoring_without_answers",
}
)
Expand All @@ -35,7 +34,9 @@ def setUp(self):
)
self.course_categ = self.env["hr.course.category"].create({"name": "Category1"})
self.employee1 = self.env["hr.employee"].create({"name": "Employee1"})
self.employee2 = self.env["hr.employee"].create({"name": "Employee2"})
self.employee2 = self.env["hr.employee"].create(
{"name": "Employee2", "user_id": self.survey_manager.id}
)
self.course = self.env["hr.course"].create(
{
"name": "Test Course",
Expand Down Expand Up @@ -78,7 +79,7 @@ def test_hr_schedule(self):
self.assertEqual(self.course_schedule.state, "in_progress")
self.assertEqual(len(self.course_schedule.course_attendee_ids), 2)
self.assertFalse(self.course_schedule.course_attendee_ids[0].survey_answer_id)
self.course_schedule.attendant_ids = [(2, self.employee2.id, 0)]
self.course_schedule.attendant_ids = [(3, self.employee2.id, 0)]
self.course_schedule.waiting2inprogress()
self.assertEqual(len(self.course_schedule.attendant_ids), 1)
self.assertEqual(len(self.course_schedule.course_attendee_ids), 1)
Expand Down Expand Up @@ -123,3 +124,49 @@ def test_hr_schedule(self):
self.assertEqual(self.course_schedule.course_attendee_ids.result, "passed")
with self.assertRaises(ValidationError):
self.course_schedule.course_attendee_ids.resend_survey()

self.course_schedule.attendant_ids = [(6, 0, [self.employee2.id])]
self.course_schedule.waiting2inprogress()
self.assertEqual(len(self.course_schedule.attendant_ids), 1)
self.assertEqual(len(self.course_schedule.course_attendee_ids), 1)
self.employee2._compute_count_courses()
self.assertEqual(self.employee2.count_courses, 1)
self.employee2.action_view_course()

self.course_schedule.inprogress2validation()
self.assertEqual(self.course_schedule.state, "in_validation")
self.assertEqual(self.course_schedule.course_attendee_ids.result, "pending")
with self.assertRaises(ValidationError):
self.course_schedule.course_attendee_ids.resend_survey()
answer = self.course_schedule.course_attendee_ids.survey_answer_id
self.assertTrue(answer.hr_course_attendee_ids)
self._add_answer_line(
self.question,
answer,
self.question.suggested_answer_ids.filtered(
lambda l: l.value == "Choice1"
).id,
answer_type="suggestion",
answer_fname="suggested_answer_id",
)
answer._mark_done()
self.assertEqual(self.course_schedule.course_attendee_ids.result, "failed")
self.course_schedule.course_attendee_ids.resend_survey()
self.assertNotEqual(
answer, self.course_schedule.course_attendee_ids.survey_answer_id
)
answer = self.course_schedule.course_attendee_ids.survey_answer_id
self.assertTrue(answer.hr_course_attendee_ids)
self._add_answer_line(
self.question,
answer,
self.question.suggested_answer_ids.filtered(
lambda l: l.value == "Choice0"
).id,
answer_type="suggestion",
answer_fname="suggested_answer_id",
)
answer._mark_done()
self.assertEqual(self.course_schedule.course_attendee_ids.result, "passed")
with self.assertRaises(ValidationError):
self.course_schedule.course_attendee_ids.resend_survey()
3 changes: 2 additions & 1 deletion hr_course_survey/views/hr_course_attendee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
<field name="name">hr.course.attendee.tree</field>
<field name="model">hr.course.attendee</field>
<field name="inherit_id" ref="hr_course.hr_course_attendee_tree_view" />
<field name="groups_id" eval="[(4, ref('hr.group_hr_manager'))]" />
<field name="arch" type="xml">
<field name="result" position="after">
<field
name="survey_answer_id"
attrs="{'invisible': [('survey_answer_id', '=', False)]}"
groups="hr.group_hr_manager"
/>
<button
name="resend_survey"
string="Retry"
type="object"
icon="fa-repeat text-success"
attrs="{'column_invisible': [('parent.state', 'not in', ('in_validation'))], 'invisible': ['|', ('result', '!=', 'failed'), ('survey_answer_id', '=', False)]}"
groups="hr.group_hr_manager"
/>
</field>
</field>
Expand Down
6 changes: 0 additions & 6 deletions hr_course_survey/views/hr_course_schedule.xml

This file was deleted.

0 comments on commit 6fcc1f7

Please sign in to comment.