diff --git a/stock_request_analytic/README.rst b/stock_request_analytic/README.rst new file mode 100644 index 00000000..b580f5af --- /dev/null +++ b/stock_request_analytic/README.rst @@ -0,0 +1,100 @@ +====================== +Stock Request Analytic +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:175196e930c3236bff228d445f7062291596da1174a46d545e60dae2b8cfd442 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--request-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-request/tree/18.0/stock_request_analytic + :alt: OCA/stock-logistics-request +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-request-18-0/stock-logistics-request-18-0-stock_request_analytic + :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/stock-logistics-request&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows for users to be able to display and assign analytic +accounts to stock requests. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To create stock moves with a specific analytic distribution, assign an +analytic distribution to each stock request or set an analytic +distribution on the stock request order as a default value for new stock +requests on that order. + +Known issues / Roadmap +====================== + +- Integrate this module with stock_request_purchase to pass the analytic + account to the purchase order + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ForgeFlow + +Contributors +------------ + +- Aaron Henriquez +- Lois Rilo +- Pimolnat Suntian +- Alan Ramos +- Denis Roussel +- `Tecnativa `__: + + - João Marques + +- Stefan Rijnhart + +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. + +This module is part of the `OCA/stock-logistics-request `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_analytic/__init__.py b/stock_request_analytic/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_request_analytic/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_request_analytic/__manifest__.py b/stock_request_analytic/__manifest__.py new file mode 100644 index 00000000..93831972 --- /dev/null +++ b/stock_request_analytic/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2017-2020 ForgeFlow, S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Stock Request Analytic", + "summary": "Internal request for stock", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "website": "https://github.com/OCA/stock-logistics-request", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "category": "Analytic", + "depends": ["stock_request", "stock_analytic"], + "data": [ + "security/ir.model.access.csv", + "views/stock_request_views.xml", + "views/stock_request_order_views.xml", + ], + "installable": True, +} diff --git a/stock_request_analytic/i18n/es.po b/stock_request_analytic/i18n/es.po new file mode 100644 index 00000000..03fe94ee --- /dev/null +++ b/stock_request_analytic/i18n/es.po @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-27 14:09+0000\n" +"Last-Translator: Ivorra78 \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 4.17\n" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_account_analytic_account +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_account_id +msgid "Analytic Account" +msgstr "Cuenta analítica" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_account_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Accounts" +msgstr "Cuentas analíticas" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_count +msgid "Analytic Count" +msgstr "Conteo analítico" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_count +msgid "Analytic Tag Count" +msgstr "Recuento analítico de etiquetas" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_tag_ids +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Tags" +msgstr "Etiquetas Analíticas" + +#. module: stock_request_analytic +#: code:addons/stock_request_analytic/models/stock_request_order.py:0 +#, python-format +msgid "Analytic type (analytic_type) not present in the context" +msgstr "Tipo analítico (analytic_type) no presente en el contexto" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Default Analytic Account" +msgstr "Cuenta Analítica por defecto" + +#. module: stock_request_analytic +#: model:ir.model.fields,help:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Set this if you want to define a default analytic account on requests" +msgstr "" +"Seleccione esta opción si desea definir una cuenta analítica predeterminada " +"para las solicitudes" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request +msgid "Stock Request" +msgstr "Solicitud de existencias" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request_order +msgid "Stock Request Order" +msgstr "Solicitud de pedido de existencias" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_account_analytic_account__stock_request_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.view_account_analytic_account_form +msgid "Stock Requests" +msgstr "Solicitudes de existencias" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_rule +msgid "Stock Rule" +msgstr "Regla de existencias" diff --git a/stock_request_analytic/i18n/it.po b/stock_request_analytic/i18n/it.po new file mode 100644 index 00000000..918df7a4 --- /dev/null +++ b/stock_request_analytic/i18n/it.po @@ -0,0 +1,84 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-18 09:34+0000\n" +"Last-Translator: mymage \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.17\n" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_account_analytic_account +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_account_id +msgid "Analytic Account" +msgstr "Conto analitico" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_account_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Accounts" +msgstr "Conti analitici" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_count +msgid "Analytic Count" +msgstr "Conteggio analitico" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_count +msgid "Analytic Tag Count" +msgstr "Conteggio etichette analitiche" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_tag_ids +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Tags" +msgstr "Etichette analitiche" + +#. module: stock_request_analytic +#: code:addons/stock_request_analytic/models/stock_request_order.py:0 +#, python-format +msgid "Analytic type (analytic_type) not present in the context" +msgstr "Tipo analitico (analytic_type) non presente nel context" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Default Analytic Account" +msgstr "Conto analitico predefinito" + +#. module: stock_request_analytic +#: model:ir.model.fields,help:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Set this if you want to define a default analytic account on requests" +msgstr "" +"Impostare se si vuole definire un conto analitico predefinito nelle richieste" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request +msgid "Stock Request" +msgstr "Richiesta di magazzino" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request_order +msgid "Stock Request Order" +msgstr "Ordine richiesta di magazzino" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_account_analytic_account__stock_request_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.view_account_analytic_account_form +msgid "Stock Requests" +msgstr "Richieste di magazzino" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_rule +msgid "Stock Rule" +msgstr "Regola di giacenza" diff --git a/stock_request_analytic/i18n/pt_BR.po b/stock_request_analytic/i18n/pt_BR.po new file mode 100644 index 00000000..da0dd9fa --- /dev/null +++ b/stock_request_analytic/i18n/pt_BR.po @@ -0,0 +1,91 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-02-01 20:33+0000\n" +"Last-Translator: Rodrigo Macedo \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 4.3.2\n" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_account_analytic_account +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_account_id +msgid "Analytic Account" +msgstr "Conta Analítica" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_account_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Accounts" +msgstr "Contas Analíticas" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_count +msgid "Analytic Count" +msgstr "Contagem Analítica" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_count +msgid "Analytic Tag Count" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_tag_ids +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Tags" +msgstr "Etiquetas Analíticas" + +#. module: stock_request_analytic +#: code:addons/stock_request_analytic/models/stock_request_order.py:0 +#, python-format +msgid "Analytic type (analytic_type) not present in the context" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Default Analytic Account" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,help:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Set this if you want to define a default analytic account on requests" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request +msgid "Stock Request" +msgstr "Requisição de Estoque" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request_order +msgid "Stock Request Order" +msgstr "Ordens de Requisição de Estoque" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_account_analytic_account__stock_request_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.view_account_analytic_account_form +msgid "Stock Requests" +msgstr "Requisições de Estoque" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_rule +msgid "Stock Rule" +msgstr "Regras de Estoque" + +#, python-format +#~ msgid "" +#~ "You cannot link a analytic account to a stock request that belongs to " +#~ "another company." +#~ msgstr "" +#~ "Você não pode vincular uma conta analítica a uma requisição de estoque " +#~ "que pertence a outra empresa." diff --git a/stock_request_analytic/i18n/stock_request_analytic.pot b/stock_request_analytic/i18n/stock_request_analytic.pot new file mode 100644 index 00000000..f016021f --- /dev/null +++ b/stock_request_analytic/i18n/stock_request_analytic.pot @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_distribution +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_distribution +msgid "Analytic Distribution" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_distribution_search +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_distribution_search +msgid "Analytic Distribution Search" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_precision +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_precision +msgid "Analytic Precision" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__distribution_analytic_account_ids +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request +msgid "Stock Request" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request_order +msgid "Stock Request Order" +msgstr "" diff --git a/stock_request_analytic/i18n/zh_CN.po b/stock_request_analytic/i18n/zh_CN.po new file mode 100644 index 00000000..f08aef5f --- /dev/null +++ b/stock_request_analytic/i18n/zh_CN.po @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_request_analytic +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-10-16 15:58+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_account_analytic_account +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_account_id +msgid "Analytic Account" +msgstr "分析账户" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_account_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Accounts" +msgstr "分析账户" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_count +msgid "Analytic Count" +msgstr "分析数量" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_count +msgid "Analytic Tag Count" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request__analytic_tag_ids +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__analytic_tag_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.stock_request_order_form +msgid "Analytic Tags" +msgstr "" + +#. module: stock_request_analytic +#: code:addons/stock_request_analytic/models/stock_request_order.py:0 +#, python-format +msgid "Analytic type (analytic_type) not present in the context" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Default Analytic Account" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model.fields,help:stock_request_analytic.field_stock_request_order__default_analytic_account_id +msgid "Set this if you want to define a default analytic account on requests" +msgstr "" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request +msgid "Stock Request" +msgstr "库存请求" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_request_order +msgid "Stock Request Order" +msgstr "库存请求单" + +#. module: stock_request_analytic +#: model:ir.model.fields,field_description:stock_request_analytic.field_account_analytic_account__stock_request_ids +#: model_terms:ir.ui.view,arch_db:stock_request_analytic.view_account_analytic_account_form +msgid "Stock Requests" +msgstr "库存请求" + +#. module: stock_request_analytic +#: model:ir.model,name:stock_request_analytic.model_stock_rule +msgid "Stock Rule" +msgstr "库存规则" + +#, python-format +#~ msgid "" +#~ "You cannot link a analytic account to a stock request that belongs to " +#~ "another company." +#~ msgstr "您无法将分析帐户链接到属于另一家公司的库存请求。" diff --git a/stock_request_analytic/models/__init__.py b/stock_request_analytic/models/__init__.py new file mode 100644 index 00000000..3255e7eb --- /dev/null +++ b/stock_request_analytic/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_request +from . import stock_request_order diff --git a/stock_request_analytic/models/stock_request.py b/stock_request_analytic/models/stock_request.py new file mode 100644 index 00000000..bd58743b --- /dev/null +++ b/stock_request_analytic/models/stock_request.py @@ -0,0 +1,28 @@ +# Copyright 2017-2020 ForgeFlow, S.L. (https://www.forgeflow.com) +# Copyright 2021 Tecnativa - João Marques +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class StockRequest(models.Model): + _name = "stock.request" + _inherit = ["analytic.mixin", "stock.request"] + + analytic_distribution = fields.Json(compute="_compute_analytic_distribution") + + @api.depends("order_id") + def _compute_analytic_distribution(self): + """Set default analytic distribution on lines from order if defined""" + for req in self: + if req.order_id.analytic_distribution: + req.analytic_distribution = req.order_id.analytic_distribution + + def _prepare_procurement_values(self, group_id=False): + """ + Add analytic distribution to procurement values + """ + res = super()._prepare_procurement_values(group_id=group_id) + if self.analytic_distribution: + res.update({"analytic_distribution": self.analytic_distribution}) + return res diff --git a/stock_request_analytic/models/stock_request_order.py b/stock_request_analytic/models/stock_request_order.py new file mode 100644 index 00000000..fbe4108b --- /dev/null +++ b/stock_request_analytic/models/stock_request_order.py @@ -0,0 +1,9 @@ +# Copyright 2018 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class StockRequestOrder(models.Model): + _name = "stock.request.order" + _inherit = ["analytic.mixin", "stock.request.order"] diff --git a/stock_request_analytic/pyproject.toml b/stock_request_analytic/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/stock_request_analytic/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_request_analytic/readme/CONTRIBUTORS.md b/stock_request_analytic/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..f26924b6 --- /dev/null +++ b/stock_request_analytic/readme/CONTRIBUTORS.md @@ -0,0 +1,8 @@ +- Aaron Henriquez \<\> +- Lois Rilo \<\> +- Pimolnat Suntian \<\> +- Alan Ramos \<\> +- Denis Roussel \<\> +- [Tecnativa](https://www.tecnativa.com): + - João Marques +- Stefan Rijnhart \<\> diff --git a/stock_request_analytic/readme/DESCRIPTION.md b/stock_request_analytic/readme/DESCRIPTION.md new file mode 100644 index 00000000..259f4ba9 --- /dev/null +++ b/stock_request_analytic/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows for users to be able to display and assign analytic +accounts to stock requests. diff --git a/stock_request_analytic/readme/ROADMAP.md b/stock_request_analytic/readme/ROADMAP.md new file mode 100644 index 00000000..6f5c1faf --- /dev/null +++ b/stock_request_analytic/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- Integrate this module with stock_request_purchase to pass the analytic + account to the purchase order diff --git a/stock_request_analytic/readme/USAGE.md b/stock_request_analytic/readme/USAGE.md new file mode 100644 index 00000000..21d9255b --- /dev/null +++ b/stock_request_analytic/readme/USAGE.md @@ -0,0 +1,3 @@ +To create stock moves with a specific analytic distribution, assign an analytic +distribution to each stock request or set an analytic distribution on the stock +request order as a default value for new stock requests on that order. diff --git a/stock_request_analytic/security/ir.model.access.csv b/stock_request_analytic/security/ir.model.access.csv new file mode 100644 index 00000000..43a1348f --- /dev/null +++ b/stock_request_analytic/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_stock_request_analytic_user,stock.request analytic user,stock_request.model_stock_request,analytic.group_analytic_accounting,1,0,0,0 diff --git a/stock_request_analytic/static/description/icon.png b/stock_request_analytic/static/description/icon.png new file mode 100644 index 00000000..d4f6a65a Binary files /dev/null and b/stock_request_analytic/static/description/icon.png differ diff --git a/stock_request_analytic/static/description/index.html b/stock_request_analytic/static/description/index.html new file mode 100644 index 00000000..17fb19ed --- /dev/null +++ b/stock_request_analytic/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +Stock Request Analytic + + + +
+

