Skip to content

Commit

Permalink
[MIG] maintenance_project: Migration to 17.0
Browse files Browse the repository at this point in the history
Co-Authored-By: David Alonso <david.alonso@solvos.es>
  • Loading branch information
Anxo82 and dalonsod committed Aug 11, 2024
1 parent 2015de5 commit f132c76
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion maintenance_project/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Maintenance Projects",
"summary": "Adds projects to maintenance equipments and requests",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Odoo Community Association (OCA), Solvos",
"license": "AGPL-3",
"category": "Maintenance",
Expand Down
2 changes: 0 additions & 2 deletions maintenance_project/data/demo_maintenance_project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
<field name="model">MODEL2</field>
<field name="create_project_from_equipment" eval="False" />
<field name="project_id" ref="maintenance_project.project_project_1" />
<field name="period" eval="30" />
<field name="maintenance_duration" eval="2" />
<field
name="preventive_default_task_id"
ref="maintenance_project.project_task_12"
Expand Down
2 changes: 0 additions & 2 deletions maintenance_project/models/maintenance_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ def create(self, vals_list):

@api.onchange("equipment_id")
def onchange_equipment_id(self):
res = super().onchange_equipment_id()
if self.equipment_id and self.equipment_id.project_id:
self.project_id = self.equipment_id.project_id
return res
11 changes: 4 additions & 7 deletions maintenance_project/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -418,9 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<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>
Expand Down
40 changes: 28 additions & 12 deletions maintenance_project/tests/test_maintenance_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
class TestMaintenanceProject(test_common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestMaintenanceProject, cls).setUpClass()
super().setUpClass()

cls.cron = cls.env.ref("maintenance.maintenance_requests_cron")
cls.project1 = cls.env["project.project"].create({"name": "My project"})
cls.project_demo1 = cls.env.ref("maintenance_project.project_project_1")

Expand All @@ -20,8 +19,6 @@ def setUpClass(cls):
"maintenance_team_id": cls.env.ref(
"maintenance.equipment_team_metrology"
).id,
"period": 30,
"maintenance_duration": 1.0,
}
)
cls.equipment2 = cls.env["maintenance.equipment"].create(
Expand Down Expand Up @@ -69,15 +66,34 @@ def test_request_onchange_equipment(self):
self.assertFalse(req2.project_id)

def test_generate_requests(self):
self.cron.method_direct_trigger()

generated_requests = self.env["maintenance.request"].search(
[("project_id", "!=", False)]
req_name = "My new recurring test request"
req = self.env["maintenance.request"].create(
{
"name": req_name,
"maintenance_type": "preventive",
"duration": 1.0,
"recurring_maintenance": True,
"repeat_interval": 1,
"repeat_unit": "month",
"repeat_type": "forever",
}
)
for req in generated_requests:
self.assertEqual(req.project_id, req.equipment_id.project_id)
self.assertEqual(req.task_id, req.equipment_id.preventive_default_task_id)
self.assertEqual(req.project_id.maintenance_request_count, 1)
req.equipment_id = self.equipment1
req.onchange_equipment_id()
req.description = "Request done!"

request_obj = self.env["maintenance.request"]
domain = [
("name", "=", req_name),
("equipment_id", "=", self.equipment1.id),
("project_id", "=", self.equipment1.project_id.id),
]
my_requests = request_obj.search(domain)
self.assertEqual(len(my_requests), 1)

req.stage_id = self.env.ref("maintenance.stage_3")
my_requests = request_obj.search(domain)
self.assertEqual(len(my_requests), 2)

def test_action_views(self):
act1 = self.project1.action_view_equipment_ids()
Expand Down
11 changes: 4 additions & 7 deletions maintenance_project/views/maintenance_equipment_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</xpath>
<xpath expr="//div[hasclass('o_kanban_record_body')]" position="inside">
<div t-if="record.project_id.raw_value">
<small>Project: <t t-raw="record.project_id.value" /></small>
<small>Project: <t t-out="record.project_id.value" /></small>
</div>
</xpath>
</field>
Expand All @@ -37,16 +37,13 @@
<field name="inherit_id" ref="maintenance.hr_equipment_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='location']" position="after">
<field
name="create_project_from_equipment"
attrs="{'invisible': [('id', '!=', False)]}"
/>
<field name="create_project_from_equipment" invisible="id" />
<field
name="project_id"
attrs="{'invisible': [('create_project_from_equipment', '=', True), ('id', '=', False)]}"
invisible="create_project_from_equipment or not id"
/>
</xpath>
<xpath expr="//group[@name='maintenance']" position="after">
<xpath expr="//group[@name='statistics']" position="after">
<group name="project_task">
<field
name="preventive_default_task_id"
Expand Down
2 changes: 1 addition & 1 deletion maintenance_project/views/maintenance_request_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</xpath>
<xpath expr="//div[hasclass('o_kanban_record_body')]" position="inside">
<div t-if="record.project_id.raw_value">
<small>Project: <t t-raw="record.project_id.value" /></small>
<small>Project: <t t-out="record.project_id.value" /></small>
</div>
</xpath>
</field>
Expand Down

0 comments on commit f132c76

Please sign in to comment.