Skip to content
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
64 changes: 64 additions & 0 deletions sale_stock_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===================
Sale Stock Analytic
===================

Copies the analytic account of the sale order and the analytic tags of the sale order line to the stock move

Usage
=====

To use this module, you need to:

#. Go to your sale order
#. Set values for analytic tags on your sale order lines
#. Set value for analytic account on your sale order
#. Confirm sale order
#. ... and you should have your analytic account and analytic tags on your stock moves

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/87/13.0

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example

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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

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

* Benoit Aimont <[email protected]>
* Marcos Oitabén <[email protected]>

Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
1 change: 1 addition & 0 deletions sale_stock_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions sale_stock_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Sale Stock Analytic",
"summary": """
Copies the analytic account of the sale order and the analytic tags
of the sale order line to the stock move""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": ["sale_stock", "stock_analytic"],
}
37 changes: 37 additions & 0 deletions sale_stock_analytic/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-03-05 14:30+0000\n"
"Last-Translator: mymage <[email protected]>\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 5.10.2\n"

#. module: sale_stock_analytic
#: model:ir.model.fields,field_description:sale_stock_analytic.field_stock_rule__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: sale_stock_analytic
#: model:ir.model.fields,field_description:sale_stock_analytic.field_stock_rule__id
msgid "ID"
msgstr "ID"

#. module: sale_stock_analytic
#: model:ir.model.fields,field_description:sale_stock_analytic.field_stock_rule____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: sale_stock_analytic
#: model:ir.model,name:sale_stock_analytic.model_stock_rule
msgid "Stock Rule"
msgstr "Regola di giacenza"
34 changes: 34 additions & 0 deletions sale_stock_analytic/i18n/sale_stock_analytic.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: sale_stock_analytic
#: model:ir.model.fields,field_description:sale_stock_analytic.field_stock_rule__display_name
msgid "Display Name"
msgstr ""

#. module: sale_stock_analytic
#: model:ir.model.fields,field_description:sale_stock_analytic.field_stock_rule__id
msgid "ID"
msgstr ""

#. module: sale_stock_analytic
#: model:ir.model.fields,field_description:sale_stock_analytic.field_stock_rule____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_stock_analytic
#: model:ir.model,name:sale_stock_analytic.model_stock_rule
msgid "Stock Rule"
msgstr ""
1 change: 1 addition & 0 deletions sale_stock_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_rule
38 changes: 38 additions & 0 deletions sale_stock_analytic/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class StockRule(models.Model):
_inherit = "stock.rule"

def _get_stock_move_values(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
move_values = super()._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)
sol_id = move_values.get("sale_line_id", False)
if sol_id:
sol_model = self.env["sale.order.line"]
sol = sol_model.browse(sol_id)
analytic_distribution = sol.analytic_distribution
if analytic_distribution:
move_values.update({"analytic_distribution": analytic_distribution})
return move_values
3 changes: 3 additions & 0 deletions sale_stock_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"
Binary file added sale_stock_analytic/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sale_stock_analytic/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_sale_stock_analytic
41 changes: 41 additions & 0 deletions sale_stock_analytic/tests/test_sale_stock_analytic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestSaleStockAnalytic(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.sale_order_model = cls.env["sale.order"]
cls.sale_order_line_model = cls.env["sale.order.line"]
cls.product_model = cls.env["product.product"]
cls.res_partner_model = cls.env["res.partner"]

cls.partner = cls.res_partner_model.create({"name": "Partner test"})
cls.product = cls.product_model.create({"name": "Product test"})
cls.analytic_account = cls.env.ref("analytic.analytic_agrolait")

cls.sale_order = cls.sale_order_model.create(
{
"partner_id": cls.partner.id,
}
)
cls.sale_order_line = cls.sale_order_line_model.create(
{
"name": "sale order line test",
"order_id": cls.sale_order.id,
"product_id": cls.product.id,
"analytic_distribution": dict(
{str(cls.env.ref("analytic.analytic_agrolait").id): 100.0}
),
}
)

def test_sale_stock_analytic(self):
self.sale_order.action_confirm()
self.move = self.sale_order.picking_ids.move_ids_without_package
self.assertEqual(
self.move.analytic_distribution, self.sale_order_line.analytic_distribution
)
Loading