From 9d97678712ef85b4c98730d5e15ccf2721875ae3 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Tue, 8 Sep 2015 18:06:12 +0200 Subject: [PATCH 1/8] Revert changes to computation of _immediately_usable_qty Commit 6c16913 changed the way we compute the immediately_usable_qty: instead of using the virtual stock, we used the sum of quants without reservations. But a quant may actually be reserved and still be available (for example it may be reserved for an internal move). Fixes https://github.com/OCA/stock-logistics-warehouse/issues/79 --- stock_available/product.py | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/stock_available/product.py b/stock_available/product.py index 199a8ef63..b3bfd9cdc 100644 --- a/stock_available/product.py +++ b/stock_available/product.py @@ -29,35 +29,23 @@ class ProductTemplate(models.Model): """ _inherit = 'product.template' - # immediately usable quantity caluculated with the quant method @api.multi @api.depends('virtual_available') def _immediately_usable_qty(self): - stock_location_obj = self.env['stock.location'] - internal_locations = stock_location_obj.search([ - ('usage', '=', 'internal')]) - sublocations = self.env['stock.location'] - for location in internal_locations: - sublocations += stock_location_obj.search( - [('id', 'child_of', location.id)]) - for product_template in self: - products = self.env['product.product'].search([ - ('product_tmpl_id', '=', product_template.id)]) - quant_obj = self.env['stock.quant'] - quants = quant_obj.search([ - ('location_id', 'in', sublocations.ids), - ('product_id', 'in', products.ids), - ('reservation_id', '=', False)]) - availability = 0 - if quants: - for quant in quants: - availability += quant.qty - product_template.immediately_usable_qty = availability + """No-op implementation of the stock available to promise. + + By default, available to promise = forecasted quantity. + + Must be overridden by another module that actually implement + computations.""" + for product in self: + product.immediately_usable_qty = product.virtual_available + immediately_usable_qty = fields.Float( digits=dp.get_precision('Product Unit of Measure'), compute='_immediately_usable_qty', - string='Available to promise (quant calculation)', + string='Available to promise', help="Stock for this Product that can be safely proposed " "for sale to Customers.\n" "The definition of this value can be configured to suit " From b7decf20afa170a5c067e905f00608ef2a89bacc Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Tue, 8 Sep 2015 18:14:13 +0200 Subject: [PATCH 2/8] Remove loop and use correct decorator --- stock_available/product.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stock_available/product.py b/stock_available/product.py index b3bfd9cdc..430ec432f 100644 --- a/stock_available/product.py +++ b/stock_available/product.py @@ -29,7 +29,7 @@ class ProductTemplate(models.Model): """ _inherit = 'product.template' - @api.multi + @api.one @api.depends('virtual_available') def _immediately_usable_qty(self): """No-op implementation of the stock available to promise. @@ -38,8 +38,7 @@ class ProductTemplate(models.Model): Must be overridden by another module that actually implement computations.""" - for product in self: - product.immediately_usable_qty = product.virtual_available + self.immediately_usable_qty = self.virtual_available immediately_usable_qty = fields.Float( From 11a308372ece3ba53ad35f7fcf47087d68ade654 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Wed, 9 Sep 2015 14:06:44 +0200 Subject: [PATCH 3/8] Revert "[DEL] remove old tests, rewriting" This reverts commit c74aab47e9d41e2343d3f238da3299e5f7fd0c8c. --- stock_available_immediately/tests/__init__.py | 1 + .../tests/test_stock_available_immediately.py | 120 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 stock_available_immediately/tests/__init__.py create mode 100644 stock_available_immediately/tests/test_stock_available_immediately.py diff --git a/stock_available_immediately/tests/__init__.py b/stock_available_immediately/tests/__init__.py new file mode 100644 index 000000000..84148ecde --- /dev/null +++ b/stock_available_immediately/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_available_immediately diff --git a/stock_available_immediately/tests/test_stock_available_immediately.py b/stock_available_immediately/tests/test_stock_available_immediately.py new file mode 100644 index 000000000..2c46f6460 --- /dev/null +++ b/stock_available_immediately/tests/test_stock_available_immediately.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.tests.common import TransactionCase + + +class testStockLogisticsWarehouse(TransactionCase): + + def test01_stock_levels(self): + """checking that immediately_usable_qty actually reflects \ +the variations in stock, both on product and template""" + moveObj = self.env['stock.move'] + productObj = self.env['product.product'] + templateObj = self.env['product.template'] + supplier_location = self.env.ref('stock.stock_location_suppliers') + stock_location = self.env.ref('stock.stock_location_stock') + customer_location = self.env.ref('stock.stock_location_customers') + uom_unit = self.env.ref('product.product_uom_unit') + + # Create product template + templateAB = templateObj.create( + {'name': 'templAB', + 'uom_id': uom_unit.id, + }) + + # Create product A and B + productA = productObj.create( + {'name': 'product A', + 'standard_price': 1, + 'type': 'product', + 'uom_id': uom_unit.id, + 'default_code': 'A', + 'product_tmpl_id': templateAB.id, + }) + + productB = productObj.create( + {'name': 'product B', + 'standard_price': 1, + 'type': 'product', + 'uom_id': uom_unit.id, + 'default_code': 'B', + 'product_tmpl_id': templateAB.id, + }) + + # Create a stock move from INCOMING to STOCK + stockMoveInA = moveObj.create( + {'location_id': supplier_location.id, + 'location_dest_id': stock_location.id, + 'name': 'MOVE INCOMING -> STOCK ', + 'product_id': productA.id, + 'product_uom': productA.uom_id.id, + 'product_uom_qty': 2, + }) + + stockMoveInB = moveObj.create( + {'location_id': supplier_location.id, + 'location_dest_id': stock_location.id, + 'name': 'MOVE INCOMING -> STOCK ', + 'product_id': productB.id, + 'product_uom': productB.uom_id.id, + 'product_uom_qty': 3, + }) + + def compare_product_usable_qty(product, value): + # Refresh, because the function field is not recalculated between + # transactions + product.refresh() + self.assertEqual(product.immediately_usable_qty, value) + + compare_product_usable_qty(productA, 0) + compare_product_usable_qty(templateAB, 0) + + stockMoveInA.action_confirm() + compare_product_usable_qty(productA, 0) + compare_product_usable_qty(templateAB, 0) + + stockMoveInA.action_assign() + compare_product_usable_qty(productA, 0) + compare_product_usable_qty(templateAB, 0) + + stockMoveInA.action_done() + compare_product_usable_qty(productA, 2) + compare_product_usable_qty(templateAB, 2) + + # will directly trigger action_done on productB + stockMoveInB.action_done() + compare_product_usable_qty(productA, 2) + compare_product_usable_qty(productB, 3) + compare_product_usable_qty(templateAB, 5) + + # Create a stock move from STOCK to CUSTOMER + stockMoveOutA = moveObj.create( + {'location_id': stock_location.id, + 'location_dest_id': customer_location.id, + 'name': ' STOCK --> CUSTOMER ', + 'product_id': productA.id, + 'product_uom': productA.uom_id.id, + 'product_uom_qty': 1, + 'state': 'confirmed', + }) + + stockMoveOutA.action_done() + compare_product_usable_qty(productA, 1) + compare_product_usable_qty(templateAB, 4) From bc25e1395d01ec41cab9a3640af7b1502fb3e456 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Wed, 9 Sep 2015 14:06:49 +0200 Subject: [PATCH 4/8] Revert "[DEL] removed references to product.py, not needed anymore, the quant calculations done in product template are fine." This reverts commit d6dee6f90dfe0403da5c59bc0685c7324dd11d3e. --- stock_available_immediately/__init__.py | 2 ++ stock_available_immediately/product.py | 33 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 stock_available_immediately/product.py diff --git a/stock_available_immediately/__init__.py b/stock_available_immediately/__init__.py index 867607b7d..46f811108 100755 --- a/stock_available_immediately/__init__.py +++ b/stock_available_immediately/__init__.py @@ -17,3 +17,5 @@ # along with this program. If not, see . # ############################################################################## + +from . import product diff --git a/stock_available_immediately/product.py b/stock_available_immediately/product.py new file mode 100644 index 000000000..491e44d1d --- /dev/null +++ b/stock_available_immediately/product.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright 2010-2012 Camptocamp SA +# Copyright (C) 2011 Akretion Sébastien BEAU +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models + + +class Product(models.Model): + """Subtract incoming qty from immediately_usable_qty""" + _inherit = 'product.product' + + def _immediately_usable_qty(self): + """Ignore the incoming goods in the quantity available to promise""" + super(Product, self)._immediately_usable_qty() + for product in self: + product.immediately_usable_qty -= product.incoming_qty From 3f45564185243fa3014eb65b6fae97e9e2d4f066 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Wed, 9 Sep 2015 15:03:40 +0200 Subject: [PATCH 5/8] Restore the features of stock_available_immediately The previous fix restored stock_available but then there was no way to exclude the incomming moves from the count. This belongs in stock_available_immediately, restoring it cleanly. This commit also takes care to respect the distinction between templates and variants, so it should fix https://github.com/OCA/stock-logistics-warehouse/issues/73 too. --- stock_available/__init__.py | 3 +- stock_available/__openerp__.py | 4 +- stock_available/models/__init__.py | 23 ++++ .../{product.py => models/product_product.py} | 8 +- stock_available/models/product_template.py | 45 +++++++ stock_available/{ => models}/res_config.py | 0 stock_available/tests/test_stock_available.py | 120 ------------------ stock_available/{ => views}/product_view.xml | 0 .../{ => views}/res_config_view.xml | 0 stock_available_immediately/__init__.py | 2 +- .../models/__init__.py | 21 +++ .../{product.py => models/product_product.py} | 11 +- stock_available_immediately/tests/__init__.py | 2 + 13 files changed, 103 insertions(+), 136 deletions(-) create mode 100644 stock_available/models/__init__.py rename stock_available/{product.py => models/product_product.py} (88%) create mode 100644 stock_available/models/product_template.py rename stock_available/{ => models}/res_config.py (100%) delete mode 100644 stock_available/tests/test_stock_available.py rename stock_available/{ => views}/product_view.xml (100%) rename stock_available/{ => views}/res_config_view.xml (100%) create mode 100755 stock_available_immediately/models/__init__.py rename stock_available_immediately/{product.py => models/product_product.py} (81%) diff --git a/stock_available/__init__.py b/stock_available/__init__.py index 6dff1269a..036bf665c 100644 --- a/stock_available/__init__.py +++ b/stock_available/__init__.py @@ -18,5 +18,4 @@ # ############################################################################## -from . import product -from . import res_config +from . import models diff --git a/stock_available/__openerp__.py b/stock_available/__openerp__.py index 0f2042a78..55f7f217b 100644 --- a/stock_available/__openerp__.py +++ b/stock_available/__openerp__.py @@ -26,7 +26,7 @@ 'depends': ['stock'], 'license': 'AGPL-3', 'data': [ - 'product_view.xml', - 'res_config_view.xml', + 'views/product_view.xml', + 'views/res_config_view.xml', ] } diff --git a/stock_available/models/__init__.py b/stock_available/models/__init__.py new file mode 100644 index 000000000..bf26a289f --- /dev/null +++ b/stock_available/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import product_template +from . import product_product +from . import res_config diff --git a/stock_available/product.py b/stock_available/models/product_product.py similarity index 88% rename from stock_available/product.py rename to stock_available/models/product_product.py index 430ec432f..b7ff07210 100644 --- a/stock_available/product.py +++ b/stock_available/models/product_product.py @@ -22,12 +22,12 @@ from openerp import models, fields, api from openerp.addons import decimal_precision as dp -class ProductTemplate(models.Model): +class ProductProduct(models.Model): """Add a field for the stock available to promise. Useful implementations need to be installed through the Settings menu or by installing one of the modules stock_available_* """ - _inherit = 'product.template' + _inherit = 'product.product' @api.one @api.depends('virtual_available') @@ -48,6 +48,4 @@ class ProductTemplate(models.Model): help="Stock for this Product that can be safely proposed " "for sale to Customers.\n" "The definition of this value can be configured to suit " - "your needs , this number is obtained by using the new odoo 8 " - "quants, so it gives us the actual current quants minus reserved" - "quants") + "your needs") diff --git a/stock_available/models/product_template.py b/stock_available/models/product_template.py new file mode 100644 index 000000000..6fbb204cb --- /dev/null +++ b/stock_available/models/product_template.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields, api +from openerp.addons import decimal_precision as dp + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + + + @api.one + @api.depends('virtual_available') + def _immediately_usable_qty(self): + """Compute the quantity using all the variants""" + self.immediately_usable_qty = sum( + [v.immediately_usable_qty for v in self.product_variant_ids]) + + + immediately_usable_qty = fields.Float( + digits=dp.get_precision('Product Unit of Measure'), + compute='_immediately_usable_qty', + string='Available to promise', + help="Stock for this Product that can be safely proposed " + "for sale to Customers.\n" + "The definition of this value can be configured to suit " + "your needs") diff --git a/stock_available/res_config.py b/stock_available/models/res_config.py similarity index 100% rename from stock_available/res_config.py rename to stock_available/models/res_config.py diff --git a/stock_available/tests/test_stock_available.py b/stock_available/tests/test_stock_available.py deleted file mode 100644 index 2c46f6460..000000000 --- a/stock_available/tests/test_stock_available.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Therp BV -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -from openerp.tests.common import TransactionCase - - -class testStockLogisticsWarehouse(TransactionCase): - - def test01_stock_levels(self): - """checking that immediately_usable_qty actually reflects \ -the variations in stock, both on product and template""" - moveObj = self.env['stock.move'] - productObj = self.env['product.product'] - templateObj = self.env['product.template'] - supplier_location = self.env.ref('stock.stock_location_suppliers') - stock_location = self.env.ref('stock.stock_location_stock') - customer_location = self.env.ref('stock.stock_location_customers') - uom_unit = self.env.ref('product.product_uom_unit') - - # Create product template - templateAB = templateObj.create( - {'name': 'templAB', - 'uom_id': uom_unit.id, - }) - - # Create product A and B - productA = productObj.create( - {'name': 'product A', - 'standard_price': 1, - 'type': 'product', - 'uom_id': uom_unit.id, - 'default_code': 'A', - 'product_tmpl_id': templateAB.id, - }) - - productB = productObj.create( - {'name': 'product B', - 'standard_price': 1, - 'type': 'product', - 'uom_id': uom_unit.id, - 'default_code': 'B', - 'product_tmpl_id': templateAB.id, - }) - - # Create a stock move from INCOMING to STOCK - stockMoveInA = moveObj.create( - {'location_id': supplier_location.id, - 'location_dest_id': stock_location.id, - 'name': 'MOVE INCOMING -> STOCK ', - 'product_id': productA.id, - 'product_uom': productA.uom_id.id, - 'product_uom_qty': 2, - }) - - stockMoveInB = moveObj.create( - {'location_id': supplier_location.id, - 'location_dest_id': stock_location.id, - 'name': 'MOVE INCOMING -> STOCK ', - 'product_id': productB.id, - 'product_uom': productB.uom_id.id, - 'product_uom_qty': 3, - }) - - def compare_product_usable_qty(product, value): - # Refresh, because the function field is not recalculated between - # transactions - product.refresh() - self.assertEqual(product.immediately_usable_qty, value) - - compare_product_usable_qty(productA, 0) - compare_product_usable_qty(templateAB, 0) - - stockMoveInA.action_confirm() - compare_product_usable_qty(productA, 0) - compare_product_usable_qty(templateAB, 0) - - stockMoveInA.action_assign() - compare_product_usable_qty(productA, 0) - compare_product_usable_qty(templateAB, 0) - - stockMoveInA.action_done() - compare_product_usable_qty(productA, 2) - compare_product_usable_qty(templateAB, 2) - - # will directly trigger action_done on productB - stockMoveInB.action_done() - compare_product_usable_qty(productA, 2) - compare_product_usable_qty(productB, 3) - compare_product_usable_qty(templateAB, 5) - - # Create a stock move from STOCK to CUSTOMER - stockMoveOutA = moveObj.create( - {'location_id': stock_location.id, - 'location_dest_id': customer_location.id, - 'name': ' STOCK --> CUSTOMER ', - 'product_id': productA.id, - 'product_uom': productA.uom_id.id, - 'product_uom_qty': 1, - 'state': 'confirmed', - }) - - stockMoveOutA.action_done() - compare_product_usable_qty(productA, 1) - compare_product_usable_qty(templateAB, 4) diff --git a/stock_available/product_view.xml b/stock_available/views/product_view.xml similarity index 100% rename from stock_available/product_view.xml rename to stock_available/views/product_view.xml diff --git a/stock_available/res_config_view.xml b/stock_available/views/res_config_view.xml similarity index 100% rename from stock_available/res_config_view.xml rename to stock_available/views/res_config_view.xml diff --git a/stock_available_immediately/__init__.py b/stock_available_immediately/__init__.py index 46f811108..207739f8d 100755 --- a/stock_available_immediately/__init__.py +++ b/stock_available_immediately/__init__.py @@ -18,4 +18,4 @@ # ############################################################################## -from . import product +from . import models diff --git a/stock_available_immediately/models/__init__.py b/stock_available_immediately/models/__init__.py new file mode 100755 index 000000000..5ec9a622a --- /dev/null +++ b/stock_available_immediately/models/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Author Guewen Baconnier. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import product_product diff --git a/stock_available_immediately/product.py b/stock_available_immediately/models/product_product.py similarity index 81% rename from stock_available_immediately/product.py rename to stock_available_immediately/models/product_product.py index 491e44d1d..d3050f872 100644 --- a/stock_available_immediately/product.py +++ b/stock_available_immediately/models/product_product.py @@ -19,15 +19,14 @@ # ############################################################################## -from openerp import models +from openerp import models, api -class Product(models.Model): - """Subtract incoming qty from immediately_usable_qty""" +class ProductProduct(models.Model): _inherit = 'product.product' + @api.one def _immediately_usable_qty(self): """Ignore the incoming goods in the quantity available to promise""" - super(Product, self)._immediately_usable_qty() - for product in self: - product.immediately_usable_qty -= product.incoming_qty + super(ProductProduct, self)._immediately_usable_qty() + self.immediately_usable_qty -= self.incoming_qty diff --git a/stock_available_immediately/tests/__init__.py b/stock_available_immediately/tests/__init__.py index 84148ecde..d6af52dfa 100644 --- a/stock_available_immediately/tests/__init__.py +++ b/stock_available_immediately/tests/__init__.py @@ -1 +1,3 @@ +# -*- encoding: utf-8 -*- + from . import test_stock_available_immediately From 2014a87a189d7068a105030fb38dea064a6af3c8 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Thu, 10 Sep 2015 14:55:27 +0200 Subject: [PATCH 6/8] Restore the qty avail. to promise on variant treeview --- stock_available/__openerp__.py | 3 ++- .../views/product_product_view.xml | 20 +++++++++++++++++++ ...uct_view.xml => product_template_view.xml} | 0 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 stock_available/views/product_product_view.xml rename stock_available/views/{product_view.xml => product_template_view.xml} (100%) diff --git a/stock_available/__openerp__.py b/stock_available/__openerp__.py index 55f7f217b..cbcd39b70 100644 --- a/stock_available/__openerp__.py +++ b/stock_available/__openerp__.py @@ -26,7 +26,8 @@ 'depends': ['stock'], 'license': 'AGPL-3', 'data': [ - 'views/product_view.xml', + 'views/product_template_view.xml', + 'views/product_product_view.xml', 'views/res_config_view.xml', ] } diff --git a/stock_available/views/product_product_view.xml b/stock_available/views/product_product_view.xml new file mode 100644 index 000000000..22dd36b2e --- /dev/null +++ b/stock_available/views/product_product_view.xml @@ -0,0 +1,20 @@ + + + + + Quantity available to promise (variant tree) + product.product + + + + + red:immediately_usable_qty<0;blue:immediately_usable_qty>=0 and state in ('draft', 'end', 'obsolete');black:immediately_usable_qty>=0 and state not in ('draft', 'end', 'obsolete') + + + + + + + + + diff --git a/stock_available/views/product_view.xml b/stock_available/views/product_template_view.xml similarity index 100% rename from stock_available/views/product_view.xml rename to stock_available/views/product_template_view.xml From fe44a2cbe3169056bd9e703e656c6c84e8c71e04 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Thu, 10 Sep 2015 15:25:49 +0200 Subject: [PATCH 7/8] PEP8 --- stock_available/models/product_product.py | 1 - stock_available/models/product_template.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/stock_available/models/product_product.py b/stock_available/models/product_product.py index b7ff07210..c529040b7 100644 --- a/stock_available/models/product_product.py +++ b/stock_available/models/product_product.py @@ -40,7 +40,6 @@ class ProductProduct(models.Model): computations.""" self.immediately_usable_qty = self.virtual_available - immediately_usable_qty = fields.Float( digits=dp.get_precision('Product Unit of Measure'), compute='_immediately_usable_qty', diff --git a/stock_available/models/product_template.py b/stock_available/models/product_template.py index 6fbb204cb..fe55ecc47 100644 --- a/stock_available/models/product_template.py +++ b/stock_available/models/product_template.py @@ -25,8 +25,6 @@ from openerp.addons import decimal_precision as dp class ProductTemplate(models.Model): _inherit = 'product.template' - - @api.one @api.depends('virtual_available') def _immediately_usable_qty(self): @@ -34,7 +32,6 @@ class ProductTemplate(models.Model): self.immediately_usable_qty = sum( [v.immediately_usable_qty for v in self.product_variant_ids]) - immediately_usable_qty = fields.Float( digits=dp.get_precision('Product Unit of Measure'), compute='_immediately_usable_qty', From aa6478d244aa25d37b5112c7c00724389f553905 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Wed, 16 Sep 2015 09:35:18 +0200 Subject: [PATCH 8/8] Fix the beta lint checks of Travis --- stock_available_immediately/__init__.py | 2 +- stock_available_immediately/models/__init__.py | 2 +- stock_available_immediately/tests/__init__.py | 2 +- .../tests/test_stock_available_immediately.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) mode change 100755 => 100644 stock_available_immediately/__init__.py mode change 100755 => 100644 stock_available_immediately/models/__init__.py diff --git a/stock_available_immediately/__init__.py b/stock_available_immediately/__init__.py old mode 100755 new mode 100644 index 207739f8d..4c76a5131 --- a/stock_available_immediately/__init__.py +++ b/stock_available_immediately/__init__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author Guewen Baconnier. Copyright Camptocamp SA diff --git a/stock_available_immediately/models/__init__.py b/stock_available_immediately/models/__init__.py old mode 100755 new mode 100644 index 5ec9a622a..a28883030 --- a/stock_available_immediately/models/__init__.py +++ b/stock_available_immediately/models/__init__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # Author Guewen Baconnier. Copyright Camptocamp SA diff --git a/stock_available_immediately/tests/__init__.py b/stock_available_immediately/tests/__init__.py index d6af52dfa..8185fdf1f 100644 --- a/stock_available_immediately/tests/__init__.py +++ b/stock_available_immediately/tests/__init__.py @@ -1,3 +1,3 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- from . import test_stock_available_immediately diff --git a/stock_available_immediately/tests/test_stock_available_immediately.py b/stock_available_immediately/tests/test_stock_available_immediately.py index 2c46f6460..be9f43006 100644 --- a/stock_available_immediately/tests/test_stock_available_immediately.py +++ b/stock_available_immediately/tests/test_stock_available_immediately.py @@ -20,7 +20,7 @@ from openerp.tests.common import TransactionCase -class testStockLogisticsWarehouse(TransactionCase): +class TestStockLogisticsWarehouse(TransactionCase): def test01_stock_levels(self): """checking that immediately_usable_qty actually reflects \