diff --git a/fieldservice_stock_account_analytic/README.rst b/fieldservice_stock_account_analytic/README.rst new file mode 100644 index 0000000000..de41e57aee --- /dev/null +++ b/fieldservice_stock_account_analytic/README.rst @@ -0,0 +1,125 @@ +=========================================== +Field Service - Stock - Analytic Accounting +=========================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/12.0/fieldservice_stock_account_analytic + :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-12-0/field-service-12-0-fieldservice_stock_account_analytic + :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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to report on the stock output account by analytic account. + +It uses the analytic account of the field service location to set the +analytic account on the deliveries. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +FSM Location +~~~~~~~~~~~~ + +* Go to Field Service > Master data > Locations +* Create or select a location +* Check that the inventory location is a Customer location +* Go to the Accounting tab +* Set the analytic account + +FSM Order +~~~~~~~~~ + +* Go to Field Service +* Create or select an order +* Select the location +* Go to the Inventory tab to add some products and submit the stock requests + +Inventory +~~~~~~~~~ + +* Go to Inventory > Stock Request Orders > X to process +* Open the stock request order related to your Field Service order +* Set the route on the lines and confirm it +* Process the transfers + +Accounting +~~~~~~~~~~ + +* Go to Accounting > Adviser > Analytic Entries + +Known issues / Roadmap +====================== + +The roadmap of the Field Service application is documented on +`Github `_. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* `Open Source Integrators `_ + + * Maxime Chambreuil + +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-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainer `__: + +|maintainer-max3903| + +This module is part of the `OCA/field-service `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fieldservice_stock_account_analytic/__init__.py b/fieldservice_stock_account_analytic/__init__.py new file mode 100644 index 0000000000..33c2f06eff --- /dev/null +++ b/fieldservice_stock_account_analytic/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2019 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/fieldservice_stock_account_analytic/__manifest__.py b/fieldservice_stock_account_analytic/__manifest__.py new file mode 100644 index 0000000000..c38ac603e2 --- /dev/null +++ b/fieldservice_stock_account_analytic/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Field Service - Stock - Analytic Accounting", + "summary": "Track costs of delivered items with analytic accounting", + "license": "AGPL-3", + "version": "14.0.1.0.0", + "category": "Field Service", + "author": "Open Source Integrators, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/field-service", + "depends": [ + "fieldservice_account_analytic", + "fieldservice_stock_account", + "stock_request_analytic", + ], + "development_status": "Beta", + "maintainers": ["max3903"], +} diff --git a/fieldservice_stock_account_analytic/i18n/de.po b/fieldservice_stock_account_analytic/i18n/de.po new file mode 100644 index 0000000000..c36d8fc687 --- /dev/null +++ b/fieldservice_stock_account_analytic/i18n/de.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stock_account_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-11-26 11:58+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: none\n" +"Language: de\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 3.8\n" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_fsm_order +msgid "Field Service Order" +msgstr "Field-Service-Auftrag" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_stock_request +msgid "Stock Request" +msgstr "" diff --git a/fieldservice_stock_account_analytic/i18n/es.po b/fieldservice_stock_account_analytic/i18n/es.po new file mode 100644 index 0000000000..f1eb39dd50 --- /dev/null +++ b/fieldservice_stock_account_analytic/i18n/es.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stock_account_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-12-14 16:05+0000\n" +"Last-Translator: Nelson Ramírez Sánchez \n" +"Language-Team: none\n" +"Language: es\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 3.9.1\n" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_fsm_order +msgid "Field Service Order" +msgstr "Pedido de Servicio de Campo" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_stock_request +msgid "Stock Request" +msgstr "Solicitud de Stock" diff --git a/fieldservice_stock_account_analytic/i18n/es_CL.po b/fieldservice_stock_account_analytic/i18n/es_CL.po new file mode 100644 index 0000000000..a6edb04241 --- /dev/null +++ b/fieldservice_stock_account_analytic/i18n/es_CL.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stock_account_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-12-14 16:05+0000\n" +"Last-Translator: Nelson Ramírez Sánchez \n" +"Language-Team: none\n" +"Language: es_CL\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 3.9.1\n" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_fsm_order +msgid "Field Service Order" +msgstr "Pedido de Servicio de Campo" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_stock_request +msgid "Stock Request" +msgstr "Solicitud de Stock" diff --git a/fieldservice_stock_account_analytic/i18n/fieldservice_stock_account_analytic.pot b/fieldservice_stock_account_analytic/i18n/fieldservice_stock_account_analytic.pot new file mode 100644 index 0000000000..fa5f317794 --- /dev/null +++ b/fieldservice_stock_account_analytic/i18n/fieldservice_stock_account_analytic.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stock_account_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \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_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_fsm_order +msgid "Field Service Order" +msgstr "" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_stock_request +msgid "Stock Request" +msgstr "" + diff --git a/fieldservice_stock_account_analytic/i18n/pt_BR.po b/fieldservice_stock_account_analytic/i18n/pt_BR.po new file mode 100644 index 0000000000..2691700502 --- /dev/null +++ b/fieldservice_stock_account_analytic/i18n/pt_BR.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stock_account_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-02-05 11:13+0000\n" +"Last-Translator: Marcel Savegnago \n" +"Language-Team: none\n" +"Language: pt_BR\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 3.10\n" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_fsm_order +msgid "Field Service Order" +msgstr "Ordem de Serviço de Campo" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_stock_request +msgid "Stock Request" +msgstr "Requisição de Estoque" diff --git a/fieldservice_stock_account_analytic/i18n/pt_PT.po b/fieldservice_stock_account_analytic/i18n/pt_PT.po new file mode 100644 index 0000000000..e5e43a4f89 --- /dev/null +++ b/fieldservice_stock_account_analytic/i18n/pt_PT.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * fieldservice_stock_account_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-02 00:19+0000\n" +"Last-Translator: Daniel Reis \n" +"Language-Team: none\n" +"Language: pt_PT\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 3.10\n" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_fsm_order +msgid "Field Service Order" +msgstr "Ordem de Serviço de Campo" + +#. module: fieldservice_stock_account_analytic +#: model:ir.model,name:fieldservice_stock_account_analytic.model_stock_request +msgid "Stock Request" +msgstr "Requisição de Stock" diff --git a/fieldservice_stock_account_analytic/models/__init__.py b/fieldservice_stock_account_analytic/models/__init__.py new file mode 100644 index 0000000000..7d2d28e818 --- /dev/null +++ b/fieldservice_stock_account_analytic/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_request +from . import fsm_order diff --git a/fieldservice_stock_account_analytic/models/fsm_order.py b/fieldservice_stock_account_analytic/models/fsm_order.py new file mode 100644 index 0000000000..4c78603199 --- /dev/null +++ b/fieldservice_stock_account_analytic/models/fsm_order.py @@ -0,0 +1,17 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class FSMOrder(models.Model): + _inherit = "fsm.order" + + def _prepare_inv_line_for_stock_request(self, stock_request, invoice=False): + vals = super()._prepare_inv_line_for_stock_request(stock_request, invoice) + vals.update( + { + "analytic_account_id": self.location_id.analytic_account_id.id, + } + ) + return vals diff --git a/fieldservice_stock_account_analytic/models/stock_request.py b/fieldservice_stock_account_analytic/models/stock_request.py new file mode 100644 index 0000000000..28a068f632 --- /dev/null +++ b/fieldservice_stock_account_analytic/models/stock_request.py @@ -0,0 +1,17 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class StockRequest(models.Model): + _inherit = "stock.request" + + @api.model + def create(self, vals): + if vals.get("fsm_order_id"): + fsm_order = self.env["fsm.order"].browse(vals.get("fsm_order_id")) + vals.update( + {"analytic_account_id": fsm_order.location_id.analytic_account_id.id} + ) + return super().create(vals) diff --git a/fieldservice_stock_account_analytic/readme/CONTRIBUTORS.rst b/fieldservice_stock_account_analytic/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..bd2fd4aef4 --- /dev/null +++ b/fieldservice_stock_account_analytic/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Open Source Integrators `_ + + * Maxime Chambreuil diff --git a/fieldservice_stock_account_analytic/readme/DESCRIPTION.rst b/fieldservice_stock_account_analytic/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..30bbe94c77 --- /dev/null +++ b/fieldservice_stock_account_analytic/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module allows you to report on the stock output account by analytic account. + +It uses the analytic account of the field service location to set the +analytic account on the deliveries. diff --git a/fieldservice_stock_account_analytic/readme/ROADMAP.rst b/fieldservice_stock_account_analytic/readme/ROADMAP.rst new file mode 100644 index 0000000000..f607015959 --- /dev/null +++ b/fieldservice_stock_account_analytic/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +The roadmap of the Field Service application is documented on +`Github `_. diff --git a/fieldservice_stock_account_analytic/readme/USAGE.rst b/fieldservice_stock_account_analytic/readme/USAGE.rst new file mode 100644 index 0000000000..0f940ea200 --- /dev/null +++ b/fieldservice_stock_account_analytic/readme/USAGE.rst @@ -0,0 +1,29 @@ +FSM Location +~~~~~~~~~~~~ + +* Go to Field Service > Master data > Locations +* Create or select a location +* Check that the inventory location is a Customer location +* Go to the Accounting tab +* Set the analytic account + +FSM Order +~~~~~~~~~ + +* Go to Field Service +* Create or select an order +* Select the location +* Go to the Inventory tab to add some products and submit the stock requests + +Inventory +~~~~~~~~~ + +* Go to Inventory > Stock Request Orders > X to process +* Open the stock request order related to your Field Service order +* Set the route on the lines and confirm it +* Process the transfers + +Accounting +~~~~~~~~~~ + +* Go to Accounting > Adviser > Analytic Entries diff --git a/fieldservice_stock_account_analytic/static/description/icon.png b/fieldservice_stock_account_analytic/static/description/icon.png new file mode 100644 index 0000000000..955674d8f0 Binary files /dev/null and b/fieldservice_stock_account_analytic/static/description/icon.png differ diff --git a/fieldservice_stock_account_analytic/static/description/index.html b/fieldservice_stock_account_analytic/static/description/index.html new file mode 100644 index 0000000000..9245b14d3a --- /dev/null +++ b/fieldservice_stock_account_analytic/static/description/index.html @@ -0,0 +1,476 @@ + + + + + + +Field Service - Stock - Analytic Accounting + + + +
+

