[MIG] stock_warehouse_orderpoint_stock_info_unreserved: Migration to 10.0

[IMP] fast compute
_product_available() method is computed only once by location
[FIX] stock_available: Some affectations
This commit is contained in:
mreficent
2017-09-06 18:00:37 +02:00
committed by ps-tubtim
parent 0121e6e895
commit 64fffa8a35
6 changed files with 28 additions and 22 deletions

View File

@@ -2,9 +2,9 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
======================================
Reordering Rules stock info unreserved
======================================
================================================
Stock Warehouse Orderpoint Stock Info Unreserved
================================================
This modules allows to display the availability of stock on hand and
unreserved on a reordering rule.
@@ -14,7 +14,7 @@ Usage
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/153/9.0
:target: https://runbot.odoo-community.org/runbot/153/10.0
Bug Tracker
===========
@@ -29,12 +29,16 @@ feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
Maintainer
----------

View File

@@ -3,15 +3,15 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Reordering rules stock info unreserved",
"version": "9.0.1.0.0",
"name": "Stock Warehouse Orderpoint Stock Info Unreserved",
"version": "10.0.1.0.0",
"depends": [
"stock_warehouse_orderpoint_stock_info",
"stock_available_unreserved"
],
"author": "Eficent, "
"Odoo Community Association (OCA)",
"website": "http://www.eficent.com",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse",
"license": "AGPL-3",
"data": [

View File

@@ -2,7 +2,8 @@
# Copyright 2016 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
from odoo import api, fields, models
from collections import defaultdict
class StockWarehouseOrderpoint(models.Model):
@@ -11,12 +12,16 @@ class StockWarehouseOrderpoint(models.Model):
@api.multi
def _compute_product_available_qty(self):
super(StockWarehouseOrderpoint, self)._compute_product_available_qty()
for rec in self:
product_available = rec.product_id.with_context(
location=rec.location_id.id
)._product_available()[rec.product_id.id]
rec.product_location_qty_available_not_res = \
product_available['qty_available_not_res']
op_by_loc = defaultdict(lambda: self.env['stock.warehouse.orderpoint'])
for order in self:
op_by_loc[order.location_id] |= order
for location_id, order_in_loc in op_by_loc.items():
products = order_in_loc.mapped('product_id').with_context(
location=location_id.id)._compute_qty_available_not_res()
for order in order_in_loc:
product = products[order.product_id.id]
order.product_location_qty_available_not_res = \
product['qty_available_not_res']
product_location_qty_available_not_res = fields.Float(
string='Quantity On Location (Unreserved)',

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -2,10 +2,10 @@
# Copyright 2016 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests import common
from odoo.tests.common import TransactionCase
class TestStockWarehouseOrderpoint(common.TransactionCase):
class TestStockWarehouseOrderpoint(TransactionCase):
def setUp(self):
super(TestStockWarehouseOrderpoint, self).setUp()

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<odoo>
<record model="ir.ui.view" id="stock_warehouse_orderpoint_tree_view">
<field name="name">stock.warehouse.orderpoint.tree</field>
<field name="model">stock.warehouse.orderpoint</field>
@@ -24,6 +23,4 @@
</field>
</field>
</record>
</data>
</openerp>
</odoo>