Skip to content

Commit 1b68671

Browse files
imlopesivantodorovich
authored andcommitted
[MIG] fieldservice_agreement: Migration to 17.0
The `agreement_serviceprofile` dependency has been moved to a glue module `fieldservice_agreement_serviceprofile`.
1 parent 6355b0b commit 1b68671

27 files changed

+217
-296
lines changed

fieldservice_agreement/README.rst

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,76 +17,89 @@ Field Service - Agreements
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ffield--service-lightgray.png?logo=github
20-
:target: https://github.com/OCA/field-service/tree/16.0/fieldservice_agreement
20+
:target: https://github.com/OCA/field-service/tree/17.0/fieldservice_agreement
2121
:alt: OCA/field-service
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/field-service-16-0/field-service-16-0-fieldservice_agreement
23+
:target: https://translation.odoo-community.org/projects/field-service-17-0/field-service-17-0-fieldservice_agreement
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=17.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

31-
Odoo Agreement App does not provide an easy way to access field service orders
32-
related to an agreement. Some organizations needs to have a quick access to
33-
field service orders to track the performance of an agreement.
31+
Odoo Agreement App does not provide an easy way to access field service
32+
orders related to an agreement. Some organizations needs to have a quick
33+
access to field service orders to track the performance of an agreement.
3434

35-
This module allows you to link a field service order to an agreement and adds a
36-
smart button on the agreement to look at the list of related field service
37-
orders.
35+
This module allows you to link a field service order to an agreement and
36+
adds a smart button on the agreement to look at the list of related
37+
field service orders.
3838

3939
**Table of contents**
4040

4141
.. contents::
4242
:local:
4343

44+
Configuration
45+
=============
46+
47+
48+
4449
Usage
4550
=====
4651

4752
To use this module:
4853

49-
* Go to Field Service > Operations > Orders
50-
* Select or create a field service order and set the agreement
51-
* Go to Agreement > Agreements
52-
* Open the previous agreement
53-
* Click on the smart button "Service Orders" to see the list of related field service orders
54+
- Go to Field Service > Operations > Orders
55+
- Select or create a field service order and set the agreement
56+
- Go to Agreement > Agreements
57+
- Open the previous agreement
58+
- Click on the smart button "Service Orders" to see the list of related
59+
field service orders
60+
61+
Known issues / Roadmap
62+
======================
63+
64+
5465

5566
Bug Tracker
5667
===========
5768

5869
Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/issues>`_.
5970
In case of trouble, please check there if your issue has already been reported.
6071
If you spotted it first, help us to smash it by providing a detailed and welcomed
61-
`feedback <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_agreement%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
72+
`feedback <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_agreement%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6273

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

6576
Credits
6677
=======
6778

6879
Authors
69-
~~~~~~~
80+
-------
7081

7182
* Open Source Integrators
7283

7384
Contributors
74-
~~~~~~~~~~~~
85+
------------
7586

76-
* Bhavesh Odedra <[email protected]>
77-
* Sandip Mangukiya <[email protected]>
78-
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
79-
* Patrick Wilson <[email protected]>
87+
- Bhavesh Odedra <[email protected]>
88+
- Sandip Mangukiya <[email protected]>
89+
- Serpent Consulting Services Pvt. Ltd. <[email protected]>
90+
- Patrick Wilson <[email protected]>
91+
- Italo Lopes <[email protected]>
92+
- Iván Todorovich <[email protected]>
8093

8194
Other credits
82-
~~~~~~~~~~~~~
95+
-------------
8396

8497
The development of this module has been financially supported by:
8598

86-
* Open Source Integrators
99+
- Open Source Integrators
87100

88101
Maintainers
89-
~~~~~~~~~~~
102+
-----------
90103

91104
This module is maintained by the OCA.
92105

@@ -118,6 +131,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
118131

119132
|maintainer-max3903| |maintainer-bodedra| |maintainer-smangukiya| |maintainer-osi-scampbell| |maintainer-patrickrwilson|
120133

121-
This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/16.0/fieldservice_agreement>`_ project on GitHub.
134+
This module is part of the `OCA/field-service <https://github.com/OCA/field-service/tree/17.0/fieldservice_agreement>`_ project on GitHub.
122135

