Skip to content

Commit

Permalink
[16.0][MIG] fieldservice_activity
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrito committed Oct 28, 2022
1 parent 284d9fe commit 5db7696
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 123 deletions.
11 changes: 5 additions & 6 deletions fieldservice_activity/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Field Service Activity
: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/15.0/fieldservice_activity
:target: https://github.com/OCA/field-service/tree/14.0/fieldservice_activity
: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-15-0/field-service-15-0-fieldservice_activity
:target: https://translation.odoo-community.org/projects/field-service-14-0/field-service-14-0-fieldservice_activity
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/264/15.0
:target: https://runbot.odoo-community.org/runbot/264/14.0
:alt: Try me on Runbot

|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/field-service/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/field-service/issues/new?body=module:%20fieldservice_activity%0Aversion:%2015.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_activity%0Aversion:%2014.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 All @@ -76,7 +76,6 @@ Contributors
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Steve Campbell <scampbells@opensourceintegrators.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Freni Patel <fpatel@opensourceintegrators.com>

Other credits
~~~~~~~~~~~~~
Expand Down Expand Up @@ -109,6 +108,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-max3903| |maintainer-osi-scampbell|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion fieldservice_activity/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Field Service Activity",
"summary": """Field Service Activities are a set of actions
that need to be performed on a service order""",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Field Service",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
Expand Down
7 changes: 2 additions & 5 deletions fieldservice_activity/i18n/es_AR.po
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ msgstr "Referencia"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__required
msgid "Required"
msgstr ""
msgid "Requireid"
msgstr "Requerido"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__sequence
Expand All @@ -160,6 +160,3 @@ msgid ""
msgstr ""
"Debe completar la actividad '%s' antes de completar "
"este pedido."

#~ msgid "Requireid"
#~ msgstr "Requerido"
7 changes: 2 additions & 5 deletions fieldservice_activity/i18n/es_CL.po
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ msgstr "Referencia"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__required
msgid "Required"
msgstr ""
msgid "Requireid"
msgstr "Requerido"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__sequence
Expand All @@ -158,6 +158,3 @@ msgid ""
"You must complete activity '%s' before completing this "
"order."
msgstr "Debe completar la actividad '%s' antes de completar este pedido."

#~ msgid "Requireid"
#~ msgstr "Requerido"
14 changes: 12 additions & 2 deletions fieldservice_activity/i18n/fieldservice_activity.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -70,6 +70,7 @@ msgstr ""

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__display_name
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_template__display_name
msgid "Display Name"
msgstr ""

Expand Down Expand Up @@ -100,11 +101,15 @@ msgstr ""

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__id
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order__id
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_template__id
msgid "ID"
msgstr ""

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity____last_update
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order____last_update
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_template____last_update
msgid "Last Modified on"
msgstr ""

Expand All @@ -123,14 +128,19 @@ msgstr ""
msgid "Name"
msgstr ""

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order__display_name
msgid "Order"
msgstr ""

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__ref
msgid "Reference"
msgstr ""

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__required
msgid "Required"
msgid "Requireid"
msgstr ""

#. module: fieldservice_activity
Expand Down
22 changes: 13 additions & 9 deletions fieldservice_activity/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-10-27 13:43+0000\n"
"PO-Revision-Date: 2021-09-29 10:34+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"
"X-Generator: Weblate 4.3.2\n"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order__order_activity_ids
Expand Down Expand Up @@ -73,6 +73,7 @@ msgstr "Completata il"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__display_name
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_template__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

Expand Down Expand Up @@ -103,11 +104,15 @@ msgstr "Modello ordine assistenza sul campo"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__id
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order__id
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_template__id
msgid "ID"
msgstr "ID"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity____last_update
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order____last_update
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_template____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

Expand All @@ -126,14 +131,19 @@ msgstr "Ultimo aggiornamento il"
msgid "Name"
msgstr "Nome"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_order__display_name
msgid "Order"
msgstr "Ordine"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__ref
msgid "Reference"
msgstr "Riferimento"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__required
msgid "Required"
msgid "Requireid"
msgstr "Richiesto"

#. module: fieldservice_activity
Expand All @@ -158,9 +168,3 @@ msgid ""
"You must complete activity '%s' before completing this "
"order."
msgstr "Devi completare l'attività '%s' prima di completare questo ordine."

#~ msgid "Order"
#~ msgstr "Ordine"

