diff --git a/stock_available_immediately/__openerp__.py b/stock_available_immediately/__openerp__.py index 41cbb52e2..1cedaa84f 100644 --- a/stock_available_immediately/__openerp__.py +++ b/stock_available_immediately/__openerp__.py @@ -33,8 +33,8 @@ Immediately usable is computed : Quantity on Hand - Outgoing Stock. """, "website": "http://tinyerp.com/module_account.html", "category": "Generic Modules/Stock", - "data": ["product_view.xml", + "data": ["product_view.xml", ], "active": False, - "installable": True + 'installable': True } diff --git a/stock_available_immediately/product.py b/stock_available_immediately/product.py index 51e3b3954..8e6a7dc95 100644 --- a/stock_available_immediately/product.py +++ b/stock_available_immediately/product.py @@ -20,42 +20,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 @@ -137,6 +119,6 @@ class product_immediately_usable(orm.Model): type='float', string='Immediately Usable', multi='qty_available', - help="Quantity of products really available for sale." \ + help="Quantity of products really available for sale." "Computed as: Quantity On Hand - Outgoing."), } diff --git a/stock_available_immediately/product_view.xml b/stock_available_immediately/product_view.xml index 058da3d14..bdd7873f9 100644 --- a/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 +