123136
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

fieldservice_agreement/__manifest__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
"website": "https://github.com/OCA/field-service",
99
"category": "Field Service",
1010
"license": "AGPL-3",
11-
"version": "16.0.1.0.0",
12-
"depends": ["fieldservice", "agreement_serviceprofile"],
11+
"version": "17.0.1.0.0",
12+
"depends": ["fieldservice", "agreement"],
1313
"data": [
1414
"views/fsm_order_view.xml",
1515
"views/fsm_equipment_view.xml",
1616
"views/agreement_view.xml",
1717
"views/fsm_person.xml",
18-
"views/fsm_location.xml",
1918
],
2019
"installable": True,
2120
"development_status": "Beta",
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22

3-
from . import agreement, fsm_equipment, fsm_location, fsm_order, fsm_person
3+
from . import agreement
4+
from . import fsm_equipment
5+
from . import fsm_order
6+
from . import fsm_person

fieldservice_agreement/models/agreement.py

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,49 @@ class Agreement(models.Model):
1414
fsm_location_id = fields.Many2one("fsm.location", string="FSM Location")
1515

1616
def _compute_service_order_count(self):
17-
for agreement in self:
18-
agreement.service_order_count = self.env["fsm.order"].search_count(
19-
[("agreement_id", "=", agreement.id)]
20-
)
21-
22-
def action_view_service_order(self):
23-
for agreement in self:
24-
fsm_order_ids = self.env["fsm.order"].search(
25-
[("agreement_id", "=", agreement.id)]
26-
)
27-
action = self.env["ir.actions.act_window"]._for_xml_id(
28-
"fieldservice.action_fsm_operation_order"
29-
)
30-
if len(fsm_order_ids) == 1:
31-
action["views"] = [
32-
(self.env.ref("fieldservice.fsm_order_form").id, "form")
33-
]
34-
action["res_id"] = fsm_order_ids.ids[0]
35-
else:
36-
action["domain"] = [("id", "in", fsm_order_ids.ids)]
37-
return action
17+
data = self.env["fsm.order"]._read_group(
18+
[("agreement_id", "in", self.ids)],
19+
["agreement_id"],
20+
["__count"],
21+
)
22+
counts = {rec.id: count for rec, count in data}
23+
for rec in self:
24+
rec.service_order_count = counts.get(rec.id, 0)
3825

3926
def _compute_equipment_count(self):
40-
for agreement in self:
41-
agreement.equipment_count = self.env["fsm.equipment"].search_count(
42-
[("agreement_id", "=", agreement.id)]
43-
)
27+
data = self.env["fsm.equipment"]._read_group(
28+
[("agreement_id", "in", self.ids)],
29+
["agreement_id"],
30+
["__count"],
31+
)
32+
counts = {rec.id: count for rec, count in data}
33+
for rec in self:
34+
rec.equipment_count = counts.get(rec.id, 0)
35+
36+
def action_view_service_order(self):
37+
action = self.env["ir.actions.act_window"]._for_xml_id(
38+
"fieldservice.action_fsm_operation_order"
39+
)
40+
orders = self.env["fsm.order"].search([("agreement_id", "in", self.ids)])
41+
if len(orders) == 1:
42+
action["views"] = [(self.env.ref("fieldservice.fsm_order_form").id, "form")]
43+
action["res_id"] = orders.id
44+
else:
45+
action["domain"] = [("id", "in", orders.ids)]
46+
return action
4447