Stock Request Analytic

+ + +

Beta License: AGPL-3 OCA/stock-logistics-request Translate me on Weblate Try me on Runboat

+

This module allows for users to be able to display and assign analytic +accounts to stock requests.

+

Table of contents

+ +
+

Usage

+

To create stock moves with a specific analytic distribution, assign an +analytic distribution to each stock request or set an analytic +distribution on the stock request order as a default value for new stock +requests on that order.

+
+
+

Known issues / Roadmap

+
    +
  • Integrate this module with stock_request_purchase to pass the analytic +account to the purchase order
  • +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

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.

+

This module is part of the OCA/stock-logistics-request project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_request_analytic/tests/__init__.py b/stock_request_analytic/tests/__init__.py new file mode 100644 index 00000000..fd35f0ff --- /dev/null +++ b/stock_request_analytic/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_request_analytic diff --git a/stock_request_analytic/tests/test_stock_request_analytic.py b/stock_request_analytic/tests/test_stock_request_analytic.py new file mode 100644 index 00000000..6403d35f --- /dev/null +++ b/stock_request_analytic/tests/test_stock_request_analytic.py @@ -0,0 +1,135 @@ +# Copyright 2017-2020 ForgeFlow, S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import Command, fields +from odoo.tests import Form, new_test_user +from odoo.tests.common import users + +from odoo.addons.base.tests.common import BaseCommon + + +class TestStockRequestAnalytic(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + + # Model + cls.AccountAnalyticAccount = cls.env["account.analytic.account"] + cls.ProductProduct = cls.env["product.product"] + cls.StockRequest = cls.env["stock.request"] + cls.StockRequestOrder = cls.env["stock.request.order"] + cls.StockLocation = cls.env["stock.location"] + cls.StockLocationRoute = cls.env["stock.route"] + cls.StockRule = cls.env["stock.rule"] + + # Data + cls.expected_date = fields.Datetime.now() + cls.main_company = cls.env.ref("base.main_company") + cls.warehouse = cls.env.ref("stock.warehouse0") + plan = cls.env["account.analytic.plan"].create({"name": __name__}) + analytic_account = cls.AccountAnalyticAccount.create( + {"name": "Analytic", "plan_id": plan.id} + ) + cls.analytic_distribution = {str(analytic_account.id): 100} + cls.demand_loc = cls.StockLocation.create( + { + "name": "demand_loc", + "location_id": cls.warehouse.lot_stock_id.id, + "usage": "internal", + } + ) + demand_route = cls.StockLocationRoute.create( + { + "name": "Transfer", + "product_categ_selectable": False, + "product_selectable": True, + "company_id": cls.main_company.id, + "sequence": 10, + } + ) + cls.StockRule.create( + { + "name": "Transfer", + "route_id": demand_route.id, + "location_src_id": cls.warehouse.lot_stock_id.id, + "location_dest_id": cls.demand_loc.id, + "action": "pull", + "picking_type_id": cls.warehouse.int_type_id.id, + "procure_method": "make_to_stock", + "warehouse_id": cls.warehouse.id, + "company_id": cls.main_company.id, + } + ) + cls.product = cls.ProductProduct.create( + { + "name": "Test Product", + "type": "service", + "is_storable": True, + "route_ids": [(6, 0, demand_route.ids)], + } + ) + cls.user = new_test_user( + cls.env, + login="stock_request_user", + groups=( + "stock_request.group_stock_request_user," + "analytic.group_analytic_accounting," + "stock.group_stock_user" + ), + ) + + def prepare_order_request_analytic(self, analytic_distribution, company): + vals = { + "company_id": company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.demand_loc.id, + "expected_date": self.expected_date, + "stock_request_ids": [ + Command.create( + { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "analytic_distribution": analytic_distribution, + "company_id": company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.demand_loc.id, + "expected_date": self.expected_date, + }, + ) + ], + } + return vals + + def test_stock_analytic(self): + vals = self.prepare_order_request_analytic( + self.analytic_distribution, + self.main_company, + ) + order = self.StockRequestOrder.create(vals) + req = order.stock_request_ids + order.action_confirm() + moves = req.move_ids + for mv in moves: + self.assertFalse(mv.analytic_distribution) + + @users("stock_request_user") + def test_default_analytic(self): + """ + Create request order with a default analytic + """ + vals = self.prepare_order_request_analytic(False, self.main_company) + vals.update( + { + "analytic_distribution": self.analytic_distribution, + } + ) + order = self.StockRequestOrder.with_user(self.user).create(vals) + with Form(order) as order_form: + with order_form.stock_request_ids.new() as line_form: + line_form.product_id = self.product + line_form.product_uom_qty = 5.0 + self.assertEqual( + line_form.analytic_distribution, + self.analytic_distribution, + ) diff --git a/stock_request_analytic/views/stock_request_order_views.xml b/stock_request_analytic/views/stock_request_order_views.xml new file mode 100644 index 00000000..49a1a3ec --- /dev/null +++ b/stock_request_analytic/views/stock_request_order_views.xml @@ -0,0 +1,26 @@ + + + + + stock.request.order.form - stock_request_analytic + stock.request.order + + + + + + + + + + + diff --git a/stock_request_analytic/views/stock_request_views.xml b/stock_request_analytic/views/stock_request_views.xml new file mode 100644 index 00000000..31ccf565 --- /dev/null +++ b/stock_request_analytic/views/stock_request_views.xml @@ -0,0 +1,19 @@ + + + + + stock.request.form + stock.request + + + + + + + +