2011-06-21 13:30:26 +00:00
-
2011-06-29 05:44:52 +00:00
I create a company for Customer
2011-06-23 13:42:07 +00:00
-
2011-06-24 13:11:17 +00:00
!record {model: res.company, id: res_company_test11}:
2011-06-23 13:42:07 +00:00
name : Thomson pvt. ltd.
partner_id : 1
rml_header : 1
rml_header2 : 1
rml_header3 : 1
currency_id : 1
-
2011-06-29 05:44:52 +00:00
I create a partner which is a my customer
2011-06-23 13:42:07 +00:00
-
2011-06-24 13:11:17 +00:00
!record {model: res.partner, id: res_partner_test20}:
2011-06-23 13:42:07 +00:00
name : Junjun wala
supplier : False
2011-06-24 13:11:17 +00:00
company_id : res_company_test11
2011-08-26 11:09:14 +00:00
opt_out : True
2011-06-24 13:11:17 +00:00
-
2011-06-29 05:44:52 +00:00
I create one customer invoice
2011-06-24 13:11:17 +00:00
-
!record {model: account.invoice, id: customer_invoice_test}:
journal_id : 1
partner_id : res_partner_test20
2011-06-23 13:42:07 +00:00
currency_id : base.EUR
2011-06-24 13:11:17 +00:00
address_invoice_id : base.res_partner_address_11
2011-06-28 13:43:26 +00:00
company_id : res_company_test11
account_id : account.a_pay
2011-06-23 13:42:07 +00:00
date_invoice : '2011-06-22'
2011-06-27 12:26:16 +00:00
name : selling product
2011-06-24 13:11:17 +00:00
type : 'out_invoice'
2011-06-23 13:42:07 +00:00
invoice_line :
2011-06-24 13:11:17 +00:00
- product_id : product.product_product_pc1
partner_id : res_partner_test20
uos_id : 1
2011-06-23 13:42:07 +00:00
quantity : 1.0
2011-06-24 13:11:17 +00:00
price_unit : 10.0
name : 'basic pc'
2011-06-28 13:43:26 +00:00
account_id : account.a_pay
tax_line :
- name : sale tax
account_id : account.a_pay
manual : True
amount : 1000.00
-
2011-06-29 05:44:52 +00:00
I Open the Invoice
2011-06-28 13:43:26 +00:00
-
!python {model: account.invoice}: |
2011-06-24 13:11:17 +00:00
2011-06-28 13:43:26 +00:00
invoices = self.browse(cr, uid, ref("customer_invoice_test"))
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'account.invoice',invoices.id,'invoice_open', cr)
2011-06-23 13:42:07 +00:00
-
2011-09-13 12:59:23 +00:00
I Testing of EDI functionality. First I export customer invoice from my company than import that invoice into customer company
2011-06-21 13:30:26 +00:00
-
!python {model: ir.edi.document}: |
2011-06-29 05:44:52 +00:00
invoice_pool = self.pool.get('account.invoice')
invoice = invoice_pool.browse(cr, uid, ref("customer_invoice_test"))
2011-06-30 13:37:57 +00:00
2011-06-29 05:44:52 +00:00
tokens = self.export_edi(cr, uid, [invoice])
assert tokens, 'Token is not generated'
2011-09-13 12:59:23 +00:00
-
I import of EDI document of custmer invoice
-
!python {model: ir.edi.document}: |
invoice_pool = self.pool.get('account.invoice')
edi_document = {
"internal_number": "SAJ/2011/002" ,
"company_address": {
"city": "Gerompont" ,
"zip": "1367" ,
"__last_update": False ,
"country_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:base.be" , "Belgium" ] ,
"__id": "b22acf7a-ddcd-11e0-a4db-701a04e25543:base.main_address" ,
"phone": "(+32).81.81.37.00" ,
"street": "Chaussee de Namur 40"
},
"company_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:account.res_company_test11" , "Thomson pvt. ltd." ] ,
"currency_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:base.EUR" , "EUR (\u20ac)" ] ,
"address_invoice_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:base.res_partner_address_11" , "Sebastien LANGE, France, Alencon, 1 place de l'\u00c9glise" ] ,
"partner_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:account.res_partner_test20" , "Junjun wala" ] ,
"__attachments": [ ] ,
"__module": "account" ,
"amount_total": 1010.0 ,
"date_invoice": "2011-06-22" ,
"amount_untaxed": 10.0 ,
"name": "selling product" ,
"__model": "account.invoice" ,
"__last_update": False ,
"tax_line": [ {
"amount": 1000.0 ,
"manual": True ,
"__id": "b22acf7a-ddcd-11e0-a4db-701a04e25543:b22acf7a-ddcd-11e0-a4db-701a04e25543:account.account_invoice_tax-4g4EutbiEMVl" ,
"name": "sale tax" ,
"__last_update": False
}] ,
"__id": "b22acf7a-ddcd-11e0-a4db-701a04e25543:account.customer_invoice_test" ,
"amount_tax": 1000.0 ,
"__version": [ 6 , 1 ] ,
"type": "out_invoice" ,
"invoice_line": [ {
"uos_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:product.product_uom_unit" , "PCE" ] ,
"name": "basic pc" ,
"__last_update": False ,
"price_unit": 10.0 ,
"price_subtotal": 10.0 ,
"__id": "b22acf7a-ddcd-11e0-a4db-701a04e25543:b22acf7a-ddcd-11e0-a4db-701a04e25543:account.account_invoice_line-1RP3so-u2vV4" ,
"product_id": [ "b22acf7a-ddcd-11e0-a4db-701a04e25543:product.product_product_pc1" , "[PC1] Basic PC" ] ,
"quantity": 1.0
}]
}
invoice_id = invoice_pool.edi_import(cr, uid, edi_document, context=context)
invoice_new = invoice_pool.browse(cr, uid, invoice_id, context=context)
assert invoice_id, 'Invoice is not imported'
2011-06-23 13:42:07 +00:00
-
2011-06-29 05:44:52 +00:00
I Checking the out invoice become in invoice or not after import
2011-06-23 13:42:07 +00:00
-
!python {model: account.invoice}: |
2011-06-28 13:43:26 +00:00
2011-06-29 05:44:52 +00:00
invoice_old = self.browse(cr, uid, ref("customer_invoice_test"))
2011-06-29 05:27:22 +00:00
new_partner_id = self.pool.get('res.partner').name_search(cr, uid, invoice_old.company_id.name)
2011-06-29 05:44:52 +00:00
assert new_partner_id, 'Partner is not created of Supplier'
2011-09-13 12:59:23 +00:00
ids = self.search(cr, uid, [('partner_id','=',new_partner_id[0][0]),('reference','=',"SAJ/2011/002")])
2011-06-29 05:27:22 +00:00
assert ids, 'Invoice does not have created of party'
invoice_new = self.browse(cr, uid, ids[0])
2011-06-28 13:43:26 +00:00
assert invoice_new.reference == invoice_old.internal_number, "internal number is not stored in reference"
2011-06-29 05:44:52 +00:00
assert invoice_new.reference_type == 'none', "reference type is not set to 'None'"
2011-06-28 13:43:26 +00:00
assert invoice_new.internal_number == False, "internal number is not reset"
assert invoice_new.journal_id.id, "journal id is not selected"
2011-06-29 05:27:22 +00:00
for inv_line in invoice_new.invoice_line :
assert inv_line.account_id.id, "account_id is not taken from product's default"
for inv_tax in invoice_new.tax_line :
assert inv_tax.manual, "for tax line manual is not set to True"
assert inv_tax.account_id, "for tax_line default accounts is not picked based on the tax config of the DB where it is imported."