Skip to content

Commit

Permalink
Merge commit 'refs/pull/511/head' of https://github.com/oca/account-a…
Browse files Browse the repository at this point in the history
…nalytic into 16.0-3113
  • Loading branch information
docker-odoo committed Jul 25, 2023
2 parents f1835d1 + 2952ea3 commit 3dab62a
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 0 deletions.
63 changes: 63 additions & 0 deletions sale_stock_analytic/README.rst
@@ -0,0 +1,63 @@
.. 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 <benoit.aimont@acsone.eu>

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
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions sale_stock_analytic/__manifest__.py
@@ -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": "16.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"],
}
34 changes: 34 additions & 0 deletions sale_stock_analytic/i18n/sale_stock_analytic.pot
@@ -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
@@ -0,0 +1 @@
from . import stock_rule
39 changes: 39 additions & 0 deletions sale_stock_analytic/models/stock_rule.py
@@ -0,0 +1,39 @@
# 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(StockRule, self)._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
Binary file added sale_stock_analytic/static/description/icon.png
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
@@ -0,0 +1 @@
from . import test_sale_stock_analytic
39 changes: 39 additions & 0 deletions sale_stock_analytic/tests/test_sale_stock_analytic.py
@@ -0,0 +1,39 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import SavepointCase


class TestSaleStockAnalytic(SavepointCase):
@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_distribution = dict(
{str(cls.env.ref("analytic.analytic_agrolait").id): 100.0}
)

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": cls.analytic_distribution,
}
)

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.analytic_distribution)
1 change: 1 addition & 0 deletions setup/sale_stock_analytic/odoo/addons/sale_stock_analytic
6 changes: 6 additions & 0 deletions setup/sale_stock_analytic/setup.py
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 3dab62a

Please sign in to comment.