Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][ADD] fieldservice_sale_stock_product_tags: New module fieldservice_sale_stock_product_tags #1330

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions fieldservice_sale_stock_product_tags/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
=======================================
Field Service - Sale Stock Product Tags
=======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:daaa7c594ceadfc80161e693db3f2dfc9abaa08d866be5266f59d829096580d4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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_sale_stock_product_tags
: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_sale_stock_product_tags
: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=15.0
:alt: Try me on Runboat

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

This module extends Field Service (FSM) functionality by automatically assigning FSM tags to orders based on product template tags.

**Features:**
- Automatically assigns FSM tags to open FSM orders based on products in linked stock moves.
- Ensures missing FSM tags are created dynamically.
- Supports manual tag assignment without being overwritten.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Navigate to **Field Service > Master Data > Products**.
2. Select a product or create a new one.
3. In the **General Information** tab, add a tag in the **Tags** field.
4. Navigate to **Sales**.
5. Create a new sale, add the product, and confirm it.
6. The linked FSM order will have the tag assigned automatically.
7. If no FSM tag matches the product tag, a new one will be created with the same name and color.

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_sale_stock_product_tags%0Aversion:%2015.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
~~~~~~~

* APSL-Nagarro

Contributors
~~~~~~~~~~~~

* `APSL-Nagarro <https://www.apsl.tech>`_:
* Patryk Pyczko <ppyczko@apsl.net>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-ppyczko| image:: https://github.com/ppyczko.png?size=40px
:target: https://github.com/ppyczko
:alt: ppyczko

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ppyczko|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions fieldservice_sale_stock_product_tags/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
16 changes: 16 additions & 0 deletions fieldservice_sale_stock_product_tags/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2025 Patryk Pyczko (APSL-Nagarro)<ppyczko@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Field Service - Sale Stock Product Tags",
"version": "15.0.1.0.0",
"summary": "Automatically assigns FSM tags to FSM orders based on product template tags.",
"category": "Field Service",
"website": "https://github.com/OCA/field-service",
"author": "APSL-Nagarro, Odoo Community Association (OCA)",
"maintainers": ["ppyczko"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["fieldservice_sale_stock", "product_template_tags"],
}
31 changes: 31 additions & 0 deletions fieldservice_sale_stock_product_tags/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * fieldservice_sale_stock_product_tags
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-18 11:27+0000\n"
"PO-Revision-Date: 2025-03-18 11:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model.fields,help:fieldservice_sale_stock_product_tags.field_fsm_order__tag_ids
msgid "Classify and analyze your orders"
msgstr "Classifica i analitza les teves comandes"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model,name:fieldservice_sale_stock_product_tags.model_fsm_order
msgid "Field Service Order"
msgstr "Ordre de Servei de Camp"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model.fields,field_description:fieldservice_sale_stock_product_tags.field_fsm_order__tag_ids
msgid "Tags"
msgstr "Etiquetes"
31 changes: 31 additions & 0 deletions fieldservice_sale_stock_product_tags/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * fieldservice_sale_stock_product_tags
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-18 11:27+0000\n"
"PO-Revision-Date: 2025-03-18 11:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model.fields,help:fieldservice_sale_stock_product_tags.field_fsm_order__tag_ids
msgid "Classify and analyze your orders"
msgstr "Clasifica y analiza tus pedidos"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model,name:fieldservice_sale_stock_product_tags.model_fsm_order
msgid "Field Service Order"
msgstr "Orden de Servicio de Campo"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model.fields,field_description:fieldservice_sale_stock_product_tags.field_fsm_order__tag_ids
msgid "Tags"
msgstr "Etiquetas"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * fieldservice_sale_stock_product_tags
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-18 11:25+0000\n"
"PO-Revision-Date: 2025-03-18 11:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model.fields,help:fieldservice_sale_stock_product_tags.field_fsm_order__tag_ids
msgid "Classify and analyze your orders"
msgstr ""

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model,name:fieldservice_sale_stock_product_tags.model_fsm_order
msgid "Field Service Order"
msgstr ""

#. module: fieldservice_sale_stock_product_tags
#: model:ir.model.fields,field_description:fieldservice_sale_stock_product_tags.field_fsm_order__tag_ids
msgid "Tags"
msgstr ""
3 changes: 3 additions & 0 deletions fieldservice_sale_stock_product_tags/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import fsm_order
42 changes: 42 additions & 0 deletions fieldservice_sale_stock_product_tags/models/fsm_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2025 Patryk Pyczko (APSL-Nagarro)<ppyczko@apsl.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class FSMOrder(models.Model):
_inherit = "fsm.order"

tag_ids = fields.Many2many(
"fsm.tag",
"fsm_order_tag_rel",
"fsm_order_id",
"tag_id",
string="Tags",
compute="_compute_fsm_tags",
inverse="_inverse_fsm_tags",
store=True,
help="Classify and analyze your orders",
)

@api.depends("move_ids.product_id.tag_ids")
def _compute_fsm_tags(self):
FSMTag = self.env["fsm.tag"]
active_orders = self.filtered(lambda o: not o.stage_id.is_closed)

for order in active_orders:
product_tags = order.move_ids.mapped("product_id.tag_ids")

auto_tags = FSMTag.search([("name", "in", product_tags.mapped("name"))])
missing_tags = product_tags.filtered(
lambda tag: tag.name not in auto_tags.mapped("name")
)

auto_tags |= FSMTag.create(
[{"name": tag.name, "color": tag.color or 10} for tag in missing_tags]
)

order.tag_ids |= auto_tags

def _inverse_fsm_tags(self):
pass
2 changes: 2 additions & 0 deletions fieldservice_sale_stock_product_tags/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* `APSL-Nagarro <https://www.apsl.tech>`_:
* Patryk Pyczko <ppyczko@apsl.net>
6 changes: 6 additions & 0 deletions fieldservice_sale_stock_product_tags/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module extends Field Service (FSM) functionality by automatically assigning FSM tags to orders based on product template tags.

**Features:**
- Automatically assigns FSM tags to open FSM orders based on products in linked stock moves.
- Ensures missing FSM tags are created dynamically.
- Supports manual tag assignment without being overwritten.
9 changes: 9 additions & 0 deletions fieldservice_sale_stock_product_tags/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To use this module, you need to:

1. Navigate to **Field Service > Master Data > Products**.
2. Select a product or create a new one.
3. In the **General Information** tab, add a tag in the **Tags** field.
4. Navigate to **Sales**.
5. Create a new sale, add the product, and confirm it.
6. The linked FSM order will have the tag assigned automatically.
7. If no FSM tag matches the product tag, a new one will be created with the same name and color.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading