bzr revid: hmo@tinyerp.com-20110629052722-ib5hdr0wrs3g8dnk
This commit is contained in:
Harry (OpenERP) 2011-06-29 10:57:22 +05:30
commit 835ed95c6a
3 changed files with 48 additions and 17 deletions

View File

@ -122,7 +122,6 @@ module named account_voucher.
'board_account_view.xml',
"wizard/account_report_profit_loss_view.xml",
"wizard/account_report_balance_sheet_view.xml",
],
'demo_xml': [
'account_demo.xml',

View File

@ -240,20 +240,21 @@ class account_invoice(osv.osv, ir_edi.edi):
account = product.product_tmpl_id.property_account_expense
if not account:
account = product.categ_id.property_account_expense_categ
# TODO: add effect of fiscal position
# account = fpos_obj.map_account(cr, uid, fiscal_position_id, account.id)
edi_invoice_line['account_id'] = account and self.edi_m2o(cr, uid, account, context=context) or False
# for tax lines, we disconnect from the invoice.line, so all tax lines will be of type 'manual', and default accounts should be picked based
# on the tax config of the DB where it is imported.
for edi_tax_line in edi_document.get('tax_line', []):
account_ids = account_pool.search(cr, uid, [('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')])
if account_ids:
edi_tax_line['account_id'] = account_ids[0] #TODO should select account of output VAT for Customer Invoice and Input VAT for Supplier Invoice
tax_account = account_pool.browse(cr, uid, account_ids[0])
edi_tax_line['account_id'] = self.edi_m2o(cr, uid, tax_account, context=context) #TODO should select account of output VAT for Customer Invoice and Input VAT for Supplier Invoice
edi_tax_line['manual'] = True
# TODO :=> payment_term: if set, create a default one based on name...
return super(account_invoice,self).edi_import(cr, uid, edi_document, context=context)
account_invoice()

View File

@ -16,7 +16,6 @@
name: Junjun wala
supplier: False
company_id: res_company_test11
-
create customer invoice
-
@ -25,8 +24,8 @@
partner_id: res_partner_test20
currency_id: base.EUR
address_invoice_id: base.res_partner_address_11
company_id: base.main_company
account_id: 1
company_id: res_company_test11
account_id: account.a_pay
date_invoice: '2011-06-22'
name: selling product
type: 'out_invoice'
@ -37,25 +36,57 @@
quantity: 1.0
price_unit: 10.0
name: 'basic pc'
account_id: 1
account_id: account.a_pay
tax_line:
- name: sale tax
account_id: account.a_pay
manual: True
amount: 1000.00
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
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)
-
Tesing of EDI functionality
-
!python {model: ir.edi.document}: |
invoice_obj = self.pool.get('account.invoice')
invoices = invoice_obj.browse(cr, uid, [ref("customer_invoice_test")])
invoice_invoice_new = self.pool.get('account.invoice')
invoices = invoice_invoice_new.browse(cr, uid, [ref("customer_invoice_test")])
tokens = self.export_edi(cr, uid, invoices)
for token in tokens:
document = self.get_document(cr, uid, token, context=context)
a = self.import_edi(cr, uid, edi_document = document)
-
Check the customer invoice is exported or not
Check the exported out_invoice become in_invoice or not
-
!python {model: account.invoice}: |
ids=self.search(cr, uid, [('partner_id','=',ref("res_partner_test20")),('type','=','out_invoice')])
if not ids:
raise AssertionError("Invoice is not imported")
invoice_old = self.browse(cr,uid,ref("customer_invoice_test"))
new_partner_id = self.pool.get('res.partner').name_search(cr, uid, invoice_old.company_id.name)
assert new_partner_id, 'Partner is not created of party'
ids = self.search(cr, uid, [('partner_id','=',new_partner_id[0]),('reference','=',invoice_old.internal_number)])
assert ids, 'Invoice does not have created of party'
invoice_new = self.browse(cr, uid, ids[0])
assert invoice_new.reference == invoice_old.internal_number, "internal number is not stored in reference"
assert invoice_new.reference_type == None, "reference type is not set to 'None'"
assert invoice_new.internal_number == False, "internal number is not reset"
assert invoice_new.journal_id.id, "journal id is not selected"
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."