[MERGE]:adding new demo file for server action
bzr revid: han@tinyerp.com-20110630133757-edmaamzw2u26qtl8
This commit is contained in:
@@ -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': [
|
||||
|
||||
@@ -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...
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!--Export edi document -->
|
||||
<record id="ir_actions_server_invoice" model="ir.actions.server">
|
||||
<field name="code">context.update({'token':self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)})</field>
|
||||
<field eval="6" name="sequence"/>
|
||||
<field name="state">code</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="account.model_account_invoice"/>
|
||||
<field name="condition">True</field>
|
||||
<field name="name">invoice</field>
|
||||
</record>
|
||||
|
||||
<!--send mail when invoice is creaed -->
|
||||
<record id="ir_actions_server_invoicesend" model="ir.actions.server">
|
||||
<field eval="7" name="sequence"/>
|
||||
<field name="message">hello</field>
|
||||
<field name="subject">invoice created</field>
|
||||
<field name="state">email</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="email">han@tinyerp.com</field>
|
||||
<field name="model_id" ref="account.model_account_invoice"/>
|
||||
<field name="condition">True</field>
|
||||
<field name="name">invoice_send</field>
|
||||
</record>
|
||||
|
||||
<!--multi action for export edi and send email -->
|
||||
<record id="ir_actions_server_multiaction" model="ir.actions.server">
|
||||
<field eval="8" name="sequence"/>
|
||||
<field name="state">other</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="account.model_account_invoice"/>
|
||||
<field eval="[(6,0,[ref('account.ir_actions_server_invoice'),ref('account.ir_actions_server_invoicesend')])]" name="child_ids"/>
|
||||
<field name="condition">True</field>
|
||||
<field name="name">Multi_action</field>
|
||||
</record>
|
||||
|
||||
<!--calling multi action in workflow.activity -->
|
||||
<record id="account.act_open" model="workflow.activity">
|
||||
<field name="action_id" ref="ir_actions_server_multiaction"/>
|
||||
</record>
|
||||
|
||||
<!--Email template -->
|
||||
<record id="email_template_invoice" model="email.template">
|
||||
<field model="email_template.account" name="from_account"/>
|
||||
<field name="def_subject">invoice</field>
|
||||
<field name="def_to">xyz</field>
|
||||
<field name="def_body_html"></field>
|
||||
<field name="object_name" ref="account.model_account_invoice"/>
|
||||
<field name="def_cc">xyz</field>
|
||||
<field name="def_body_text">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,</field>
|
||||
<field name="template_language">mako</field>
|
||||
<field name="lang">english</field>
|
||||
<field name="def_bcc">xyz</field>
|
||||
<field name="name">Invoice</field>
|
||||
<field name="model_int_name">account.invoice</field>
|
||||
<field name="reply_to">xyz</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user