From dbbea6df2c3d549c4bfb71bc4bddd5ed6fc33875 Mon Sep 17 00:00:00 2001 From: EL HADJI DEM Date: Thu, 25 Sep 2014 15:10:03 -0400 Subject: [PATCH] [UPD] In create method, use name unless name_get to define res_name value --- document_multiple_records/document.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/document_multiple_records/document.py b/document_multiple_records/document.py index 5e8456a9..f01acfc8 100644 --- a/document_multiple_records/document.py +++ b/document_multiple_records/document.py @@ -37,14 +37,18 @@ class document_file(orm.Model): res = super(document_file, self).create(cr, uid, data, context=context) # Create attachment_document_ids with res_model, res_id and res_name if 'res_model' in data and 'res_id' in data: + res_model_lines = self.pool.get(data['res_model']).browse( + cr, uid, data['res_id'], context=context) + # Default value + res_name = res_model_lines.name_get()[0][1] + # For account.voucher model, take the name field + if data['res_model'] == 'account.voucher': + res_name = res_model_lines.name ir_attachment_document_obj.create(cr, uid, { 'attachment_id': res, 'res_model': data['res_model'], 'res_id': data['res_id'], - 'res_name': data.get( - 'res_name', self.pool.get(data['res_model']).browse( - cr, uid, data['res_id'], - context=context).name_get()[0][1]), + 'res_name': data.get('res_name', res_name), }, context=context) return res