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]sale_stock_analytic: Migration to 17.0 #617

Open
wants to merge 57 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
098ae42
migration to v7
Jun 7, 2013
3306b13
merge with mathieu
yvanpatry Jun 13, 2013
2be3ced
update for migration V7
Pierre-Monod Jun 13, 2013
6bb9de6
add images
Aug 14, 2013
c725d52
update for wilog v7.0
Pierre-Monod Sep 3, 2013
58248fa
Add contract customer invoice and migrate [IMP] SMS erase print [IMP]…
yvanpatry Sep 3, 2013
3dd157b
 - change the logo of all modules
mathieuvatel Mar 18, 2014
894d517
- Added new module stock_analytic
fv-clearcorp Nov 19, 2015
5f46632
Adapt original module according OCA Standard
andhit-r Feb 5, 2016
9b07f25
[MIG]stock_analytic to v9
AaronHForgeFlow Apr 3, 2017
deb3cdf
[MIG]stock_analytic to v10
AaronHForgeFlow Jun 28, 2017
cf00ab4
11.0 MIG stock_analytic
jaredkipe Mar 19, 2018
5bafae3
Add the ability to pick Analytic account on picking form.
jaredkipe Oct 30, 2018
8f22389
Translated using Weblate (German)
rschnapka Jan 21, 2019
20a5997
[MIG]stock_analytic to v12
AaronHForgeFlow Jan 30, 2019
a47c513
[MIG] Updated the tests of the module stock_analytic.
Jun 13, 2019
59dc3b2
Translated using Weblate (Portuguese (Brazil))
marcelsavegnago Aug 2, 2019
2aa857a
Translated using Weblate (Catalan)
Oct 7, 2019
3d1ecab
[12.0] [FIX] Wrong runbot link in readme
Jerther Oct 15, 2019
01a89fe
[12.0] [FIX] stock_analytic: Analytic account field is in wrong page
Jerther Oct 16, 2019
a95b083
Translated using Weblate (Croatian)
badbole Nov 13, 2019
1e8c50e
[IMP] stock_analytic: Add analytic account to scrap
max3903 Nov 20, 2019
bdd3250
Translated using Weblate (German)
marylla Jan 29, 2020
9609bc1
Translated using Weblate (Portuguese)
alvarorib Feb 18, 2020
47a1947
Translated using Weblate (Spanish)
ruthbeat Mar 2, 2020
102f32f
[FIX] Apply analytic account on COGS account when booking customer in…
Feb 4, 2020
1a54a6d
[IMP] stock_analytic: black, isort
jimhoefnagels Mar 24, 2020
6e456d9
[MIG] stock_analytic: Migration to 13.0
jimhoefnagels Mar 24, 2020
b35d6c6
stock_analytic 12.0.1.1.2
jimhoefnagels May 11, 2020
fd8a222
[IMP] stock_analytic: black, isort
jimhoefnagels May 11, 2020
681f0b4
[MIG] stock_analytic: Migration to 13.0
jimhoefnagels May 11, 2020
00ec9b1
Translated using Weblate (Portuguese (Brazil))
Aug 12, 2020
9d77082
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Sep 30, 2020
e75f6d0
[13.0][IMP] stock_analytic - add analytic tags on stock move
baimont Nov 9, 2020
fe6dfda
[IMP] stock_analytic: black, isort, prettier
alan196 Jan 28, 2021
d50e4cd
[MIG] stock_analytic: Migration to 14.0
alan196 Jan 28, 2021
567503e
[14.0][IMP] stock_analytic: Transmit analytic account to new moves
rousseldenis Nov 26, 2021
e410fba
Translated using Weblate (Portuguese (Brazil))
Feb 1, 2022
caf5504
Translated using Weblate (Catalan)
Noel000 Mar 21, 2022
7eac7d5
[14.0][IMP] stock_analytic: Add analytic on move lines tree view
rousseldenis Dec 28, 2021
d91a479
[IMP] stock_analytic: Take into account extra move lines flow
rousseldenis May 17, 2022
2f19cf1
[MIG] stock_analytic: Migration to 16.0
nicomacr Dec 6, 2022
98a14fe
[IMP] stock_analytic: add validation on analytic distribution
yostashiro Jan 23, 2023
e5d6355
[16.0][IMP] stock_analytic: add analytic distribution to move tree re…
ThiagoMForgeFlow Jun 15, 2023
6e5110d
Translated using Weblate (Dutch)
Jan-Onestein Oct 17, 2023
ea47702
Translated using Weblate (Spanish)
Ivorra78 Oct 19, 2023
9113bf8
Translated using Weblate (Portuguese (Brazil))
adrianojprado Oct 28, 2023
5f4c575
[IMP] stock_analytic: pre-commit stuff
moitabenfdz Dec 21, 2023
f73b68e
[MIG] stock_analytic: Migration to 17.0
moitabenfdz Dec 21, 2023
f9ed7bc
[13.0][ADD] new module sale_stock_analytic
baimont Nov 10, 2020
192b337
[14.0][MIG] sale_stock_analytic
rousseldenis Nov 2, 2021
a915813
[IMP] sale_stock_analytic: Depends on sale_stock
rousseldenis Nov 2, 2021
cf77e63
[IMP] sale_stock_analytic: Improve tests
rousseldenis Nov 2, 2021
cb21c36
[MIG] sale_stock_analytic: Migration to 15.0
moitabenfdz Dec 21, 2023
56252c2
[MIG] sale_stock_analytic: Migration to 16.0
moitabenfdz Jan 2, 2024
5b900c8
[IMP] sale_stock_analytic: pre-commit stuff
moitabenfdz Jan 2, 2024
96ea9fa
[MIG] sale_stock_analytic: Migration to 17.0
moitabenfdz Jan 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 <benoit.aimont@acsone.eu>
* Marcos Oitabén <marcos.oitaben@dynapps.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
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": "17.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
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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might take into account the case where analytic account is at the sale order level...
you might cherry-pick DynAppsNV#2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, Odoo's own logic merges the two when preparing the invoice line information from a sale line: https://github.com/odoo/odoo/blob/1648ee1abff1ae12b3933baa85a2e048fa2eb557/addons/sale/models/sale_order_line.py#L1142C9-L1142C35.

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
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
42 changes: 42 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,42 @@
# 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,
"analytic_account_id": cls.analytic_account.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
)
124 changes: 124 additions & 0 deletions stock_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
==============
Stock Analytic
==============

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

