2011-06-21 13:30:26 +00:00
-
2011-10-05 00:34:09 +00:00
In order to test the EDI export features of Invoices
2011-06-23 13:42:07 +00:00
-
2011-10-05 00:34:09 +00:00
First I create a draft customer invoice
2011-06-23 13:42:07 +00:00
-
2011-10-05 00:34:09 +00:00
!record {model: account.invoice, id: invoice_edi_1}:
2011-06-24 13:11:17 +00:00
journal_id : 1
2011-10-05 00:34:09 +00:00
partner_id : base.res_partner_agrolait
2011-06-23 13:42:07 +00:00
currency_id : base.EUR
2011-10-05 00:34:09 +00:00
address_invoice_id : base.res_partner_address_8invoice
company_id : 1
2011-06-28 13:43:26 +00:00
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
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
2011-09-15 08:46:35 +00:00
invoice_line :
- product_id : product.product_product_pc3
uos_id : 1
quantity : 5.0
price_unit : 100.0
name : 'Medium PC'
account_id : account.a_pay
2011-06-28 13:43:26 +00:00
tax_line :
- name : sale tax
account_id : account.a_pay
manual : True
amount : 1000.00
-
2011-10-05 00:34:09 +00:00
I confirm and open the invoice
2011-06-28 13:43:26 +00:00
-
2011-10-05 00:34:09 +00:00
!workflow {model: account.invoice, ref: invoice_edi_1, action: invoice_open}
2011-06-23 13:42:07 +00:00
-
2011-10-05 00:34:09 +00:00
Then I export the customer invoice
2011-06-21 13:30:26 +00:00
-
2011-10-05 00:34:09 +00:00
!python {model: edi.document}: |
2011-06-29 05:44:52 +00:00
invoice_pool = self.pool.get('account.invoice')
2011-10-05 00:34:09 +00:00
invoice = invoice_pool.browse(cr, uid, ref("invoice_edi_1"))
token = self.export_edi(cr, uid, [invoice])
assert token, 'Invalid EDI Token'
2011-06-23 13:42:07 +00:00
-
2011-10-05 00:34:09 +00:00
Then I import a sample EDI document of another customer invoice
2011-09-13 12:59:23 +00:00
-
2011-10-05 00:34:09 +00:00
!python {model: account.invoice}: |
2011-09-13 12:59:23 +00:00
edi_document = {
2011-10-05 00:34:09 +00:00
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.random_invoice_763jsms" ,
"__module": "account" ,
"__model": "account.invoice" ,
"__version": [ 6 , 1 , 0 ] ,
2011-09-13 12:59:23 +00:00
"internal_number": "SAJ/2011/002" ,
"company_address": {
2011-10-05 00:34:09 +00:00
"__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.main_address" ,
"__module": "base" ,
"__model": "res.partner.address" ,
2011-09-13 12:59:23 +00:00
"city": "Gerompont" ,
"zip": "1367" ,
2011-10-05 00:34:09 +00:00
"country_id": [ "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.be" , "Belgium" ] ,
2011-09-13 12:59:23 +00:00
"phone": "(+32).81.81.37.00" ,
"street": "Chaussee de Namur 40"
},
2011-10-05 00:34:09 +00:00
"company_id": [ "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_company_test11" , "Thomson pvt. ltd." ] ,
"currency_id": [ "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.EUR" , "EUR (€)" ] ,
"address_invoice_id": [ "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_partner_address_11" , "Sebastien LANGE, France, Alencon, 1 place de l'\u00c9glise" ] ,
"partner_id": [ "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_partner_test20" , "Junjun wala" ] ,
2011-09-13 12:59:23 +00:00
"date_invoice": "2011-06-22" ,
2011-10-05 00:34:09 +00:00
"name": "sample invoice" ,
2011-09-13 12:59:23 +00:00
"tax_line": [ {
2011-10-05 00:34:09 +00:00
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_tax-4g4EutbiEMVl" ,
"__module": "account" ,
"__model": "account.invoice.tax" ,
2011-09-13 12:59:23 +00:00
"amount": 1000.0 ,
"manual": True ,
"name": "sale tax" ,
}] ,
"type": "out_invoice" ,
"invoice_line": [ {
2011-10-05 00:34:09 +00:00
"__module": "account" ,
"__model": "account.invoice.line" ,
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_line-1RP3so" ,
"uos_id": [ "product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_uom_unit" , "PCE" ] ,
"name": "Basic PC" ,
2011-09-13 12:59:23 +00:00
"price_unit": 10.0 ,
2011-10-05 00:34:09 +00:00
"product_id": [ "product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_product_pc1" , "[PC1] Basic PC" ] ,
2011-09-13 12:59:23 +00:00
"quantity": 1.0
2011-09-15 08:46:35 +00:00
},
{
2011-10-05 00:34:09 +00:00
"__module": "account" ,
"__model": "account.invoice.line" ,
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_line-u2XV5" ,
"uos_id": [ "product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_uom_unit" , "PCE" ] ,
"name": "Medium PC" ,
2011-09-15 08:46:35 +00:00
"price_unit": 100.0 ,
2011-10-05 00:34:09 +00:00
"product_id": [ "product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_product_pc3" , "[PC3] Medium PC" ] ,
2011-09-15 08:46:35 +00:00
"quantity": 5.0
2011-09-13 12:59:23 +00:00
}]
}
2011-10-05 00:34:09 +00:00
invoice_id = self.edi_import(cr, uid, edi_document, context=context)
assert invoice_id, 'EDI import failed'
invoice_new = self.browse(cr, uid, invoice_id)
assert invoice_new.partner_id.supplier, 'Imported Partner is not marked as supplier'
2011-09-15 05:30:43 +00:00
assert invoice_new.reference == "SAJ/2011/002", "internal number is not stored in reference"
2011-10-05 00:34:09 +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"
2011-09-15 08:46:35 +00:00
assert invoice_new.journal_id.id, "journal id is not selected"
2011-10-05 00:34:09 +00:00
assert invoice_new.type == 'in_invoice', "Invoice type was not set properly"
2011-09-16 07:38:18 +00:00
assert len(invoice_new.invoice_line) == 2, "invoice lines are not same"
2011-06-29 05:27:22 +00:00
for inv_line in invoice_new.invoice_line :
2011-09-16 07:38:18 +00:00
if inv_line.name == 'basic pc' :
assert inv_line.uos_id.name == "PCE" , "uom is not same"
assert inv_line.price_unit == 10 , "price unit is not same"
assert inv_line.quantity == 1 , "product qty is not same"
assert inv_line.price_subtotal == 10, "price sub total is not same"
elif inv_line.name == 'medium pc' :
assert inv_line.uos_id.name == "PCE" , "uom is not same"
assert inv_line.price_unit == 100 , "price unit is not same"
assert inv_line.quantity == 5 , "product qty is not same"
2011-10-05 00:34:09 +00:00
assert inv_line.price_subtotal == 500, "price sub total is not same"
2011-09-16 07:38:18 +00:00
else :
assert 'wrong product imported in invoice lines'
2011-06-29 05:27:22 +00:00
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."