From 6a05e60800fee58a76b57fada6d5a4779afd29f0 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 27 Jan 2012 14:55:37 +0100 Subject: [PATCH] [FIX] stock: fix recomputation of complete_name of stock.location bzr revid: rco@openerp.com-20120127135537-cfwkzzl221doz2um --- addons/stock/stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"),