Field Service - Stock - Analytic Accounting

+ + +

Beta License: AGPL-3 OCA/field-service Translate me on Weblate Try me on Runbot

+

This module allows you to report on the stock output account by analytic account.

+

It uses the analytic account of the field service location to set the +analytic account on the deliveries.

+

Table of contents

+ +
+

Usage

+
+

FSM Location

+
    +
  • Go to Field Service > Master data > Locations
  • +
  • Create or select a location
  • +
  • Check that the inventory location is a Customer location
  • +
  • Go to the Accounting tab
  • +
  • Set the analytic account
  • +
+
+
+

FSM Order

+
    +
  • Go to Field Service
  • +
  • Create or select an order
  • +
  • Select the location
  • +
  • Go to the Inventory tab to add some products and submit the stock requests
  • +
+
+
+

Inventory

+
    +
  • Go to Inventory > Stock Request Orders > X to process
  • +
  • Open the stock request order related to your Field Service order
  • +
  • Set the route on the lines and confirm it
  • +
  • Process the transfers
  • +
+
+
+

Accounting

+
    +
  • Go to Accounting > Adviser > Analytic Entries
  • +
+
+
+
+

Known issues / Roadmap

+

The roadmap of the Field Service application is documented on +Github.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

max3903

+

This module is part of the OCA/field-service project on GitHub.

