mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[MIG] stock_account_quantity_history_location: Migration to 13.0
This commit is contained in:
committed by
Pedro M. Baeza
parent
e7e4884986
commit
043382d3db
@@ -14,13 +14,13 @@ Stock Account Quantity History Location
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_account_quantity_history_location
|
||||
:target: https://github.com/OCA/stock-logistics-reporting/tree/13.0/stock_account_quantity_history_location
|
||||
:alt: OCA/stock-logistics-reporting
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-12-0/stock-logistics-reporting-12-0-stock_account_quantity_history_location
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-13-0/stock-logistics-reporting-13-0-stock_account_quantity_history_location
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/151/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/151/13.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -41,7 +41,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-reporting/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_account_quantity_history_location%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_account_quantity_history_location%0Aversion:%2013.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.
|
||||
|
||||
@@ -66,6 +66,6 @@ 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/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_account_quantity_history_location>`_ project on GitHub.
|
||||
This module is part of the `OCA/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/13.0/stock_account_quantity_history_location>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2019 Aleph Objects, Inc.
|
||||
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
@@ -7,11 +8,11 @@
|
||||
"summary": """
|
||||
Glue module between Stock Account and Stock Quantity History Location
|
||||
modules""",
|
||||
"version": "12.0.1.1.0",
|
||||
"version": "13.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Eficent," "Odoo Community Association (OCA)",
|
||||
"author": "Eficent, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-reporting",
|
||||
"depends": ["stock_account", "stock_quantity_history_location",],
|
||||
"data": ["wizards/stock_quantity_history.xml",],
|
||||
"depends": ["stock_account", "stock_quantity_history_location"],
|
||||
"data": ["wizards/stock_quantity_history.xml"],
|
||||
"auto_install": True,
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * stock_account_quantity_history_location
|
||||
# * stock_account_quantity_history_location
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0\n"
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: <>\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@@ -17,4 +17,3 @@ msgstr ""
|
||||
#: model:ir.model,name:stock_account_quantity_history_location.model_stock_quantity_history
|
||||
msgid "Stock Quantity History"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Víctor Martínez
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_account_quantity_history_location"><img alt="OCA/stock-logistics-reporting" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-reporting-12-0/stock-logistics-reporting-12-0-stock_account_quantity_history_location"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/151/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/13.0/stock_account_quantity_history_location"><img alt="OCA/stock-logistics-reporting" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-reporting-13-0/stock-logistics-reporting-13-0-stock_account_quantity_history_location"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/151/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Glue module between Stock Account and Stock Quantity History Location modules.</p>
|
||||
<p>Display a warning on the Stock Inventory report that accounting valuation is
|
||||
not calculated when you specify a location.</p>
|
||||
@@ -387,7 +387,7 @@ not calculated when you specify a location.</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_account_quantity_history_location%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_account_quantity_history_location%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -405,7 +405,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_account_quantity_history_location">OCA/stock-logistics-reporting</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/13.0/stock_account_quantity_history_location">OCA/stock-logistics-reporting</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# Copyright 2020 Tecnativa - David Vidal
|
||||
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from datetime import datetime
|
||||
|
||||
from odoo.addons.stock_quantity_history_location.tests import (
|
||||
test_stock_quantity_history_location,
|
||||
)
|
||||
@@ -11,48 +14,87 @@ class TestValuationLocation(
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env["product.price.history"].create(
|
||||
{"datetime": "2019-08-12", "product_id": cls.product.id, "cost": 35.01,}
|
||||
cls.sqh_model = cls.env["stock.quantity.history"]
|
||||
cls.sqh_model_svl = cls.env["stock.quantity.history"].with_context(
|
||||
active_model="stock.valuation.layer"
|
||||
)
|
||||
cls.env["product.price.history"].create(
|
||||
{"datetime": "2020-01-01", "product_id": cls.product.id, "cost": 33.33,}
|
||||
)
|
||||
cls.product.categ_id.property_cost_method = "standard"
|
||||
cls.test_stock_loc2 = cls.env["stock.location"].create(
|
||||
{
|
||||
"usage": "internal",
|
||||
"name": "Test Stock Location 2",
|
||||
"company_id": cls.main_company.id,
|
||||
}
|
||||
)
|
||||
# Create a move for the past
|
||||
move = cls.env["stock.move"].create(
|
||||
|
||||
def _create_stock_move(self, location_dest_id, qty):
|
||||
move = self.env["stock.move"].create(
|
||||
{
|
||||
"name": "Stock move in",
|
||||
"location_id": cls.supplier_location.id,
|
||||
"location_dest_id": cls.test_stock_loc2.id,
|
||||
"product_id": cls.product.id,
|
||||
"product_uom": cls.product.uom_id.id,
|
||||
"product_uom_qty": 50.0,
|
||||
"location_id": self.supplier_location.id,
|
||||
"location_dest_id": location_dest_id.id,
|
||||
"product_id": self.product.id,
|
||||
"product_uom": self.product.uom_id.id,
|
||||
"product_uom_qty": qty,
|
||||
}
|
||||
)
|
||||
move._action_confirm()
|
||||
move._action_assign()
|
||||
move_line = move.move_line_ids[0]
|
||||
move_line.qty_done = 50.0
|
||||
move_line.qty_done = qty
|
||||
move._action_done()
|
||||
move.date = "2020-01-01"
|
||||
return move
|
||||
|
||||
def test_stock_location_valuation(self):
|
||||
wizard = self.env["stock.quantity.history"].create(
|
||||
wizard = self.sqh_model.create(
|
||||
{
|
||||
"location_id": self.test_stock_loc2.id,
|
||||
"location_id": self.test_stock_loc.id,
|
||||
"include_child_locations": True,
|
||||
"compute_at_date": 1,
|
||||
"date": "2020-01-01",
|
||||
"inventory_datetime": datetime.today(),
|
||||
}
|
||||
)
|
||||
action = wizard.with_context(company_owned=True, valuation=True).open_table()
|
||||
self.assertAlmostEqual(
|
||||
self.product.with_context(action["context"]).stock_value, 1666.5
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
qty_svl_prev = self.product.with_context(action["context"]).quantity_svl
|
||||
move = self._create_stock_move(location_dest_id=self.test_stock_loc, qty=60)
|
||||
wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
product = self.product.with_context(action["context"])
|
||||
self.assertEqual(product.quantity_svl - qty_svl_prev, 60)
|
||||
|
||||
def test_stock_location_valuation_without_location_id(self):
|
||||
wizard = self.sqh_model.create(
|
||||
{"include_child_locations": True, "inventory_datetime": datetime.today()}
|
||||
)
|
||||
action = wizard.with_context(company_owned=True, valuation=True).open_at_date()
|
||||
qty_svl_prev = self.product.with_context(action["context"]).quantity_svl
|
||||
self._create_stock_move(location_dest_id=self.test_stock_loc, qty=50)
|
||||
move = self._create_stock_move(
|
||||
location_dest_id=self.child_test_stock_loc, qty=10
|
||||
)
|
||||
wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
product = self.product.with_context(action["context"])
|
||||
self.assertEqual(product.quantity_svl - qty_svl_prev, 60)
|
||||
|
||||
def test_stock_location_valuation_with_svl(self):
|
||||
wizard = self.sqh_model_svl.create(
|
||||
{
|
||||
"location_id": self.test_stock_loc.id,
|
||||
"include_child_locations": True,
|
||||
"inventory_datetime": datetime.today(),
|
||||
}
|
||||
)
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
records_prev = self.env[action["res_model"]].search(action["domain"])
|
||||
move = self._create_stock_move(location_dest_id=self.test_stock_loc, qty=100)
|
||||
wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
records = self.env[action["res_model"]].search(action["domain"]) - records_prev
|
||||
self.assertEqual(sum(records.mapped("quantity")), 100)
|
||||
|
||||
def test_stock_location_valuation_with_svl_without_location_id(self):
|
||||
wizard = self.sqh_model_svl.create(
|
||||
{"include_child_locations": True, "inventory_datetime": datetime.today()}
|
||||
)
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
records_prev = self.env[action["res_model"]].search(action["domain"])
|
||||
self._create_stock_move(location_dest_id=self.test_stock_loc, qty=100)
|
||||
move = self._create_stock_move(
|
||||
location_dest_id=self.child_test_stock_loc, qty=100
|
||||
)
|
||||
wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date
|
||||
action = wizard.with_context(company_owned=True).open_at_date()
|
||||
records = self.env[action["res_model"]].search(action["domain"]) - records_prev
|
||||
self.assertEqual(sum(records.mapped("quantity")), 200)
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# Copyright 2019 Aleph Objects, Inc.
|
||||
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import ast
|
||||
|
||||
from odoo import models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class StockQuantityHistory(models.TransientModel):
|
||||
_inherit = "stock.quantity.history"
|
||||
|
||||
def open_table(self):
|
||||
"""Stock valuation goes by a different path than stock report, so
|
||||
we ensure the correct context as well"""
|
||||
action = super().open_table()
|
||||
if not self.env.context.get("valuation"):
|
||||
return action
|
||||
# Show 0 quantities on Inventory Valuation to display Account Valuation
|
||||
# anomalies, such as, non 0 stock_value on cost_method FIFO
|
||||
if not self.location_id:
|
||||
domain = ast.literal_eval(action["domain"])
|
||||
domain.pop(domain.index(("qty_available", "!=", 0)))
|
||||
action["domain"] = domain
|
||||
def open_at_date(self):
|
||||
action = super().open_at_date()
|
||||
ctx = action["context"]
|
||||
if isinstance(ctx, str):
|
||||
ctx = ast.literal_eval(ctx)
|
||||
@@ -36,4 +28,22 @@ class StockQuantityHistory(models.TransientModel):
|
||||
self.location_id.complete_name,
|
||||
)
|
||||
action["context"] = ctx
|
||||
if self.env.context.get("active_model") == "stock.valuation.layer":
|
||||
action["domain"] = expression.AND(
|
||||
[
|
||||
action["domain"],
|
||||
[("stock_move_id.location_dest_id", "=", self.location_id.id)],
|
||||
]
|
||||
)
|
||||
else:
|
||||
# Show 0 quantities on Inventory Valuation to display Account Valuation
|
||||
# anomalies, such as, non 0 stock_value on cost_method FIFO
|
||||
if self.env.context.get("active_model") == "stock.valuation.layer":
|
||||
action["domain"] = expression.AND(
|
||||
[action["domain"], [("quantity", "!=", 0)]]
|
||||
)
|
||||
else:
|
||||
action["domain"] = expression.AND(
|
||||
[action["domain"], [("qty_available", "!=", 0)]]
|
||||
)
|
||||
return action
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
<record id="view_stock_account_quantity_history_location" model="ir.ui.view">
|
||||
<field name="name">Valuation Report</field>
|
||||
<field name="model">stock.quantity.history</field>
|
||||
<field name="inherit_id" ref="stock_account.view_stock_quantity_history" />
|
||||
<field name="inherit_id" ref="stock.view_stock_quantity_history" />
|
||||
<field
|
||||
name="groups_id"
|
||||
eval="[(4, ref('stock.group_stock_multi_locations'))]"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="compute_at_date" position="before">
|
||||
<field name="location_id" />
|
||||
<field name="inventory_datetime" position="before">
|
||||
<field
|
||||
name="include_child_locations"
|
||||
attrs="{'invisible': [('location_id', '=', False)]}"
|
||||
name="location_id"
|
||||
invisible="context.get('active_model') != 'stock.valuation.layer'"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user