diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 5ec724ed462..636cec2cfde 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -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', diff --git a/addons/account/edi_invoice.py b/addons/account/edi_invoice.py index e37bd220d35..0ffe2db0651 100644 --- a/addons/account/edi_invoice.py +++ b/addons/account/edi_invoice.py @@ -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() diff --git a/addons/account/test/test_edi_invoice.yml b/addons/account/test/test_edi_invoice.yml index 18e5a8fb9e9..dacd80e57b1 100644 --- a/addons/account/test/test_edi_invoice.yml +++ b/addons/account/test/test_edi_invoice.yml @@ -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." + + + +