[MIG] stock_quantity_history_location: Migration 15.0

Co-authored-by: DavidJForgeFlow <david.jimenez@forgeflow.com>
This commit is contained in:
AnnaPForgeFlow
2022-07-06 13:31:32 +02:00
committed by GuillemCForgeFlow
parent 2ede7b6305
commit 45acc97c4f
11 changed files with 93 additions and 68 deletions

View File

@@ -14,14 +14,14 @@ Stock 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/14.0/stock_quantity_history_location
:target: https://github.com/OCA/stock-logistics-reporting/tree/15.0/stock_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-14-0/stock-logistics-reporting-14-0-stock_quantity_history_location
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-15-0/stock-logistics-reporting-15-0-stock_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/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/stock-logistics-reporting&target_branch=15.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -49,7 +49,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_quantity_history_location%0Aversion:%2014.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_quantity_history_location%0Aversion:%2015.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.
@@ -61,6 +61,14 @@ Authors
* ForgeFlow
Contributors
~~~~~~~~~~~~
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* `Tecnativa <https://www.tecnativa.com>`_:
* Ernesto Tejeda
Maintainers
~~~~~~~~~~~
@@ -74,6 +82,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/14.0/stock_quantity_history_location>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/15.0/stock_quantity_history_location>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -5,10 +5,18 @@
{
"name": "Stock Quantity History Location",
"summary": "Provides stock quantity by location on past date",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "ForgeFlow," "Odoo Community Association (OCA)",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
"depends": ["stock"],
"data": ["wizards/stock_quantity_history.xml"],
"assets": {
"web.assets_backend": [
"stock_quantity_history_location/static/src/js/inventory_report.js",
],
"web.assets_qweb": [
"stock_quantity_history_location/static/src/xml/inventory_report.xml",
],
},
}

View File

@@ -1 +0,0 @@
* Jordi Ballester Alomar <jordi.ballester@eficent.com>

View File

@@ -0,0 +1,4 @@
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* `Tecnativa <https://www.tecnativa.com>`_:
* Ernesto Tejeda

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Stock Quantity History Location</title>
<style type="text/css">
@@ -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/14.0/stock_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-14-0/stock-logistics-reporting-14-0-stock_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/14.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/15.0/stock_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-15-0/stock-logistics-reporting-15-0-stock_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://runboat.odoo-community.org/webui/builds.html?repo=OCA/stock-logistics-reporting&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to run an Inventory report or Inventory Valuation
report by location, for a past date or for current date.</p>
<p><strong>Table of contents</strong></p>
@@ -377,7 +377,8 @@ report by location, for a past date or for current date.</p>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
@@ -404,7 +405,7 @@ report by location, for a past date or for current date.</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_quantity_history_location%0Aversion:%2014.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_quantity_history_location%0Aversion:%2015.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">
@@ -415,14 +416,24 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Ernesto Tejeda</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<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/14.0/stock_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/15.0/stock_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>

View File

@@ -1,23 +1,25 @@
/* eslint-disable no-unused-vars */
odoo.define("stock.InventoryReportLocationListController", function (require) {
"use strict";
odoo.define(
"stock_quantity_history_location.InventoryReportListController",
function (require) {
"use strict";
var core = require("web.core");
var InventoryReportListController = require("stock.InventoryReportListController");
const session = require("web.session");
const InventoryReportListController = require("stock.InventoryReportListController");
var qweb = core.qweb;
var _t = core._t;
var InventoryReportLocationListController = InventoryReportListController.include({
renderButtons: function ($node) {
this._super.apply(this, arguments);
if (this.context.no_at_date) {
return;
}
if (this.modelName === "stock.quant" && this.$buttons.length) {
this.$buttons[0].firstElementChild.innerHTML =
"Inventory at Date & Location";
}
},
});
});
InventoryReportListController.include({
init: function () {
this._super.apply(this, arguments);
this.multi_location = false;
},
willStart: function () {
const sup = this._super(...arguments);
const user_group = session
.user_has_group("stock.group_stock_multi_locations")
.then((hasGroup) => {
this.multi_location = hasGroup;
});
return Promise.all([sup, user_group]);
},
});
}
);

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-extend="StockInventoryReport.Buttons">
<t t-jquery="button.o_button_at_date" t-operation="inner">
<t t-if="widget.multi_location">Inventory at Date &amp; Location</t>
<t t-else="">Inventory at Date</t>
</t>
</t>
</templates>

View File

@@ -1,10 +1,10 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
class TestCommon(SavepointCase):
class TestCommon(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

View File

@@ -40,10 +40,10 @@ class TestStockQuantityHistoryLocation(TestCommon):
}
)
action = wizard.with_context(company_owned=True).open_at_date()
self.assertEquals(
self.product.with_context(action["context"]).qty_available, 100.0
self.assertEqual(
self.product.with_context(**action["context"]).qty_available, 100.0
)
self.assertEquals(
self.assertEqual(
self.product.with_context(
location=self.child_test_stock_loc.id, to_date="2019-08-10"
).qty_available,
@@ -55,11 +55,11 @@ class TestStockQuantityHistoryLocation(TestCommon):
{"location_id": self.test_stock_loc.id, "include_child_locations": False}
)
action = wizard.with_context().open_at_date()
self.assertEquals(action["context"]["compute_child"], False)
self.assertEquals(action["context"]["location"], self.test_stock_loc.id)
self.assertEqual(action["context"]["compute_child"], False)
self.assertEqual(action["context"]["location"], self.test_stock_loc.id)
wizard = self.env["stock.quantity.history"].create(
{"location_id": self.test_stock_loc.id, "include_child_locations": True}
)
action = wizard.with_context().open_at_date()
self.assertEquals(action["context"]["compute_child"], True)
self.assertEquals(action["context"]["location"], self.test_stock_loc.id)
self.assertEqual(action["context"]["compute_child"], True)
self.assertEqual(action["context"]["location"], self.test_stock_loc.id)

View File

@@ -13,10 +13,10 @@ class StockQuantityHistory(models.TransientModel):
location_id = fields.Many2one(
"stock.location", domain=[("usage", "in", ["internal", "transit"])]
)
include_child_locations = fields.Boolean("Include child locations", default=True)
include_child_locations = fields.Boolean(default=True)
def open_at_date(self):
action = super(StockQuantityHistory, self).open_at_date()
action = super().open_at_date()
ctx = action["context"]
if isinstance(ctx, str):
ctx = ast.literal_eval(ctx)
@@ -25,8 +25,8 @@ class StockQuantityHistory(models.TransientModel):
ctx["compute_child"] = self.include_child_locations
if ctx.get("company_owned", False):
ctx.pop("company_owned")
action["name"] = "{} ({})".format(
action["name"], self.location_id.complete_name
)
action[
"display_name"
] = f"{self.location_id.complete_name} - {action['display_name']}"
action["context"] = ctx
return action

View File

@@ -1,29 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="stock_quantity_history_location_assets_backend"
name="mrp_workorder assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/stock_quantity_history_location/static/src/js/inventory_report.js"
/>
</xpath>
</template>
<record id="view_stock_quantity_history_location" model="ir.ui.view">
<field name="name">Inventory Report</field>
<field name="model">stock.quantity.history</field>
<field name="inherit_id" ref="stock.view_stock_quantity_history" />
<field name="arch" type="xml">
<field name="inventory_datetime" position="before">
<field
name="location_id"
invisible="context.get('active_model') == 'stock.valuation.layer'"
/>
<field name="location_id" groups="stock.group_stock_multi_locations" />
<field
name="include_child_locations"
attrs="{'invisible': [('location_id', '=', False)]}"