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

[17.0][mig] stock_picking_analytic #628

Closed
wants to merge 17 commits into from
Closed
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
81 changes: 81 additions & 0 deletions stock_picking_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
======================
Stock Picking Analytic
======================

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

.. |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%2Faccount--analytic-lightgray.png?logo=github
:target: https://github.com/OCA/account-analytic/tree/17.0/stock_picking_analytic
:alt: OCA/account-analytic
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-analytic-17-0/account-analytic-17-0-stock_picking_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/account-analytic&target_branch=17.0
:alt: Try me on Runboat

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

Allows to define the analytic distribution on picking level, which
should propagate the value to the corresponding field of stock moves.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/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/account-analytic/issues/new?body=module:%20stock_picking_analytic%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
-------

* ACSONE SA/NV

Contributors
------------

- Benoît Aimont <[email protected]>
- Denis Roussel <[email protected]>
- `Quartile <https://www.quartile.co>`__:

- Yoshi Tashiro

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/account-analytic <https://github.com/OCA/account-analytic/tree/17.0/stock_picking_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_picking_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions stock_picking_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Stock Picking Analytic",
"summary": """
Allows to define the analytic account on picking level""",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": [
"stock_analytic",
"base_view_inheritance_extension",
],
"data": [
"views/stock_picking.xml",
],
}
56 changes: 56 additions & 0 deletions stock_picking_analytic/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-09-21 15:39+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\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_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_distribution
msgid "Analytic"
msgstr "Analítica"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_distribution_search
msgid "Analytic Distribution Search"
msgstr "Búsqueda de Distribución Analítica"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_precision
msgid "Analytic Precision"
msgstr "Precisión Analítica"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__original_analytic_distribution
msgid "Original Analytic Distribution"
msgstr "Distribución Analítica Original"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__move_ids_without_package
msgid "Stock moves not in package"
msgstr "Las acciones no se mueven en el paquete"

#. module: stock_picking_analytic
#: model:ir.model.fields,help:stock_picking_analytic.field_stock_picking__original_analytic_distribution
msgid ""
"Technical field. Use to store the value ofanalytic_distribution if there is "
"no lines"
msgstr ""
"Campo técnico. Úselo para almacenar el valor de distribución_analítica si no "
"hay líneas"

#. module: stock_picking_analytic
#: model:ir.model,name:stock_picking_analytic.model_stock_picking
msgid "Transfer"
msgstr "Transferencia"
56 changes: 56 additions & 0 deletions stock_picking_analytic/i18n/pt_BR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-26 14:37+0000\n"
"Last-Translator: Adriano Prado <[email protected]>\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.17\n"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_distribution
msgid "Analytic"
msgstr "Analítico"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_distribution_search
msgid "Analytic Distribution Search"
msgstr "Pesquisa de Distribuição Analítica"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_precision
msgid "Analytic Precision"
msgstr "Precisão Analítica"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__original_analytic_distribution
msgid "Original Analytic Distribution"
msgstr "Distribuição Analítica Original"

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__move_ids_without_package
msgid "Stock moves not in package"
msgstr "Movimentos de estoque fora do pacote"

#. module: stock_picking_analytic
#: model:ir.model.fields,help:stock_picking_analytic.field_stock_picking__original_analytic_distribution
msgid ""
"Technical field. Use to store the value ofanalytic_distribution if there is "
"no lines"
msgstr ""
"Campo técnico. Use para armazenar o valor de distribuição_analítica se não "
"houver linhas"

#. module: stock_picking_analytic
#: model:ir.model,name:stock_picking_analytic.model_stock_picking
msgid "Transfer"
msgstr "Transferir"
51 changes: 51 additions & 0 deletions stock_picking_analytic/i18n/stock_picking_analytic.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_distribution
msgid "Analytic"
msgstr ""

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_distribution_search
msgid "Analytic Distribution Search"
msgstr ""

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__analytic_precision
msgid "Analytic Precision"
msgstr ""

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__original_analytic_distribution
msgid "Original Analytic Distribution"
msgstr ""

#. module: stock_picking_analytic
#: model:ir.model.fields,field_description:stock_picking_analytic.field_stock_picking__move_ids_without_package
msgid "Stock moves not in package"
msgstr ""

#. module: stock_picking_analytic
#: model:ir.model.fields,help:stock_picking_analytic.field_stock_picking__original_analytic_distribution
msgid ""
"Technical field. Use to store the value ofanalytic_distribution if there is "
"no lines"
msgstr ""

#. module: stock_picking_analytic
#: model:ir.model,name:stock_picking_analytic.model_stock_picking
msgid "Transfer"
msgstr ""
1 change: 1 addition & 0 deletions stock_picking_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking
62 changes: 62 additions & 0 deletions stock_picking_analytic/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2021 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class StockPicking(models.Model):
_name = "stock.picking"
_inherit = ["stock.picking", "analytic.mixin"]

original_analytic_distribution = fields.Json(
help="Technical field. Use to store the value of"
"analytic_distribution if there is no lines",
)
analytic_distribution = fields.Json(
inverse="_inverse_analytic_distribution",
states={
"done": [("readonly", True)],
"cancel": [("readonly", True)],
},
)
# Assign a dummy search arg to the field to avoid triggering the warning.
# Without this, use of move_ids_without_package in @api.depends() of the compute
# method would trigger a warning from
# https://github.com/odoo/odoo/blob/0f84366/odoo/fields.py#L808-L812
# pylint: disable=method-search
move_ids_without_package = fields.One2many(search="[]")

# We use move_ids_without_package instead of move_ids throughout this method to
# guarantee consistent behavior. i.e. the value of move_ids is available only after
# the record has been saved.
@api.depends(
"move_ids_without_package.analytic_distribution",
"original_analytic_distribution",
)
def _compute_analytic_distribution(self):
"""
Get analytic account from first move and put it on picking
"""
for picking in self:
analytic_distribution = picking.original_analytic_distribution
if picking.move_ids_without_package:
analytic_distribution = picking.move_ids_without_package[
0
].analytic_distribution
if any(
move.analytic_distribution != analytic_distribution
for move in picking.move_ids_without_package
):
analytic_distribution = False
picking.analytic_distribution = analytic_distribution

def _inverse_analytic_distribution(self):
"""
If analytic distribution is set on picking, write it on all moves
"""
for picking in self:
if picking.analytic_distribution:
picking.move_ids_without_package.write(
{"analytic_distribution": picking.analytic_distribution}
)
picking.original_analytic_distribution = picking.analytic_distribution
3 changes: 3 additions & 0 deletions stock_picking_analytic/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions stock_picking_analytic/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Benoît Aimont \<<[email protected]>\>
- Denis Roussel \<<[email protected]>\>
- [Quartile](https://www.quartile.co):
- Yoshi Tashiro
2 changes: 2 additions & 0 deletions stock_picking_analytic/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Allows to define the analytic distribution on picking level, which
should propagate the value to the corresponding field of stock moves.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading