diff --git a/__unported__/stock_available_immediately/__init__.py b/stock_available_immediately/__init__.py similarity index 100% rename from __unported__/stock_available_immediately/__init__.py rename to stock_available_immediately/__init__.py diff --git a/__unported__/stock_available_immediately/__openerp__.py b/stock_available_immediately/__openerp__.py similarity index 98% rename from __unported__/stock_available_immediately/__openerp__.py rename to stock_available_immediately/__openerp__.py index 080dbe620..1cedaa84f 100644 --- a/__unported__/stock_available_immediately/__openerp__.py +++ b/stock_available_immediately/__openerp__.py @@ -36,5 +36,5 @@ Immediately usable is computed : Quantity on Hand - Outgoing Stock. "data": ["product_view.xml", ], "active": False, - 'installable': False + 'installable': True } diff --git a/__unported__/stock_available_immediately/product.py b/stock_available_immediately/product.py similarity index 87% rename from __unported__/stock_available_immediately/product.py rename to stock_available_immediately/product.py index cbc3a3639..fc3d1bd1a 100644 --- a/__unported__/stock_available_immediately/product.py +++ b/stock_available_immediately/product.py @@ -24,38 +24,24 @@ from openerp.addons import decimal_precision as dp from openerp.osv import orm, fields -class product_immediately_usable(orm.Model): +class ProductTemplate(orm.Model): """ - Inherit Product in order to add an "immediately usable quantity" - stock field Immediately usable quantity is : real stock - outgoing qty """ - _inherit = 'product.product' + _inherit = 'product.template' def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None): """ Get super() _product_available and compute immediately_usable_qty """ - # We need available and outgoing quantities to compute - # immediately usable quantity. - # When immediately_usable_qty is displayed but - # not qty_available and outgoing_qty, - # they are not computed in the super method so we cannot - # compute immediately_usable_qty. - # To avoid this issue, we add the 2 fields in - # field_names to compute them. - if 'immediately_usable_qty' in field_names: - field_names.append('qty_available') - field_names.append('outgoing_qty') - - res = super(product_immediately_usable, self)._product_available( + res = super(ProductTemplate, self)._product_available( cr, uid, ids, field_names, arg, context) if 'immediately_usable_qty' in field_names: for product_id, stock_qty in res.iteritems(): res[product_id]['immediately_usable_qty'] = \ - stock_qty['qty_available'] + stock_qty['outgoing_qty'] + stock_qty['qty_available'] - stock_qty['outgoing_qty'] return res diff --git a/__unported__/stock_available_immediately/product_view.xml b/stock_available_immediately/product_view.xml similarity index 75% rename from __unported__/stock_available_immediately/product_view.xml rename to stock_available_immediately/product_view.xml index 058da3d14..bdd7873f9 100644 --- a/__unported__/stock_available_immediately/product_view.xml +++ b/stock_available_immediately/product_view.xml @@ -11,20 +11,24 @@ product.normal.stock.active.qty.form.inherit - product.product - + product.template + + + + + - + - + product_immediately_usable.product_product_tree_view - product.product - + product.template + diff --git a/stock_reserve/view/product.xml b/stock_reserve/view/product.xml index e4e1dc3fb..09ff9a2fe 100644 --- a/stock_reserve/view/product.xml +++ b/stock_reserve/view/product.xml @@ -1,25 +1,10 @@ - - - product.template.reservation.button - product.template - - - - - - - - product.template.reservation.button product.product - +