Skip to content

Commit

Permalink
Merge commit 'refs/pull/509/head' of https://github.com/oca/account-a…
Browse files Browse the repository at this point in the history
…nalytic into 16.0-1400
  • Loading branch information
docker-odoo committed Feb 10, 2023
2 parents 6feebdb + ffab8b2 commit 71d666d
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 0 deletions.
62 changes: 62 additions & 0 deletions purchase_stock_analytic/README.rst
@@ -0,0 +1,62 @@
.. 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

=======================
Purchase Stock Analytic
=======================

Copies the analytic account of the purchase order item to the stock move

Usage
=====

To use this module, you need to:

#. Create a purchase order
#. Set an analytic account and analytic tags on purchase order lines
#. Confirm purchase 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/account-analytic/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 purchase_stock_analytic/__init__.py
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions purchase_stock_analytic/__manifest__.py
@@ -0,0 +1,13 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Purchase Stock Analytic",
"summary": """
Copies the analytic account of the purchase order item 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": ["purchase_stock", "stock_analytic"],
}
34 changes: 34 additions & 0 deletions purchase_stock_analytic/i18n/purchase_stock_analytic.pot
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_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: purchase_stock_analytic
#: model:ir.model.fields,field_description:purchase_stock_analytic.field_purchase_order_line__display_name
msgid "Display Name"
msgstr ""

#. module: purchase_stock_analytic
#: model:ir.model.fields,field_description:purchase_stock_analytic.field_purchase_order_line__id
msgid "ID"
msgstr ""

#. module: purchase_stock_analytic
#: model:ir.model.fields,field_description:purchase_stock_analytic.field_purchase_order_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: purchase_stock_analytic
#: model:ir.model,name:purchase_stock_analytic.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""
1 change: 1 addition & 0 deletions purchase_stock_analytic/models/__init__.py
@@ -0,0 +1 @@
from . import purchase_order_line
17 changes: 17 additions & 0 deletions purchase_stock_analytic/models/purchase_order_line.py
@@ -0,0 +1,17 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class PurchaseOrderLine(models.Model):

_inherit = "purchase.order.line"

def _prepare_stock_moves(self, picking):
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking)
for line in res:
analytic_distribution = self.analytic_distribution
if analytic_distribution:
line.update({"analytic_distribution": analytic_distribution})
return res
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 purchase_stock_analytic/tests/__init__.py
@@ -0,0 +1 @@
from . import test_purchase_stock_analytic
43 changes: 43 additions & 0 deletions purchase_stock_analytic/tests/test_purchase_stock_analytic.py
@@ -0,0 +1,43 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields
from odoo.tests.common import SavepointCase


class TestPurchaseStockAnalytic(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.purchase_order_model = cls.env["purchase.order"]
cls.purchase_order_line_model = cls.env["purchase.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.purchase_order = cls.purchase_order_model.create(
{"partner_id": cls.partner.id}
)
cls.purchase_order_line = cls.purchase_order_line_model.create(
{
"name": "purchase order line test",
"product_qty": 3,
"order_id": cls.purchase_order.id,
"price_unit": 20,
"product_id": cls.product.id,
"analytic_distribution": cls.analytic_distribution,
"date_planned": fields.Datetime.today(),
"product_uom": cls.product.uom_po_id.id,
}
)

def test_purchase_stock_analytic(self):
self.purchase_order.button_confirm()
self.move = self.purchase_order.picking_ids.move_ids_without_package
self.assertEqual(self.move.analytic_distribution, self.analytic_distribution)
6 changes: 6 additions & 0 deletions setup/purchase_stock_analytic/setup.py
@@ -0,0 +1,6 @@
import setuptools

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

0 comments on commit 71d666d

Please sign in to comment.