Skip to content

Commit

Permalink
[MIG] maintenance_request_stage_transition: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kaynnan committed Jul 3, 2023
1 parent d7ec6e5 commit 6180dc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion maintenance_request_stage_transition/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Maintenance Request Stage transition",
"summary": """
Manage transition visibility and management between stages""",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/maintenance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@ class MaintenanceRequest(models.Model):
stage_id = fields.Many2one("maintenance.stage", readonly=True)

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
res = super().fields_view_get(
view_id=view_id,
view_type=view_type,
toolbar=toolbar,
submenu=submenu,
)
def get_view(self, view_id=None, view_type="form", **options):
res = super().get_view(view_id=view_id, view_type=view_type, **options)
if view_type == "form":
doc = etree.XML(res["arch"])
stages = self.env["maintenance.stage"].search([], order="sequence desc")
Expand Down
8 changes: 4 additions & 4 deletions maintenance_request_stage_transition/tests/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_inverse(self):
self.assertIn(self.original_stage, self.stage.previous_stage_ids)

def get_button(self, stage):
data = self.request.fields_view_get(view_type="form")
data = self.request.get_view(view_type="form")
form = etree.XML(data["arch"])
path = "//header/button[@name='set_maintenance_stage' and @id='%s']"
button = form.xpath(path % stage.id)[0]
Expand All @@ -36,21 +36,21 @@ def test_nochange(self):

def test_form(self):
button_stage = self.get_button(self.stage)
attr_stage = json.loads(button_stage.attrib["attrs"])
attr_stage = json.loads(button_stage.attrib["modifiers"])
self.assertNotIn(
self.request,
self.env["maintenance.request"].search(attr_stage["invisible"]),
)
button = self.get_button(self.last_stage)
attr = json.loads(button.attrib["attrs"])
attr = json.loads(button.attrib["modifiers"])
self.assertIn(
self.request, self.env["maintenance.request"].search(attr["invisible"])
)
getattr(
self.request.with_context(**json.loads(button_stage.attrib["context"])),
button.attrib["name"],
)()
self.request.refresh()
self.request.env.invalidate_all()
self.assertEqual(self.request.stage_id, self.stage)
self.assertIn(
self.request,
Expand Down

0 comments on commit 6180dc9

Please sign in to comment.