diff --git a/crm_rma_stock_location/__init__.py b/crm_rma_stock_location/__init__.py
index 8a614c06..997253d6 100644
--- a/crm_rma_stock_location/__init__.py
+++ b/crm_rma_stock_location/__init__.py
@@ -20,3 +20,4 @@
##############################################################################
from . import stock_warehouse
+from . import product
diff --git a/crm_rma_stock_location/__openerp__.py b/crm_rma_stock_location/__openerp__.py
index 1b3e6d20..59e10eca 100644
--- a/crm_rma_stock_location/__openerp__.py
+++ b/crm_rma_stock_location/__openerp__.py
@@ -39,6 +39,7 @@ The product views displays the quantity available and virtual in this
'website': 'http://www.camptocamp.com',
'data': ['stock_data.xml',
'stock_warehouse_view.xml',
+ 'product_view.xml',
],
'test': [],
'installable': True,
diff --git a/crm_rma_stock_location/product.py b/crm_rma_stock_location/product.py
new file mode 100644
index 00000000..37fcf4b6
--- /dev/null
+++ b/crm_rma_stock_location/product.py
@@ -0,0 +1,104 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2014 Camptocamp SA
+#
+# 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.osv import orm, fields
+import openerp.addons.decimal_precision as dp
+
+
+class ProductProduct(orm.Model):
+ _inherit = 'product.product'
+
+ def _product_available(self, cr, uid, ids, field_names=None, arg=False,
+ context=None):
+ """ Finds the incoming and outgoing quantity of product for the RMA
+ locations.
+ """
+ if field_names is None:
+ field_names = []
+ if context is None:
+ context = {}
+ shop_obj = self.pool['sale.shop']
+ warehouse_obj = self.pool['stock.warehouse']
+ res = {}
+ for id in ids:
+ res[id] = {}.fromkeys(field_names, 0.0)
+
+ for field in field_names:
+ ctx = context.copy()
+
+ warehouse_id = ctx.get('warehouse_id')
+ if ctx.get('shop'):
+ shop_id = ctx['shop']
+ warehouse = shop_obj.read(cr, uid, shop_id,
+ ['warehouse_id'],
+ context=ctx)
+ warehouse_id = warehouse['warehouse_id'][0]
+
+ if warehouse_id:
+ rma_id = warehouse_obj.read(cr, uid,
+ warehouse_id,
+ ['lot_rma_id'],
+ context=ctx)['lot_rma_id'][0]
+ if rma_id:
+ ctx['location'] = rma_id
+ else:
+ location_ids = set()
+ wids = warehouse_obj.search(cr, uid, [], context=context)
+ if not wids:
+ return res
+ for wh in warehouse_obj.browse(cr, uid, wids, context=context):
+ if wh.lot_rma_id:
+ location_ids.add(wh.lot_rma_id.id)
+ if not location_ids:
+ return res
+ ctx['location'] = list(location_ids)
+
+ ctx['compute_child'] = True
+ compute = {
+ 'rma_qty_available': {
+ 'states': ('done', ),
+ 'what': ('in', 'out')
+ },
+ 'rma_virtual_available': {
+ 'states': ('confirmed', 'waiting', 'assigned', 'done'),
+ 'what': ('in', 'out')
+ }
+ }
+ ctx.update(compute[field])
+ stock = self.get_product_available(cr, uid, ids, context=ctx)
+ for id in ids:
+ res[id][field] = stock.get(id, 0.0)
+ return res
+
+ _columns = {
+ 'rma_qty_available': fields.function(
+ _product_available,
+ type='float',
+ multi='rma_qty',
+ digits_compute=dp.get_precision('Product Unit of Measure'),
+ string='RMA Quantity On Hand'),
+ 'rma_virtual_available': fields.function(
+ _product_available,
+ type='float',
+ multi='rma_qty',
+ digits_compute=dp.get_precision('Product Unit of Measure'),
+ string='RMA Quantity Available'),
+ }
diff --git a/crm_rma_stock_location/product_view.xml b/crm_rma_stock_location/product_view.xml
new file mode 100644
index 00000000..c371eead
--- /dev/null
+++ b/crm_rma_stock_location/product_view.xml
@@ -0,0 +1,28 @@
+
+
+
+
+ product.product.tree
+ product.product
+
+
+
+
+
+
+
+
+
+
+ product.normal.procurement.locations.inherit
+ product.product
+
+
+
+
+
+
+
+
+
+