mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
account_invoice_reference: ensure that the ref is always what we want, added tests
This commit is contained in:
@@ -54,7 +54,10 @@ Supplier invoices
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': ['account_invoice_view.xml',
|
||||
],
|
||||
'test': ['test/in_invoice_with_origin.yml',
|
||||
'test': ['test/out_invoice_with_origin.yml',
|
||||
'test/out_invoice_without_origin.yml',
|
||||
'test/in_invoice_with_supplier_number.yml',
|
||||
'test/in_invoice_without_supplier_number.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
|
||||
@@ -34,9 +34,8 @@ class account_move(orm.Model):
|
||||
assert isinstance(invoice, orm.browse_record)
|
||||
invoice_obj = self.pool['account.invoice']
|
||||
ref = invoice_obj._ref_from_invoice(cr, uid, invoice, context=context)
|
||||
if ref:
|
||||
vals = vals.copy()
|
||||
vals['ref'] = ref
|
||||
vals = vals.copy()
|
||||
vals['ref'] = ref
|
||||
move_id = super(account_move, self).\
|
||||
create(cr, uid, vals, context=context)
|
||||
return move_id
|
||||
@@ -48,7 +47,7 @@ class account_invoice(orm.Model):
|
||||
def _ref_from_invoice(self, cr, uid, invoice, context=None):
|
||||
if invoice.type in ('out_invoice', 'out_refund'):
|
||||
return invoice.origin
|
||||
elif invoice.type == ('in_invoice', 'in_refund'):
|
||||
elif invoice.type in ('in_invoice', 'in_refund'):
|
||||
return invoice.supplier_invoice_number
|
||||
|
||||
def action_number(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
-
|
||||
In order to check if the reference of the move is the supplier invoice number of
|
||||
the invoice (supplier invoices), I create an invoice
|
||||
-
|
||||
!record {model: account.invoice, id: invoice_reference_supplier_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_reference_supplier_number, view: account.invoice_supplier_form}:
|
||||
type: in_invoice
|
||||
-
|
||||
Ensure that the invoice is a supplier invoice
|
||||
-
|
||||
!assert {model: account.invoice, id: invoice_reference_supplier_number}:
|
||||
- type == 'in_invoice'
|
||||
-
|
||||
I create invoice by clicking on Create button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: invoice_reference_supplier_number}
|
||||
-
|
||||
I check that the reference of the move is the supplier invoice number of the invoice
|
||||
-
|
||||
!assert {model: account.invoice, id: invoice_reference_supplier_number}:
|
||||
- move_id.ref == 'ZZZ246'
|
||||
@@ -0,0 +1,39 @@
|
||||
-
|
||||
In order to check if the reference of the move is the supplier invoice number of
|
||||
the invoice (supplier invoices), I create an invoice
|
||||
-
|
||||
!record {model: account.invoice, id: invoice_reference_no_supplier_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
|
||||
type: in_invoice
|
||||
-
|
||||
Set again the type of the invoice (not set on the first one...)
|
||||
-
|
||||
!record {model: account.invoice, id: invoice_reference_supplier_number, view: account.invoice_supplier_form}:
|
||||
type: in_invoice
|
||||
-
|
||||
Ensure that the invoice is a supplier invoice
|
||||
-
|
||||
!assert {model: account.invoice, id: invoice_reference_supplier_number}:
|
||||
- type == 'in_invoice'
|
||||
-
|
||||
I create invoice by clicking on Create button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: invoice_reference_no_supplier_number}
|
||||
-
|
||||
I check that the reference of the move is the number of the invoice
|
||||
-
|
||||
!assert {model: account.invoice, id: invoice_reference_no_supplier_number}:
|
||||
- move_id.ref == number
|
||||
@@ -1,5 +1,5 @@
|
||||
-
|
||||
In order to check if the reference of the invoice is the origin of
|
||||
In order to check if the reference of the move is the origin of
|
||||
the invoice (customer invoices), I create an invoice
|
||||
-
|
||||
!record {model: account.invoice, id: invoice_reference_origin}:
|
||||
@@ -0,0 +1,22 @@
|
||||
-
|
||||
In order to check if the reference of the move is the number of
|
||||
the invoice (customer invoices) when it has no origin, I create an invoice
|
||||
-
|
||||
!record {model: account.invoice, id: invoice_reference_no_origin}:
|
||||
payment_term: account.account_payment_term_advance
|
||||
journal_id: account.sales_journal
|
||||
partner_id: base.res_partner_3
|
||||
reference_type: none
|
||||
name: 'Test Customer Invoice no origin'
|
||||
invoice_line:
|
||||
- product_id: product.product_product_5
|
||||
quantity: 10.0
|
||||
-
|
||||
I create invoice by clicking on Create button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: invoice_reference_no_origin}
|
||||
-
|
||||
I check that the reference of the move is the number of the invoice
|
||||
-
|
||||
!assert {model: account.invoice, id: invoice_reference_no_origin}:
|
||||
- move_id.ref == number
|
||||
Reference in New Issue
Block a user