[13.0][MIG] stock_available_unreserved

Standard migration. Also some copyrights are removed because they were added by mistake in the fist place (copy+paste issues ;) )
This commit is contained in:
Lois Rilo
2019-12-20 14:00:53 +01:00
parent b9f9d02672
commit 9fecf39399
8 changed files with 132 additions and 130 deletions

View File

@@ -7,20 +7,20 @@ Stock Available Unreserved
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available_unreserved
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available_unreserved
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_unreserved
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_available_unreserved
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/12.0
:target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -47,7 +47,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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-warehouse/issues/new?body=module:%20stock_available_unreserved%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-warehouse/issues/new?body=module:%20stock_available_unreserved%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.
@@ -81,6 +81,14 @@ 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-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available_unreserved>`_ project on GitHub.
.. |maintainer-LoisBForgeFlow| image:: https://github.com/LoisBForgeFlow.png?size=40px
:target: https://github.com/LoisBForgeFlow
:alt: LoisBForgeFlow
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-LoisBForgeFlow|
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available_unreserved>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,12 +1,14 @@
# Copyright 2018 Camptocamp SA
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Stock Available Unreserved",
"summary": "Quantity of stock available for immediate use",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"development_status": "Production/Stable",
"maintainers": ["LoisRForgeFlow"],
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management",
"depends": ["stock"],

View File

@@ -1,29 +1,24 @@
# Copyright 2018 Camptocamp SA
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.float_utils import float_round
from odoo.addons import decimal_precision as dp
from odoo.addons.stock.models.product import OPERATORS
UNIT = dp.get_precision("Product Unit of Measure")
class ProductTemplate(models.Model):
_inherit = "product.template"
qty_available_not_res = fields.Float(
string="Quantity On Hand Unreserved",
digits=UNIT,
digits="Product Unit of Measure",
compute="_compute_product_available_not_res",
search="_search_quantity_unreserved",
)
@api.multi
@api.depends("product_variant_ids.qty_available_not_res")
def _compute_product_available_not_res(self):
for tmpl in self:
@@ -33,14 +28,13 @@ class ProductTemplate(models.Model):
tmpl.mapped("product_variant_ids.qty_available_not_res")
)
@api.multi
def action_open_quants_unreserved(self):
products_ids = self.mapped("product_variant_ids").ids
quants = self.env["stock.quant"].search([("product_id", "in", products_ids)])
quant_ids = quants.filtered(
lambda x: x.product_id.qty_available_not_res > 0
).ids
result = self.env.ref("stock.product_open_quants").read()[0]
result = self.env.ref("stock.product_template_open_quants").read()[0]
result["domain"] = [("id", "in", quant_ids)]
result["context"] = {
"search_default_locationgroup": 1,
@@ -59,19 +53,17 @@ class ProductProduct(models.Model):
qty_available_not_res = fields.Float(
string="Qty Available Not Reserved",
digits=UNIT,
digits="Product Unit of Measure",
compute="_compute_qty_available_not_reserved",
search="_search_quantity_unreserved",
)
@api.multi
def _prepare_domain_available_not_reserved(self):
domain_quant = [("product_id", "in", self.ids)]
domain_quant_locations = self._get_domain_locations()[0]
domain_quant.extend(domain_quant_locations)
return domain_quant
@api.multi
def _compute_product_available_not_res_dict(self):
res = {}
@@ -102,7 +94,6 @@ class ProductProduct(models.Model):
res[product.id] = {"qty_available_not_res": available_not_res}
return res
@api.multi
@api.depends("stock_move_ids.product_qty", "stock_move_ids.state")
def _compute_qty_available_not_reserved(self):
res = self._compute_product_available_not_res_dict()

View File

@@ -1,5 +1,5 @@
# Copyright 2018 Camptocamp SA
# Copyright 2016 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models

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 0.15.2: http://docutils.sourceforge.net/" />
<title>Stock Available Unreserved</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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available_unreserved"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_unreserved"><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/153/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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available_unreserved"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_available_unreserved"><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/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to check the quantity of a stocked product that is
available on-hand, and that has not yet been reserved for use anywhere else.</p>
<p>This key figure is very important during the monitoring of the warehouse
@@ -393,7 +393,7 @@ the availability of unreserved stock.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/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-warehouse/issues/new?body=module:%20stock_available_unreserved%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-warehouse/issues/new?body=module:%20stock_available_unreserved%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">
@@ -421,7 +421,9 @@ 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-warehouse/tree/12.0/stock_available_unreserved">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/LoisBForgeFlow"><img alt="LoisBForgeFlow" src="https://github.com/LoisBForgeFlow.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available_unreserved">OCA/stock-logistics-warehouse</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,7 +1,5 @@
# Copyright 2018 Camptocamp SA
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2016 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2016 Therp BV <http://therp.nl>
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2019 JARSA Sistemas S.A. de C.V.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -15,6 +13,9 @@ class TestStockLogisticsWarehouse(SavepointCase):
cls.pickingObj = cls.env["stock.picking"]
cls.productObj = cls.env["product.product"]
cls.templateObj = cls.env["product.template"]
cls.attrObj = cls.env["product.attribute"]
cls.attrvalueObj = cls.env["product.attribute.value"]
cls.supplier_location = cls.env.ref("stock.stock_location_suppliers")
cls.stock_location = cls.env.ref("stock.stock_location_stock")
cls.customer_location = cls.env.ref("stock.stock_location_customers")
@@ -43,33 +44,33 @@ class TestStockLogisticsWarehouse(SavepointCase):
# Create product template
cls.templateAB = cls.templateObj.create(
{"name": "templAB", "uom_id": cls.uom_unit.id}
{"name": "templAB", "uom_id": cls.uom_unit.id, "type": "product"}
)
cls.productC = cls.templateAB.product_variant_ids
# Create product A and B
cls.productA = cls.productObj.create(
cls.color_attribute = cls.attrObj.create({"name": "Color", "sequence": 1})
cls.color_black = cls.attrvalueObj.create(
{"name": "Black", "attribute_id": cls.color_attribute.id, "sequence": 1}
)
cls.color_white = cls.attrvalueObj.create(
{"name": "White", "attribute_id": cls.color_attribute.id, "sequence": 2}
)
cls.color_grey = cls.attrvalueObj.create(
{"name": "Grey", "attribute_id": cls.color_attribute.id, "sequence": 3}
)
cls.product_attribute_line = cls.env["product.template.attribute.line"].create(
{
"name": "product A",
"standard_price": 1,
"type": "product",
"uom_id": cls.uom_unit.id,
"default_code": "A",
"product_tmpl_id": cls.templateAB.id,
"attribute_id": cls.color_attribute.id,
"value_ids": [
(6, 0, [cls.color_white.id, cls.color_black.id, cls.color_grey.id])
],
}
)
cls.productA = cls.templateAB.product_variant_ids[0]
cls.productB = cls.templateAB.product_variant_ids[1]
cls.productB = cls.productObj.create(
{
"name": "product B",
"standard_price": 1,
"type": "product",
"uom_id": cls.uom_unit.id,
"default_code": "B",
"product_tmpl_id": cls.templateAB.id,
}
)
cls.productC = cls.templateAB.product_variant_ids[2]
# Create a picking move from INCOMING to STOCK
cls.pickingInA = cls.pickingObj.create(
@@ -143,7 +144,7 @@ class TestStockLogisticsWarehouse(SavepointCase):
product.invalidate_cache()
self.assertEqual(product.qty_available_not_res, value)
def test_stock_levels(self):
def test_01_stock_levels(self):
"""checking that qty_available_not_res actually reflects \
the variations in stock, both on product and template"""
@@ -185,7 +186,7 @@ class TestStockLogisticsWarehouse(SavepointCase):
self.templateAB.action_open_quants_unreserved()
def test_more_than_one_quant(self):
def test_02_more_than_one_quant(self):
self.env["stock.quant"].create(
{
"location_id": self.stock_location.id,
@@ -239,7 +240,7 @@ class TestStockLogisticsWarehouse(SavepointCase):
)
)
def test_stock_search(self):
def test_03_stock_search(self):
all_variants = self.templateAB.product_variant_ids
a_and_b = self.productA + self.productB
b_and_c = self.productB + self.productC

View File

@@ -1,87 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_stock_product_template_tree" model="ir.ui.view">
<field name="name">product.template.stock.tree.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="stock.view_stock_product_template_tree"/>
<field name="arch" type="xml">
<field name="qty_available" position="after">
<field name="qty_available_not_res"/>
</field>
<record id="view_stock_product_template_tree" model="ir.ui.view">
<field name="name">product.template.stock.tree.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="stock.view_stock_product_template_tree"/>
<field name="arch" type="xml">
<field name="qty_available" position="after">
<field name="qty_available_not_res"/>
</field>
</record>
</field>
</record>
<record id="product_template_search_form_view_stock" model="ir.ui.view">
<field name="name">product.template.search.stock.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_search_form_view_stock"/>
<field name="arch" type="xml">
<filter name="real_stock_available" position="after">
<filter name="real_stock_unreserved" string="Reservable Products" domain="[('qty_available_not_res','&gt;',0)]"/>
</filter>
</field>
</record>
<record id="product_template_search_form_view_stock" model="ir.ui.view">
<field name="name">product.template.search.stock.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_search_form_view_stock"/>
<field name="arch" type="xml">
<filter name="real_stock_available" position="after">
<filter name="real_stock_unreserved" string="Reservable Products" domain="[('qty_available_not_res','&gt;',0)]"/>
</filter>
</field>
</record>
<record model="ir.ui.view" id="product_template_kanban_stock_view">
<field name="name">Product Template Kanban Stock</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="stock.product_template_kanban_stock_view"/>
<field name="arch" type="xml">
<ul position="inside">
<li t-if="record.type.raw_value == 'product'">Unreserved: <field name="qty_available_not_res"/> <field name="uom_id"/></li>
</ul>
</field>
</record>
<record id="product_template_kanban_stock_view" model="ir.ui.view">
<field name="name">Product Template Kanban Stock</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="stock.product_template_kanban_stock_view"/>
<field name="arch" type="xml">
<ul position="inside">
<li t-if="record.type.raw_value == 'product'">Unreserved: <field name="qty_available_not_res"/> <field name="uom_id"/></li>
</ul>
</field>
</record>
<record id="view_stock_product_tree" model="ir.ui.view">
<field name="name">product.stock.tree.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.view_stock_product_tree"/>
<field name="arch" type="xml">
<field name="qty_available" position="after">
<field name="qty_available_not_res"/>
</field>
<record id="view_stock_product_tree" model="ir.ui.view">
<field name="name">product.stock.tree.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.view_stock_product_tree"/>
<field name="arch" type="xml">
<field name="qty_available" position="after">
<field name="qty_available_not_res"/>
</field>
</record>
</field>
</record>
<record model="ir.ui.view" id="product_template_form_view_procurement_button">
<field name="name">product.template_procurement</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="stock.product_template_form_view_procurement_button"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button type="object"
name="action_open_quants_unreserved"
attrs="{'invisible':[('type', '!=', 'product')]}"
class="oe_stat_button" icon="fa-building-o">
<field name="qty_available_not_res" widget="statinfo"
string="Unreserved"/>
</button>
</div>
</field>
</record>
<record id="product_template_form_view_procurement_button" model="ir.ui.view">
<field name="name">product.template_procurement</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="stock.product_template_form_view_procurement_button"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button type="object"
name="action_open_quants_unreserved"
attrs="{'invisible':[('type', '!=', 'product')]}"
class="oe_stat_button" icon="fa-building-o">
<field name="qty_available_not_res" widget="statinfo"
string="Unreserved"/>
</button>
</div>
</field>
</record>
<record model="ir.ui.view" id="product_form_view_procurement_button">
<field name="name">product.product.procurement</field>
<field name="model">product.product</field>
<field name="inherit_id"
ref="stock.product_form_view_procurement_button"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button"
name="%(product_open_quants_unreserved)d"
icon="fa-building-o"
type="action" attrs="{'invisible':[('type', '!=', 'product')]}">
<field name="qty_available_not_res" widget="statinfo"
string="Unreserved"/>
</button>
</div>
</field>
</record>
<record id="product_form_view_procurement_button" model="ir.ui.view">
<field name="name">product.product.procurement</field>
<field name="model">product.product</field>
<field name="inherit_id"
ref="stock.product_form_view_procurement_button"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button"
name="%(product_open_quants_unreserved)d"
icon="fa-building-o"
type="action" attrs="{'invisible':[('type', '!=', 'product')]}">
<field name="qty_available_not_res" widget="statinfo"
string="Unreserved"/>
</button>
</div>
</field>
</record>
</odoo>

View File

@@ -18,8 +18,7 @@
</field>
</record>
<record model="ir.actions.act_window"
id="product_open_quants_unreserved">
<record id="product_open_quants_unreserved" model="ir.actions.act_window">
<field name="name">Stock On Hand (Unreserved)</field>
<field name="context">{'search_default_internal_loc': 1, 'search_default_locationgroup':1}</field>
<field name="domain">[('product_id', '=', active_id), ('contains_unreserved', '=', True)]</field>