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
|
2012-06-19 07:16:24 +00:00
|
|
|
partner_id: base.res_partner_2
|
2011-06-23 13:42:07 +00:00
|
|
|
currency_id: base.EUR
|
2011-10-05 00:34:09 +00:00
|
|
|
company_id: 1
|
2011-06-28 13:43:26 +00:00
|
|
|
account_id: account.a_pay
|
2012-01-02 15:04:25 +00:00
|
|
|
date_invoice: !eval "'%s' % (time.strftime('%Y-%m-%d'))"
|
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:
|
2012-06-29 11:04:24 +00:00
|
|
|
- product_id: product.product_product_3
|
2011-06-24 13:11:17 +00:00
|
|
|
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:
|
2012-06-29 11:04:24 +00:00
|
|
|
- product_id: product.product_product_5
|
2011-09-15 08:46:35 +00:00
|
|
|
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}: |
|
2012-01-02 15:04:25 +00:00
|
|
|
import time
|
2011-09-13 12:59:23 +00:00
|
|
|
edi_document = {
|
2012-03-08 14:44:39 +00:00
|
|
|
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.random_invoice_763jsms",
|
|
|
|
"__module": "account",
|
|
|
|
"__model": "account.invoice",
|
|
|
|
"__version": [6,1,0],
|
|
|
|
"internal_number": time.strftime("SAJ/%Y/002"),
|
2011-09-13 12:59:23 +00:00
|
|
|
"company_address": {
|
2011-10-05 00:34:09 +00:00
|
|
|
"__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.main_address",
|
|
|
|
"__module": "base",
|
2012-03-05 06:48:45 +00:00
|
|
|
"__model": "res.partner",
|
2011-09-13 12:59:23 +00:00
|
|
|
"city": "Gerompont",
|
2012-03-20 10:44:39 +00:00
|
|
|
"name": "Company main address",
|
2011-09-13 12:59:23 +00:00
|
|
|
"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",
|
2011-10-28 15:16:54 +00:00
|
|
|
"street": "Chaussee de Namur 40",
|
|
|
|
"bank_ids": [
|
|
|
|
["base:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_partner_bank-ZrTWzesfsdDJzGbp","Sample bank: 123465789-156113"]
|
|
|
|
],
|
2012-03-08 14:44:39 +00:00
|
|
|
},
|
|
|
|
"company_id": ["account:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_company_test11", "Thomson pvt. ltd."],
|
2011-10-24 14:44:07 +00:00
|
|
|
"currency": {
|
|
|
|
"__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.EUR",
|
|
|
|
"__module": "base",
|
|
|
|
"__model": "res.currency",
|
|
|
|
"code": "EUR",
|
|
|
|
"symbol": "€",
|
2012-03-08 14:44:39 +00:00
|
|
|
},
|
2011-10-06 11:36:51 +00:00
|
|
|
"partner_id": ["account:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_partner_test20", "Junjun wala"],
|
|
|
|
"partner_address": {
|
|
|
|
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",
|
|
|
|
"__module": "base",
|
2012-03-05 06:48:45 +00:00
|
|
|
"__model": "res.partner",
|
2012-03-20 10:44:39 +00:00
|
|
|
"name": "Default Address",
|
2011-10-06 11:36:51 +00:00
|
|
|
"phone": "(+32).81.81.37.00",
|
|
|
|
"street": "Chaussee de Namur 40",
|
|
|
|
"city": "Gerompont",
|
|
|
|
"zip": "1367",
|
|
|
|
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
|
|
|
},
|
2012-03-08 14:44:39 +00:00
|
|
|
"date_invoice": time.strftime('%Y-%m-%d'),
|
|
|
|
"name": "sample invoice",
|
2011-09-13 12:59:23 +00:00
|
|
|
"tax_line": [{
|
2012-03-08 14:44:39 +00:00
|
|
|
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.account_invoice_tax-4g4EutbiEMVl",
|
2011-10-05 00:34:09 +00:00
|
|
|
"__module": "account",
|
2012-03-08 14:44:39 +00:00
|
|
|
"__model": "account.invoice.tax",
|
|
|
|
"amount": 1000.0,
|
|
|
|
"manual": True,
|
|
|
|
"name": "sale tax",
|
|
|
|
}],
|
|
|
|
"type": "out_invoice",
|
2011-09-13 12:59:23 +00:00
|
|
|
"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",
|
2012-03-08 14:44:39 +00:00
|
|
|
"uos_id": ["product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_uom_unit", "Unit"],
|
|
|
|
"name": "Basic PC",
|
|
|
|
"price_unit": 10.0,
|
2012-06-29 11:04:24 +00:00
|
|
|
"product_id": ["product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_product_3", "[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",
|
2012-03-08 14:44:39 +00:00
|
|
|
"uos_id": ["product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_uom_unit", "Unit"],
|
|
|
|
"name": "Medium PC",
|
|
|
|
"price_unit": 100.0,
|
2012-06-29 11:04:24 +00:00
|
|
|
"product_id": ["product:b22acf7a-ddcd-11e0-a4db-701a04e25543.product_product_5", "[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)
|
2011-10-28 15:16:54 +00:00
|
|
|
|
|
|
|
# check bank info on partner
|
|
|
|
assert len(invoice_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
|
|
|
bank_info = invoice_new.partner_id.bank_ids[0]
|
|
|
|
assert bank_info.acc_number == "Sample bank: 123465789-156113", 'Expected "Sample bank: 123465789-156113", got %s' % bank_info.acc_number
|
|
|
|
|
2011-10-05 00:34:09 +00:00
|
|
|
assert invoice_new.partner_id.supplier, 'Imported Partner is not marked as supplier'
|
2012-01-02 15:04:25 +00:00
|
|
|
assert invoice_new.reference == time.strftime("SAJ/%Y/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-10-06 11:36:51 +00:00
|
|
|
if inv_line.name == 'Basic PC':
|
2012-03-08 14:44:39 +00:00
|
|
|
assert inv_line.uos_id.name == "Unit" , "uom is not same"
|
2011-09-16 07:38:18 +00:00
|
|
|
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"
|
2011-10-06 11:36:51 +00:00
|
|
|
elif inv_line.name == 'Medium PC':
|
2012-03-08 14:44:39 +00:00
|
|
|
assert inv_line.uos_id.name == "Unit" , "uom is not same"
|
2011-09-16 07:38:18 +00:00
|
|
|
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:
|
2011-10-06 11:36:51 +00:00
|
|
|
raise AssertionError('unknown invoice line: %s' % inv_line)
|
2011-06-29 05:27:22 +00:00
|
|
|
for inv_tax in invoice_new.tax_line:
|
2011-10-06 11:36:51 +00:00
|
|
|
assert inv_tax.manual, "tax line not set to manual"
|
|
|
|
assert inv_tax.account_id, "missing tax line account"
|