diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 636cec2cfde..adc0e3ea7e2 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -122,12 +122,14 @@ 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', 'project/project_demo.xml', 'project/analytic_account_demo.xml', 'demo/account_minimal.xml', + "edi_invoice_action.xml", # 'account_unit_test.xml', ], 'test': [ diff --git a/addons/account/edi_invoice.py b/addons/account/edi_invoice.py index 7b78acd2016..f8f615b40fc 100644 --- a/addons/account/edi_invoice.py +++ b/addons/account/edi_invoice.py @@ -149,7 +149,6 @@ class account_invoice(osv.osv, ir_edi.edi): if context is None: context = {} - # import company as a new partner, if type==in then supplier=1, else customer=1 # partner_id field is modified to point to the new partner # company_address data used to add address to new partner @@ -249,8 +248,8 @@ class account_invoice(osv.osv, ir_edi.edi): 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: - browse_account = account_pool.browse(cr, uid, account_ids[0]) - edi_tax_line['account_id'] = self.edi_m2o(cr, uid, browse_account, context=context) #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... diff --git a/addons/account/edi_invoice_action.xml b/addons/account/edi_invoice_action.xml new file mode 100644 index 00000000000..e5d7a3f5022 --- /dev/null +++ b/addons/account/edi_invoice_action.xml @@ -0,0 +1,71 @@ + + + + + + context.update({'token':self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)}) + + code + ir.actions.server + + True + invoice + + + + + + hello + invoice created + email + ir.actions.server + han@tinyerp.com + + True + invoice_send + + + + + + other + ir.actions.server + + + True + Multi_action + + + + + + + + + + + invoice + xyz + + + xyz + test ${object._context.get('token')} +${object.account_id.currency_mode} +Hello, + +We just registered the invoice 'INV/001' for 121 EUR for your company 'ASUSTek'. +You can click on the following link to preview, print and pay this invoice: + http://URL_ON_WEB_CLIENT + +Please note that this invoice has to be paid before 12/04/2011. + +Regards, + mako + english + xyz + Invoice + account.invoice + xyz + + + diff --git a/addons/account/test/test_edi_invoice.yml b/addons/account/test/test_edi_invoice.yml index 4951cf896c1..9cf8e9a284c 100644 --- a/addons/account/test/test_edi_invoice.yml +++ b/addons/account/test/test_edi_invoice.yml @@ -1,5 +1,5 @@ - - create Company + I create a company for Customer - !record {model: res.company, id: res_company_test11}: name: Thomson pvt. ltd. @@ -10,14 +10,14 @@ currency_id: 1 - - create partner + I create a partner which is a my customer - !record {model: res.partner, id: res_partner_test20}: name: Junjun wala supplier: False company_id: res_company_test11 - - create customer invoice + I create one customer invoice - !record {model: account.invoice, id: customer_invoice_test}: journal_id: 1 @@ -45,7 +45,7 @@ amount: 1000.00 - - I open the Invoice for the SO. + I Open the Invoice - !python {model: account.invoice}: | @@ -55,36 +55,35 @@ wf_service.trg_validate(uid, 'account.invoice',invoices.id,'invoice_open', cr) - - Tesing of EDI functionality + I Tesing of EDI functionality. First I export customer invoice from my company than import that invoice into customer company - !python {model: ir.edi.document}: | - 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) - + invoice_pool = self.pool.get('account.invoice') + invoice = invoice_pool.browse(cr, uid, ref("customer_invoice_test")) + + tokens = self.export_edi(cr, uid, [invoice]) + assert tokens, 'Token is not generated' + document = self.get_document(cr, uid, tokens[0]) + a = self.import_edi(cr, uid, edi_document = document) + assert a, 'Invoice is not imported' - - Check the exported out_invoice become in_invoice or not + I Checking the out invoice become in invoice or not after import - !python {model: account.invoice}: | - invoice_old = self.browse(cr,uid,ref("customer_invoice_test")) - ids = self.search(cr, uid, [('reference','=',invoice_old.internal_number)]) - invoice_new = self.browse(cr, uid, ids)[0] - assert invoice_new.partner_id.name == invoice_old.partner_id.name, "invoice is not imported and new partner is not created" - assert invoice_new.partner_id.company_id.name == 'OpenERP S.A.', "company_id is not converted to main company" - assert invoice_new.partner_id.address[0].partner_id == invoice_old.partner_id.name, "new partner is not imported and new address is not added" + 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 Supplier' + + ids = self.search(cr, uid, [('partner_id','=',new_partner_id[0][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.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" - assert invoice_new.payment_term.id, "Not created a default one based on name" - assert invoice_new.invoice_line.account_id.id, "account_id is not taken from product's default" - assert invoice_new.tax_line.manual == True, "for tax line manual is not set to True" - assert invoice_new.tax_line.account_id, "for tax_line default accounts is not picked based on the tax config of the DB where it is imported." - - - - + 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."