Skip to content

Commit

Permalink
[MIG] fieldservice_agreement: Migration to 17.0
Browse files Browse the repository at this point in the history
The `agreement_serviceprofile` dependency has been moved to a
glue module `fieldservice_agreement_serviceprofile`.
  • Loading branch information
ilo authored and ivantodorovich committed Nov 21, 2024
1 parent 6355b0b commit 444aae6
Show file tree
Hide file tree
Showing 27 changed files with 202 additions and 284 deletions.
63 changes: 38 additions & 25 deletions fieldservice_agreement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,76 +17,89 @@ Field Service - Agreements
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ffield--service-lightgray.png?logo=github
:target: https://github.com/OCA/field-service/tree/16.0/fieldservice_agreement
:target: https://github.com/OCA/field-service/tree/17.0/fieldservice_agreement
:alt: OCA/field-service
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/field-service-16-0/field-service-16-0-fieldservice_agreement
:target: https://translation.odoo-community.org/projects/field-service-17-0/field-service-17-0-fieldservice_agreement
: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/field-service&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/field-service&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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

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

**Table of contents**

.. contents::
:local:

Configuration
=============



Usage
=====

To use this module:

* Go to Field Service > Operations > Orders
* Select or create a field service order and set the agreement
* Go to Agreement > Agreements
* Open the previous agreement
* Click on the smart button "Service Orders" to see the list of related field service orders
- Go to Field Service > Operations > Orders
- Select or create a field service order and set the agreement
- Go to Agreement > Agreements
- Open the previous agreement
- Click on the smart button "Service Orders" to see the list of related
field service orders

