diff --git a/stock_warehouse_orderpoint_stock_info/README.rst b/stock_warehouse_orderpoint_stock_info/README.rst index c0895a440..28ed03dc3 100644 --- a/stock_warehouse_orderpoint_stock_info/README.rst +++ b/stock_warehouse_orderpoint_stock_info/README.rst @@ -2,9 +2,9 @@ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -=========================== -Reordering Rules stock info -=========================== +===================================== +Stock Warehouse Orderpoint Stock Info +===================================== This modules allows to know the product availability directly in the reordering rules. @@ -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 =========== @@ -31,12 +31,14 @@ Credits Contributors ------------ + * Oihane Crucelaegui * Pedro M. Baeza * Ana Juaristi * Jordi Ballester Alomar * Serpent Consulting Services Pvt. Ltd. +Do not contact contributors directly about support or help with technical issues. Maintainer ---------- diff --git a/stock_warehouse_orderpoint_stock_info/__openerp__.py b/stock_warehouse_orderpoint_stock_info/__manifest__.py similarity index 86% rename from stock_warehouse_orderpoint_stock_info/__openerp__.py rename to stock_warehouse_orderpoint_stock_info/__manifest__.py index 7802a3cca..907e77fea 100644 --- a/stock_warehouse_orderpoint_stock_info/__openerp__.py +++ b/stock_warehouse_orderpoint_stock_info/__manifest__.py @@ -7,8 +7,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - "name": "Reordering rules stock info", - "version": "9.0.1.0.0", + "name": "Stock Warehouse Orderpoint Stock Info", + "version": "10.0.1.0.0", "depends": [ "stock", ], @@ -23,5 +23,5 @@ "views/stock_warehouse_orderpoint_view.xml", ], "installable": True, - "auto_install": False, + "application": False, } diff --git a/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py b/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py index c0eaf9a85..d10bb1e1f 100644 --- a/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py +++ b/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py @@ -3,10 +3,11 @@ # Copyright 2016 AvanzOSC # Copyright 2016 Pedro M. Baeza # Copyright 2016 Serpent Consulting Services Pvt. Ltd. -# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# Copyright 2016-17 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): @@ -14,14 +15,21 @@ class StockWarehouseOrderpoint(models.Model): @api.multi def _compute_product_available_qty(self): - 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 = product_available['qty_available'] - rec.incoming_location_qty = product_available['incoming_qty'] - rec.outgoing_location_qty = product_available['outgoing_qty'] - rec.virtual_location_qty = product_available['virtual_available'] + 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_quantities_dict( + lot_id=self.env.context.get('lot_id'), + owner_id=self.env.context.get('owner_id'), + package_id=self.env.context.get('package_id')) + for order in order_in_loc: + product = products[order.product_id.id] + order.product_location_qty = product['qty_available'] + order.incoming_location_qty = product['incoming_qty'] + order.outgoing_location_qty = product['outgoing_qty'] + order.virtual_location_qty = product['virtual_available'] product_location_qty = fields.Float( string='Quantity On Location', @@ -37,4 +45,4 @@ class StockWarehouseOrderpoint(models.Model): compute='_compute_product_available_qty') product_category = fields.Many2one(string='Product Category', related='product_id.categ_id', - store=True) + store=True, readonly=True) diff --git a/stock_warehouse_orderpoint_stock_info/static/description/icon.png b/stock_warehouse_orderpoint_stock_info/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_warehouse_orderpoint_stock_info/static/description/icon.png differ diff --git a/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py b/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py index 6a6880bf3..d7fe7fd6c 100644 --- a/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py +++ b/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py @@ -3,10 +3,10 @@ # Copyright 2016 AvanzOSC # Copyright 2016 Pedro M. Baeza # Copyright 2016 Serpent Consulting Services Pvt. Ltd. -# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# Copyright 2016-17 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 import common class TestStockWarehouseOrderpoint(common.TransactionCase): diff --git a/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml b/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml index c2f5dd464..1ad666b4e 100644 --- a/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml +++ b/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml @@ -1,6 +1,5 @@ - - + stock.warehouse.orderpoint.tree stock.warehouse.orderpoint @@ -50,5 +49,4 @@ - - +