Merge pull request #53 from guewen/account_invoice_reference-ref-fix

Wrong field name
This commit is contained in:
Yannick Vaucher
2014-10-17 15:50:53 +02:00
3 changed files with 57 additions and 6 deletions

View File

@@ -141,6 +141,7 @@ Information propagated to the move lines:
'test/out_refund_without_origin.yml',
'test/in_refund_with_supplier_number.yml',
'test/in_refund_without_supplier_number.yml',
'test/supplier_invoice_number.yml',
],
'installable': True,

View File

@@ -79,22 +79,25 @@ 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 vals.get('supplier_invoice_number'):
if isinstance(ids, (int, long)):
ids = [ids]
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,

View File

@@ -0,0 +1,47 @@
-
In order to check if the reference is populated from the supplier_invoice_number
I create an invoice.
-
!record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}:
account_id: account.a_pay
check_total: 3000.0
company_id: base.main_company
currency_id: base.EUR
invoice_line:
- account_id: account.a_expense
name: '[PCSC234] PC Assemble SC234'
price_unit: 300.0
product_id: product.product_product_3
quantity: 10.0
uos_id: product.product_uom_unit
journal_id: account.expenses_journal
partner_id: base.res_partner_12
reference_type: none
supplier_invoice_number: ZZZ246
type: in_invoice
-
Set again the type of the invoice (not set on the first one...)
-
!record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}:
type: in_invoice
-
Ensure that the reference is the same than the supplier_invoice_number
-
!assert {model: account.invoice, id: invoice_supplier_invoice_number}:
- reference == 'ZZZ246'
-
In order to check if the supplier_invoice_number is copied to the supplier_invoice_number
when the reference is empty, I empty the reference
-
!record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}:
reference:
-
And I write a new supplier_invoice_number
-
!record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}:
supplier_invoice_number: ABC789
-
Ensure that the reference is the same than the supplier_invoice_number
-
!assert {model: account.invoice, id: invoice_supplier_invoice_number}:
- reference == 'ABC789'