From b9e8b6a8b2cf0f7dde36e27c68ffc4f56a65a8e2 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 10 Oct 2014 11:12:20 +0200 Subject: [PATCH] Make the new test passes, the fields is named supplier_invoice_number not supplier_invoice_reference --- account_invoice_reference/account_invoice.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/account_invoice_reference/account_invoice.py b/account_invoice_reference/account_invoice.py index 0fc78b27..deee487a 100644 --- a/account_invoice_reference/account_invoice.py +++ b/account_invoice_reference/account_invoice.py @@ -59,22 +59,23 @@ class AccountInvoice(orm.Model): return True def create(self, cr, uid, vals, context=None): - if (vals.get('supplier_invoice_reference') and not + if (vals.get('supplier_invoice_number') and not vals.get('reference')): - vals['reference'] = vals['supplier_invoice_reference'] + vals = vals.copy() + vals['reference'] = vals['supplier_invoice_number'] return super(AccountInvoice, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): - if vals.get('supplier_invoice_reference'): - if isinstance(ids, (int, long)): - ids = [ids] + if vals.get('supplier_invoice_number'): for invoice in self.browse(cr, uid, ids, context=context): + loc_vals = None if not invoice.reference: - locvals = vals.copy() - locvals['reference'] = vals['supplier_invoice_reference'] + loc_vals = vals.copy() + loc_vals['reference'] = vals['supplier_invoice_number'] super(AccountInvoice, self).write(cr, uid, [invoice.id], - locvals, context=context) + loc_vals or vals, + context=context) return True else: return super(AccountInvoice, self).write(cr, uid, ids, vals,