Known issues / Roadmap
======================



Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/field-service/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/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**>`_.
`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**>`_.

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

Credits
=======

Authors
~~~~~~~
-------

* Open Source Integrators

Contributors
~~~~~~~~~~~~
------------

* Bhavesh Odedra <[email protected]>
* Sandip Mangukiya <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
* Patrick Wilson <[email protected]>
- Bhavesh Odedra <[email protected]>
- Sandip Mangukiya <[email protected]>
- Serpent Consulting Services Pvt. Ltd. <[email protected]>
- Patrick Wilson <[email protected]>
- Italo Lopes <[email protected]>
- Iván Todorovich <[email protected]>

Other credits
~~~~~~~~~~~~~
-------------

The development of this module has been financially supported by:

* Open Source Integrators
- Open Source Integrators

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

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

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

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 2 additions & 3 deletions fieldservice_agreement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
"website": "https://github.com/OCA/field-service",
"category": "Field Service",
"license": "AGPL-3",
"version": "16.0.1.0.0",
"depends": ["fieldservice", "agreement_serviceprofile"],
"version": "17.0.1.0.0",
"depends": ["fieldservice", "agreement"],
"data": [
"views/fsm_order_view.xml",
"views/fsm_equipment_view.xml",
"views/agreement_view.xml",
"views/fsm_person.xml",
"views/fsm_location.xml",
],
"installable": True,
"development_status": "Beta",
Expand Down
5 changes: 4 additions & 1 deletion fieldservice_agreement/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import agreement, fsm_equipment, fsm_location, fsm_order, fsm_person
from . import agreement
from . import fsm_equipment
from . import fsm_order
from . import fsm_person
82 changes: 42 additions & 40 deletions fieldservice_agreement/models/agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,49 @@ class Agreement(models.Model):
fsm_location_id = fields.Many2one("fsm.location", string="FSM Location")

def _compute_service_order_count(self):
for agreement in self:
agreement.service_order_count = self.env["fsm.order"].search_count(
[("agreement_id", "=", agreement.id)]
)

def action_view_service_order(self):
for agreement in self:
fsm_order_ids = self.env["fsm.order"].search(
[("agreement_id", "=", agreement.id)]
)
action = self.env["ir.actions.act_window"]._for_xml_id(
"fieldservice.action_fsm_operation_order"
)
if len(fsm_order_ids) == 1:
action["views"] = [
(self.env.ref("fieldservice.fsm_order_form").id, "form")
]
action["res_id"] = fsm_order_ids.ids[0]
else:
action["domain"] = [("id", "in", fsm_order_ids.ids)]
return action
data = self.env["fsm.order"]._read_group(
[('agreement_id', 'in', self.ids)],
['agreement_id'],
['__count'],
)
counts = {rec.id: count for rec, count in data}
for rec in self:
rec.service_order_count = counts.get(rec.id, 0)

def _compute_equipment_count(self):
for agreement in self:
agreement.equipment_count = self.env["fsm.equipment"].search_count(
[("agreement_id", "=", agreement.id)]
)
data = self.env["fsm.equipment"]._read_group(
[('agreement_id', 'in', self.ids)],
['agreement_id'],
['__count'],
)
counts = {rec.id: count for rec, count in data}
for rec in self:
rec.equipment_count = counts.get(rec.id, 0)

def action_view_service_order(self):
action = self.env["ir.actions.act_window"]._for_xml_id(
"fieldservice.action_fsm_operation_order"
)
orders = self.env["fsm.order"].search([("agreement_id", "in", self.ids)])
if len(orders) == 1:
action["views"] = [(self.env.ref("fieldservice.fsm_order_form").id, "form")]
action["res_id"] = orders.id
else:
action["domain"] = [("id", "in", orders.ids)]
return action

def action_view_fsm_equipment(self):
for agreement in self:
equipment_ids = self.env["fsm.equipment"].search(
[("agreement_id", "=", agreement.id)]
)
action = self.env["ir.actions.act_window"]._for_xml_id(
"fieldservice.action_fsm_equipment"
)
if len(equipment_ids) == 1:
action["views"] = [
(self.env.ref("fieldservice.fsm_equipment_form_view").id, "form")
]
action["res_id"] = equipment_ids.ids[0]
else:
action["domain"] = [("id", "in", equipment_ids.ids)]
return action
action = self.env["ir.actions.act_window"]._for_xml_id(
"fieldservice.action_fsm_equipment"
)
equipments = self.env["fsm.equipment"].search(
[("agreement_id", "in", self.ids)]
)
if len(equipments) == 1:
action["views"] = [
(self.env.ref("fieldservice.fsm_equipment_form_view").id, "form")
]
action["res_id"] = equipments.id
else:
action["domain"] = [("id", "in", equipments.ids)]
return action
1 change: 0 additions & 1 deletion fieldservice_agreement/models/fsm_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ class FSMEquipment(models.Model):
_inherit = "fsm.equipment"

agreement_id = fields.Many2one("agreement", string="Agreement")
serviceprofile_id = fields.Many2one("agreement.serviceprofile", "Service Profile")
29 changes: 0 additions & 29 deletions fieldservice_agreement/models/fsm_location.py

This file was deleted.

1 change: 0 additions & 1 deletion fieldservice_agreement/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ class FSMOrder(models.Model):
_inherit = "fsm.order"

agreement_id = fields.Many2one("agreement", string="Agreement")
serviceprofile_id = fields.Many2one("agreement.serviceprofile", "Service Profile")
44 changes: 22 additions & 22 deletions fieldservice_agreement/models/fsm_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ class FSMPerson(models.Model):
_inherit = "fsm.person"

agreement_count = fields.Integer(
string="# of Agreements", compute="_compute_agreements"
string="# of Agreements",
compute="_compute_agreement_count",
)

def _compute_agreements(self):
self.agreement_count = self.env["agreement"].search_count(
[("partner_id", "=", self.name)]
def _compute_agreement_count(self):
data = self.env["agreement"]._read_group(
[('partner_id', 'in', self.partner_id.ids)],
['partner_id'],
['__count'],
)
counts = {rec.id: count for rec, count in data}
for rec in self:
rec.agreement_count = counts.get(rec.partner_id.id, 0)

def action_view_agreements(self):
for person in self:
action = self.env["ir.actions.act_window"]._for_xml_id(
"agreement_legal.agreement_operations_agreement"
)
agreements = self.env["agreement"].search(
[("partner_id", "=", person.partner_id.id)]
)
if len(agreements) == 1:
action["views"] = [
(
self.env.ref("agreement_legal.partner_agreement_form_view").id,
"form",
)
]
action["res_id"] = agreements.id
else:
action["domain"] = [("id", "in", agreements.ids)]
return action
action = self.env["ir.actions.act_window"]._for_xml_id(
"agreement.agreement_action"
)
records = self.env["agreement"].search(
[("partner_id", "in", self.partner_id.ids)]
)
if len(records) == 1:
action["views"] = [(self.env.ref("agreement.agreement_form").id, "form")]
action["res_id"] = records.id
else:
action["domain"] = [("id", "in", records.ids)]
return action
3 changes: 3 additions & 0 deletions fieldservice_agreement/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions fieldservice_agreement/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
6 changes: 6 additions & 0 deletions fieldservice_agreement/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Bhavesh Odedra \<<[email protected]>\>
- Sandip Mangukiya \<<[email protected]>\>
- Serpent Consulting Services Pvt. Ltd. \<<[email protected]>\>
- Patrick Wilson \<<[email protected]>\>
- Italo Lopes \<<[email protected]>\>
- Iván Todorovich \<<[email protected]>\>
4 changes: 0 additions & 4 deletions fieldservice_agreement/readme/CONTRIBUTORS.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
The development of this module has been financially supported by:

* Open Source Integrators
- Open Source Integrators
7 changes: 7 additions & 0 deletions fieldservice_agreement/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Odoo Agreement App does not provide an easy way to access field service
orders related to an agreement. Some organizations needs to have a quick
access to field service orders to track the performance of an agreement.

This module allows you to link a field service order to an agreement and
adds a smart button on the agreement to look at the list of related
field service orders.
7 changes: 0 additions & 7 deletions fieldservice_agreement/readme/DESCRIPTION.rst

This file was deleted.

1 change: 1 addition & 0 deletions fieldservice_agreement/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
8 changes: 8 additions & 0 deletions fieldservice_agreement/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To use this module:

- Go to Field Service \> Operations \> Orders
- Select or create a field service order and set the agreement
- Go to Agreement \> Agreements
- Open the previous agreement
- Click on the smart button "Service Orders" to see the list of related
field service orders
7 changes: 0 additions & 7 deletions fieldservice_agreement/readme/USAGE.rst

This file was deleted.

Loading

0 comments on commit 444aae6

Please sign in to comment.