4548
def action_view_fsm_equipment(self):
46-
for agreement in self:
47-
equipment_ids = self.env["fsm.equipment"].search(
48-
[("agreement_id", "=", agreement.id)]
49-
)
50-
action = self.env["ir.actions.act_window"]._for_xml_id(
51-
"fieldservice.action_fsm_equipment"
52-
)
53-
if len(equipment_ids) == 1:
54-
action["views"] = [
55-
(self.env.ref("fieldservice.fsm_equipment_form_view").id, "form")
56-
]
57-
action["res_id"] = equipment_ids.ids[0]
58-
else:
59-
action["domain"] = [("id", "in", equipment_ids.ids)]
60-
return action
49+
action = self.env["ir.actions.act_window"]._for_xml_id(
50+
"fieldservice.action_fsm_equipment"
51+
)
52+
equipments = self.env["fsm.equipment"].search(
53+
[("agreement_id", "in", self.ids)]
54+
)
55+
if len(equipments) == 1:
56+
action["views"] = [
57+
(self.env.ref("fieldservice.fsm_equipment_form_view").id, "form")
58+
]
59+
action["res_id"] = equipments.id
60+
else:
61+
action["domain"] = [("id", "in", equipments.ids)]
62+
return action

fieldservice_agreement/models/fsm_equipment.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ class FSMEquipment(models.Model):
88
_inherit = "fsm.equipment"
99

1010
agreement_id = fields.Many2one("agreement", string="Agreement")
11-
serviceprofile_id = fields.Many2one("agreement.serviceprofile", "Service Profile")

fieldservice_agreement/models/fsm_location.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

fieldservice_agreement/models/fsm_order.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ class FSMOrder(models.Model):
88
_inherit = "fsm.order"
99

1010
agreement_id = fields.Many2one("agreement", string="Agreement")
11-
serviceprofile_id = fields.Many2one("agreement.serviceprofile", "Service Profile")

fieldservice_agreement/models/fsm_person.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ class FSMPerson(models.Model):
88
_inherit = "fsm.person"
99

1010
agreement_count = fields.Integer(
11-
string="# of Agreements", compute="_compute_agreements"
11+
string="# of Agreements",
12+
compute="_compute_agreement_count",
1213
)
1314

14-
def _compute_agreements(self):
15-
self.agreement_count = self.env["agreement"].search_count(
16-
[("partner_id", "=", self.name)]
15+
def _compute_agreement_count(self):
16+
data = self.env["agreement"]._read_group(
17+
[("partner_id", "in", self.partner_id.ids)],
18+
["partner_id"],
19+
["__count"],
1720
)
21+
counts = {rec.id: count for rec, count in data}
22+
for rec in self:
23+
rec.agreement_count = counts.get(rec.partner_id.id, 0)
1824

1925
def action_view_agreements(self):
20-
for person in self:
21-
action = self.env["ir.actions.act_window"]._for_xml_id(
22-
"agreement_legal.agreement_operations_agreement"
23-
)
24-
agreements = self.env["agreement"].search(
25-
[("partner_id", "=", person.partner_id.id)]
26-
)
27-
if len(agreements) == 1:
28-
action["views"] = [
29-
(
30-
self.env.ref("agreement_legal.partner_agreement_form_view").id,
31-
"form",
32-
)
33-
]
34-
action["res_id"] = agreements.id
35-
else:
36-
action["domain"] = [("id", "in", agreements.ids)]
37-
return action
26+
action = self.env["ir.actions.act_window"]._for_xml_id(
27+
"agreement.agreement_action"
28+
)
29+
records = self.env["agreement"].search(
30+
[("partner_id", "in", self.partner_id.ids)]
31+
)
32+
if len(records) == 1:
33+
action["views"] = [(self.env.ref("agreement.agreement_form").id, "form")]
34+
action["res_id"] = records.id
35+
else:
36+
action["domain"] = [("id", "in", records.ids)]
37+
return action

fieldservice_agreement/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)