.. |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_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_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|

Adds Analytic Distribution field in stock move to be able to get
analytic information when generating the journal items.

**Table of contents**

.. contents::
:local:

Configuration
=============

As necessary, go to *Invoicing > Configuration > Analytic Plans*, open
the relevant record and update the applicability for 'Stock Move'.

Usage
=====

To Assign an Analytic Account to a Stock Move
---------------------------------------------

You need to:

1. Create manually or open draft picking
2. Add move lines and assign an **analytic account** in Analytic
Distribution field

Assigned Journal Items created from Stock Move with Analytic Account
--------------------------------------------------------------------

If stock move automatically create journal entry, the journal entry will
contain journal items with following rule:

1. Journal item with account equal to product's valuation account will
not be assigned to any analytic account.
2. Journal item with account different to product's valuation account
will be assigned to an analytic account according to the stock move's
analytic account.

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_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
-------

* Julius Network Solutions
* ClearCorp
* OpenSynergy Indonesia
* Hibou Corp.

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

- Hanane ELKHAL <hanane@julius.fr>
- Yvan Patry <yvan@julius.fr>
- Pierre <pierre@julius.fr>
- Mathieu VATEL <mathieu@julius.fr>
- Fabio Vílchez <fabio.vilchez@clearcorp.co.cr>
- Andhitia Rama <andhitia.r@gmail.com>
- Michael Viriyananda <viriyananda.michael@gmail.com>
- Aaron Henriquez <ahenriquez@forgeflow.com>
- Jared Kipe <jared@hibou.io>
- Alan Ramos <alan.ramos@jarsa.com.mx>
- Mantas Šniukas <mantas@vialaurea.lt>
- Marcos Oitabén <marcos.oitaben@dynapps.eu>
- `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_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions stock_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
27 changes: 27 additions & 0 deletions stock_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2013 Julius Network Solutions
# Copyright 2015 Clear Corp
# Copyright 2016 OpenSynergy Indonesia
# Copyright 2017 ForgeFlow S.L.
# Copyright 2018 Hibou Corp.
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Stock Analytic",
"summary": "Adds analytic distribution in stock move",
"version": "17.0.1.0.0",
"author": "Julius Network Solutions, "
"ClearCorp, OpenSynergy Indonesia, "
"Hibou Corp., "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"category": "Warehouse Management",
"license": "AGPL-3",
"depends": ["stock_account", "analytic"],
"data": [
"views/stock_move_views.xml",
"views/stock_scrap_views.xml",
"views/stock_move_line_views.xml",
"views/stock_picking_views.xml",
],
"installable": True,
}