diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a9eba683341..3b1711d65e4 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -92,6 +92,9 @@ class stock_location(osv.osv): res[m.id] = ' / '.join(reversed(names)) return res + def _get_sublocations(self, cr, uid, ids, context=None): + """ return all sublocations of the given stock locations (included) """ + return self.search(cr, uid, [('id', 'child_of', ids)], context=context) def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @@ -154,7 +157,8 @@ class stock_location(osv.osv): \n* Production: Virtual counterpart location for production operations: this location consumes the raw material and produces finished products """, select = True), # temporarily removed, as it's unused: 'allocation_method': fields.selection([('fifo', 'FIFO'), ('lifo', 'LIFO'), ('nearest', 'Nearest')], 'Allocation Method', required=True), - 'complete_name': fields.function(_complete_name, type='char', size=256, string="Location Name"), + 'complete_name': fields.function(_complete_name, type='char', size=256, string="Location Name", + store={'stock.location': (_get_sublocations, ['name', 'location_id'], 10)}), 'stock_real': fields.function(_product_value, type='float', string='Real Stock', multi="stock"), 'stock_virtual': fields.function(_product_value, type='float', string='Virtual Stock', multi="stock"),