From d23977c1060ca8f519ba663089c06ed07e33b3d9 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 18 Nov 2013 17:53:53 +0100 Subject: [PATCH] [IMP] account: revert wrong commit 9590 and set default value with customer refrence bzr revid: mat@openerp.com-20131118165353-nbk1wwdri1dnl4wh --- addons/account/wizard/account_invoice_refund.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 0760738a1f0..5f5cffb2954 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -53,10 +53,19 @@ class account_invoice_refund(osv.osv_memory): journal = obj_journal.search(cr, uid, [('type', '=', type), ('company_id','=',company_id)], limit=1, context=context) return journal and journal[0] or False + def _get_reason(self, cr, uid, context=None): + active_id = context and context.get('active_id', False) + if active_id: + inv = self.pool.get('account.invoice').browse(cr, uid, active_id, context=context) + return inv.name + else: + return '' + _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d'), 'journal_id': _get_journal, 'filter_refund': 'refund', + 'description': _get_reason, } def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): @@ -195,7 +204,7 @@ class account_invoice_refund(osv.osv_memory): 'invoice_line': invoice_lines, 'tax_line': tax_lines, 'period_id': period, - 'name': inv.name + 'name': description }) for field in ('partner_id', 'account_id', 'currency_id', 'payment_term', 'journal_id'):