mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] sale_stock_available_info_popup: Migration to 15.0
TT36989
This commit is contained in:
@@ -14,13 +14,13 @@ Sale Stock Available Info Popup
|
||||
: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--warehouse-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/sale_stock_available_info_popup
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/sale_stock_available_info_popup
|
||||
: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-13-0/stock-logistics-warehouse-13-0-sale_stock_available_info_popup
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-sale_stock_available_info_popup
|
||||
: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/13.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/15.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -50,7 +50,7 @@ quantity of the corresponding product instead of 'Forecast Quantity'.
|
||||
If that quantity is less than the quantity to deliver, the color of
|
||||
the icon will be red, indicating an alert; otherwise it will be blue.
|
||||
|
||||
.. |fa_info_circle| image:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/13.0/sale_stock_available_info_popup/static/src/img/info-circle-solid.png
|
||||
.. |fa_info_circle| image:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/15.0/sale_stock_available_info_popup/static/src/img/info-circle-solid.png
|
||||
:width: 10px
|
||||
|
||||
Bug Tracker
|
||||
@@ -59,7 +59,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:%20sale_stock_available_info_popup%0Aversion:%2013.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:%20sale_stock_available_info_popup%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.
|
||||
|
||||
@@ -94,6 +94,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-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/sale_stock_available_info_popup>`_ project on GitHub.
|
||||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/15.0/sale_stock_available_info_popup>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -7,10 +7,14 @@
|
||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"category": "Warehouse Management",
|
||||
"version": "13.0.1.0.3",
|
||||
"version": "15.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["sale_stock", "stock_available"],
|
||||
"data": ["views/sale_order_views.xml"],
|
||||
"qweb": ["static/src/xml/qty_at_date.xml"],
|
||||
"assets": {
|
||||
"web.assets_qweb": [
|
||||
"sale_stock_available_info_popup/static/src/xml/qty_at_date.xml",
|
||||
],
|
||||
},
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -42,6 +42,3 @@ msgid ""
|
||||
"widget.data.immediately_usable_qty_today < widget.data.qty_to_deliver and !"
|
||||
"widget.data.is_mto"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "Product Template"
|
||||
#~ msgstr "Plantilla de producto"
|
||||
|
||||
@@ -16,7 +16,7 @@ class SaleOrderLine(models.Model):
|
||||
@api.depends(
|
||||
"product_id",
|
||||
"product_uom_qty",
|
||||
"order_id.commitment_date",
|
||||
"scheduled_date",
|
||||
"order_id.date_order",
|
||||
"warehouse_id",
|
||||
)
|
||||
@@ -24,14 +24,10 @@ class SaleOrderLine(models.Model):
|
||||
qty_processed_per_product = defaultdict(lambda: 0)
|
||||
self.immediately_usable_qty_today = False
|
||||
for line in self.sorted(key=lambda r: r.sequence):
|
||||
if line.order_id.commitment_date:
|
||||
date = line.order_id.commitment_date
|
||||
else:
|
||||
date = line._expected_date()
|
||||
if not line.display_qty_widget:
|
||||
continue
|
||||
product = line.product_id.with_context(
|
||||
to_date=date, warehouse=line.warehouse_id.id
|
||||
to_date=line.scheduled_date, warehouse=line.warehouse_id.id
|
||||
)
|
||||
qty_processed = qty_processed_per_product[product.id]
|
||||
line.immediately_usable_qty_today = (
|
||||
|
||||
@@ -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>Sale Stock Available Info Popup</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-warehouse/tree/13.0/sale_stock_available_info_popup"><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-sale_stock_available_info_popup"><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><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-warehouse/tree/15.0/sale_stock_available_info_popup"><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-15-0/stock-logistics-warehouse-15-0-sale_stock_available_info_popup"><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/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module extends the functionality of ‘Sale Stock’ module
|
||||
to add the ‘Available to promise’ quantity of the corresponding product
|
||||
to the pop-up that show stock information at sales order line level.</p>
|
||||
@@ -390,7 +390,7 @@ to the pop-up that show stock information at sales order line level.</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to <em>Sales > Orders > quotations</em> and create a new one.</li>
|
||||
<li>Add a sale order line with a storable product</li>
|
||||
<li>Click on the icon <img alt="fa_info_circle" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/13.0/sale_stock_available_info_popup/static/src/img/info-circle-solid.png" style="width: 10px;" /> in the line and you will
|
||||
<li>Click on the icon <img alt="fa_info_circle" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/15.0/sale_stock_available_info_popup/static/src/img/info-circle-solid.png" style="width: 10px;" /> in the line and you will
|
||||
see in the popover the ‘Available to promise’ quantity of the
|
||||
corresponding product.</li>
|
||||
</ol>
|
||||
@@ -404,7 +404,7 @@ the icon will be red, indicating an alert; otherwise it will be blue.</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:%20sale_stock_available_info_popup%0Aversion:%2013.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:%20sale_stock_available_info_popup%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">
|
||||
@@ -434,7 +434,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-warehouse/tree/13.0/sale_stock_available_info_popup">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/15.0/sale_stock_available_info_popup">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>
|
||||
|
||||
@@ -2,18 +2,8 @@
|
||||
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<templates>
|
||||
<div t-extend="sale_stock.qtyAtDate">
|
||||
<t
|
||||
t-jquery="t[t-if^='widget.data.virtual_available_at_date']"
|
||||
t-operation="attributes"
|
||||
>
|
||||
<attribute
|
||||
name="t-if"
|
||||
>widget.data.immediately_usable_qty_today < widget.data.qty_to_deliver and !widget.data.is_mto</attribute>
|
||||
</t>
|
||||
</div>
|
||||
<div t-extend="sale_stock.QtyDetailPopOver">
|
||||
<t t-jquery="t[t-if*='!data.is_mto']" t-operation="append">
|
||||
<t t-extend="sale_stock.QtyDetailPopOver">
|
||||
<t t-jquery="t:first" t-operation="append">
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Available to promise</strong>
|
||||
@@ -24,5 +14,5 @@
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
@@ -4,19 +4,21 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo.fields import Datetime
|
||||
from odoo.tests import Form
|
||||
from odoo.tests.common import SavepointCase, users
|
||||
from odoo.tests import Form, common, new_test_user
|
||||
from odoo.tests.common import users
|
||||
|
||||
|
||||
class SaleStockAvailableInfoPopup(SavepointCase):
|
||||
class SaleStockAvailableInfoPopup(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
# Scratch some seconds from the tracking stuff that we won't need
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
cls.env.ref("base.user_demo").groups_id += cls.env.ref("stock.group_stock_user")
|
||||
cls.sale_user = new_test_user(
|
||||
cls.env,
|
||||
login="sale_user",
|
||||
groups="sales_team.group_sale_salesman",
|
||||
)
|
||||
cls.product = cls.env["product.product"].create(
|
||||
{"name": "Storable product", "type": "product"}
|
||||
{"name": "Storable product", "detailed_type": "product"}
|
||||
)
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Mr. Odoo"})
|
||||
cls.env["stock.quant"].create(
|
||||
@@ -26,22 +28,23 @@ class SaleStockAvailableInfoPopup(SavepointCase):
|
||||
"quantity": 40.0,
|
||||
}
|
||||
)
|
||||
picking_form = Form(cls.env["stock.picking"])
|
||||
picking_form.picking_type_id = cls.env.ref("stock.picking_type_in")
|
||||
picking_in = cls._create_picking(cls, cls.env.ref("stock.picking_type_in"), 5)
|
||||
picking_in.action_assign()
|
||||
picking_out = cls._create_picking(cls, cls.env.ref("stock.picking_type_out"), 3)
|
||||
picking_out.action_assign()
|
||||
|
||||
def _create_picking(self, picking_type, qty):
|
||||
picking_form = Form(self.env["stock.picking"])
|
||||
picking_form.picking_type_id = picking_type
|
||||
with picking_form.move_ids_without_package.new() as move:
|
||||
move.product_id = cls.product
|
||||
move.product_uom_qty = 5
|
||||
picking_form.save().action_assign()
|
||||
picking_form = Form(cls.env["stock.picking"])
|
||||
picking_form.picking_type_id = cls.env.ref("stock.picking_type_out")
|
||||
with picking_form.move_ids_without_package.new() as move:
|
||||
move.product_id = cls.product
|
||||
move.product_uom_qty = 3
|
||||
picking_form.save().action_assign()
|
||||
move.product_id = self.product
|
||||
move.product_uom_qty = qty
|
||||
return picking_form.save()
|
||||
|
||||
def _create_sale(self):
|
||||
sale_form = Form(self.env["sale.order"])
|
||||
sale_form.partner_id = self.partner
|
||||
sale_form.user_id = self.sale_user
|
||||
return sale_form
|
||||
|
||||
def _add_sale_line(self, sale_form, product, qty=1):
|
||||
@@ -49,17 +52,15 @@ class SaleStockAvailableInfoPopup(SavepointCase):
|
||||
line.product_id = self.product
|
||||
line.product_uom_qty = qty
|
||||
|
||||
@users("admin", "demo")
|
||||
@users("admin", "sale_user")
|
||||
def test_immediately_usable_qty_today(self):
|
||||
sale_form = self._create_sale()
|
||||
self._add_sale_line(sale_form, self.product)
|
||||
sale = sale_form.save()
|
||||
self.assertAlmostEqual(
|
||||
sale.order_line.immediately_usable_qty_today,
|
||||
self.product.immediately_usable_qty,
|
||||
)
|
||||
# 42=40-1+3
|
||||
self.assertAlmostEqual(sale.order_line.immediately_usable_qty_today, 42)
|
||||
|
||||
@users("admin", "demo")
|
||||
@users("admin", "sale_user")
|
||||
def test_immediately_usable_qty_today_similar_solines(self):
|
||||
"""Create a sale order containing three times the same product. The quantity
|
||||
available should be different for the 3 lines.
|
||||
|
||||
Reference in New Issue
Block a user