From dd784fa2454e620cb9c1e7015ffa193aaae3557f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 27 Jan 2016 18:35:29 +0100 Subject: [PATCH] Better name_get on stock_move, to make it easier to analyse the reservation of the quants --- stock_usability/stock.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/stock_usability/stock.py b/stock_usability/stock.py index 022d83a..ebf0d87 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -86,6 +86,25 @@ class StockMove(models.Model): availability = fields.Float( digits=dp.get_precision('Product Unit of Measure')) + def name_get(self, cr, uid, ids, context=None): + '''name_get of stock_move is important for the reservation of the + quants: so want to add the name of the customer and the expected date + in it''' + res = [] + for line in self.browse(cr, uid, ids, context=context): + name = line.location_id.name + ' > ' + line.location_dest_id.name + if line.product_id.code: + name = line.product_id.code + ': ' + name + if line.picking_id.origin: + name = line.picking_id.origin + ' ' + name + if line.partner_id: + name = line.partner_id.name + ' ' + name + if line.date_expected: + date_expec_dt = fields.Datetime.from_string(line.date_expected) + name = name + ' ' + fields.Date.to_string(date_expec_dt) + res.append((line.id, name)) + return res + class StockMoveOperationLink(models.Model): _inherit = 'stock.move.operation.link'