+

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

+
+
+
+ + diff --git a/fieldservice_stock_account_analytic/tests/__init__.py b/fieldservice_stock_account_analytic/tests/__init__.py new file mode 100644 index 0000000000..29c8f1c684 --- /dev/null +++ b/fieldservice_stock_account_analytic/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2022 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import test_fsm_stock_account_analytic diff --git a/fieldservice_stock_account_analytic/tests/test_fsm_stock_account_analytic.py b/fieldservice_stock_account_analytic/tests/test_fsm_stock_account_analytic.py new file mode 100644 index 0000000000..bbd2c68622 --- /dev/null +++ b/fieldservice_stock_account_analytic/tests/test_fsm_stock_account_analytic.py @@ -0,0 +1,60 @@ +# Copyright (C) 2022 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +import datetime + +from odoo.tests.common import TransactionCase + + +class FSMStockAccountAnalyticCase(TransactionCase): + def setUp(self): + super(FSMStockAccountAnalyticCase, self).setUp() + self.fsm_order = self.env["fsm.order"] + self.test_location = self.env.ref("fieldservice.test_location") + self.inv_location = self.env.ref("stock.stock_location_customers") + self.test_person = self.env.ref("fieldservice.test_person") + self.test_partner = self.env.ref("fieldservice.test_partner") + self.analytic_model = self.env["account.analytic.account"] + self.analytic = self.analytic_model.create({"name": "Test"}) + + def test_fsm_order(self): + self.test_person.partner_id.supplier_rank = 1 + self.test_location.inventory_location_id = self.inv_location.id + self.test_location.analytic_account_id = self.analytic.id + fsm_order = self.fsm_order.create( + {"location_id": self.test_location.id, "person_id": self.test_person.id} + ) + + self.env["stock.picking.type"].create( + { + "name": "Stock Request wh", + "sequence_id": self.env.ref("stock_request.seq_stock_request_order").id, + "code": "stock_request_order", + "sequence_code": "SRO", + "warehouse_id": fsm_order.warehouse_id.id, + } + ) + self.product_1 = self.env["product.product"].create( + { + "name": "Product 1", + "type": "product", + "categ_id": self.env.ref("product.product_category_all").id, + } + ) + SR_1 = self.env["stock.request"].create( + { + "warehouse_id": fsm_order.warehouse_id.id, + "location_id": fsm_order.inventory_location_id.id, + "product_id": self.product_1.id, + "product_uom_qty": 1, + "product_uom_id": self.product_1.uom_id.id, + "fsm_order_id": fsm_order.id, + "direction": "outbound", + "expected_date": datetime.datetime.now(), + "picking_policy": "direct", + } + ) + fsm_order.stock_request_ids = [(6, 0, SR_1.ids)] + fsm_order.action_request_submit() + SR_1.action_confirm() + fsm_order.account_create_invoice() diff --git a/setup/fieldservice_stock_account_analytic/odoo/addons/fieldservice_stock_account_analytic b/setup/fieldservice_stock_account_analytic/odoo/addons/fieldservice_stock_account_analytic new file mode 120000 index 0000000000..45f8ce8375 --- /dev/null +++ b/setup/fieldservice_stock_account_analytic/odoo/addons/fieldservice_stock_account_analytic @@ -0,0 +1 @@ +../../../../fieldservice_stock_account_analytic \ No newline at end of file diff --git a/setup/fieldservice_stock_account_analytic/setup.py b/setup/fieldservice_stock_account_analytic/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fieldservice_stock_account_analytic/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)