#~ msgid "Requireid"
#~ msgstr "Richiesto"
7 changes: 2 additions & 5 deletions fieldservice_activity/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ msgstr "Refer??ncia"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__required
msgid "Required"
msgstr ""
msgid "Requireid"
msgstr "Requer ID"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__sequence
Expand All @@ -158,6 +158,3 @@ msgid ""
"You must complete activity '%s' before completing this "
"order."
msgstr "Voc?? deve concluir a atividade '%s' antes de concluir este pedido."

#~ msgid "Requireid"
#~ msgstr "Requer ID"
7 changes: 2 additions & 5 deletions fieldservice_activity/i18n/pt_PT.po
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ msgstr "Refer??ncia"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__required
msgid "Required"
msgstr ""
msgid "Requireid"
msgstr "Requer ID"

#. module: fieldservice_activity
#: model:ir.model.fields,field_description:fieldservice_activity.field_fsm_activity__sequence
Expand All @@ -158,6 +158,3 @@ msgid ""
"You must complete activity '%s' before completing this "
"order."
msgstr "Voc?? deve concluir a atividade '%s' antes de concluir este pedido."

#~ msgid "Requireid"
#~ msgstr "Requer ID"
15 changes: 9 additions & 6 deletions fieldservice_activity/models/fsm_activity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from datetime import datetime

from odoo import fields, models

Expand All @@ -19,7 +18,7 @@ class FSMActivity(models.Model):
states={"todo": [("readonly", False)]},
)
sequence = fields.Integer()
completed = fields.Boolean()
completed = fields.Boolean(default=False)
completed_on = fields.Datetime(readonly=True)
completed_by = fields.Many2one("res.users", readonly=True)
ref = fields.Char(
Expand All @@ -34,10 +33,14 @@ class FSMActivity(models.Model):
)

def action_done(self):
self.completed = True
self.completed_on = datetime.now()
self.completed_by = self.env.user
self.state = "done"
self.write(
{
"completed": True,
"completed_on": fields.Datetime.now(),
"completed_by": self.env.user.id,
"state": "done",
}
)

def action_cancel(self):
self.state = "cancel"
68 changes: 37 additions & 31 deletions fieldservice_activity/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,56 @@
class FSMOrder(models.Model):
_inherit = "fsm.order"

order_activity_ids = fields.One2many("fsm.activity", "fsm_order_id", "Activites")
order_activity_ids = fields.One2many(
"fsm.activity",
"fsm_order_id",
"Order Activities",
compute="_compute_order_activity_ids",
store=True,
)

@api.onchange("template_id")
def _onchange_template_id(self):
res = super()._onchange_template_id()
@api.depends("template_id")
def _compute_order_activity_ids(self):
for rec in self:
# Clear existing activities
rec.order_activity_ids = [(5, 0, 0)]
if rec.template_id:
activity_list = []
for temp_activity in rec.template_id.temp_activity_ids:
activity_list.append(
(
0,
0,
{
"name": temp_activity.name,
"required": temp_activity.required,
"ref": temp_activity.ref,
"state": temp_activity.state,
},
)
)
rec.order_activity_ids = activity_list
return res
if not rec.template_id:
continue

activity_list = [(5, 0, 0)]
activity_list.extend(
(
0,
0,
{
"name": temp_activity.name,
"required": temp_activity.required,
"ref": temp_activity.ref,
"state": temp_activity.state,
},
)
for temp_activity in rec.template_id.temp_activity_ids
)

rec.order_activity_ids = activity_list

@api.model
@api.model_create_multi
def create(self, vals):
"""Update Activities for FSM orders that are generate from SO"""
order = super(FSMOrder, self).create(vals)
order._onchange_template_id()
return order
orders = super(FSMOrder, self).create(vals)
for order in orders:
order._onchange_template_id()
return orders

def action_complete(self):
res = super().action_complete()
for activity_id in self.order_activity_ids:
if activity_id.required and activity_id.state == "todo":
for activity in self.order_activity_ids:
if activity.required and activity.state == "todo":
raise ValidationError(
_(
"You must complete activity '%s' before \
completing this order."
)
% activity_id.name
% activity.name
)
for activity_id in self.activity_ids:
activity_id._action_done()
self.activity_ids.write({"done": True})
return res
2 changes: 1 addition & 1 deletion fieldservice_activity/models/fsm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
class FSMTemplate(models.Model):
_inherit = "fsm.template"

temp_activity_ids = fields.One2many("fsm.activity", "fsm_template_id", "Activites")
temp_activity_ids = fields.One2many("fsm.activity", "fsm_template_id", "Activities")
1 change: 0 additions & 1 deletion fieldservice_activity/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Steve Campbell <scampbells@opensourceintegrators.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Freni Patel <fpatel@opensourceintegrators.com>
Loading

0 comments on commit 5db7696

Please sign in to comment.