diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-04-19 10:12:13 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-04-19 10:12:13 +0200 |
| commit | e7ab44929ff4aa3add8d00bab97fc3e879b9b91c (patch) | |
| tree | a600579e5c3c00c473550db8da591b6634fcbe0f /addons/web/static/test/evals.js | |
| parent | 45c48d684270f9a88af668f99a1d027df57f68d3 (diff) | |
| parent | f5c37eabe94a04ca62d08f46c1cf3a084fa77f19 (diff) | |
[MERGE] from trunk
bzr revid: xmo@openerp.com-20120419081213-m3fhofkgydj6gp1m
Diffstat (limited to 'addons/web/static/test/evals.js')
| -rw-r--r-- | addons/web/static/test/evals.js | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/addons/web/static/test/evals.js b/addons/web/static/test/evals.js new file mode 100644 index 00000000000..290a009f46d --- /dev/null +++ b/addons/web/static/test/evals.js @@ -0,0 +1,136 @@ +$(document).ready(function () { + var openerp; + + module("eval.contexts", { + setup: function () { + openerp = window.openerp.init([]); + window.openerp.web.corelib(openerp); + window.openerp.web.coresetup(openerp); + } + }); + test('context_sequences', function () { + // Context n should have base evaluation context + all of contexts + // 0..n-1 in its own evaluation context + var active_id = 4; + var result = openerp.connection.test_eval_contexts([ + { + "__contexts": [ + { + "department_id": false, + "lang": "en_US", + "project_id": false, + "section_id": false, + "tz": false, + "uid": 1 + }, + { "search_default_create_uid": 1 }, + {} + ], + "__eval_context": null, + "__ref": "compound_context" + }, + { + "active_id": active_id, + "active_ids": [ active_id ], + "active_model": "purchase.requisition" + }, + { + "__debug": "{'record_id' : active_id}", + "__id": "63e8e9bff8a6", + "__ref": "context" + } + ]); + + deepEqual(result, { + department_id: false, + lang: 'en_US', + project_id: false, + section_id: false, + tz: false, + uid: 1, + search_default_create_uid: 1, + active_id: active_id, + active_ids: [active_id], + active_model: 'purchase.requisition', + record_id: active_id + }); + }); + test('non-literal_eval_contexts', function () { + var result = openerp.connection.test_eval_contexts([{ + "__ref": "compound_context", + "__contexts": [ + {"__ref": "context", "__debug": "{'type':parent.type}", + "__id": "462b9dbed42f"} + ], + "__eval_context": { + "__ref": "compound_context", + "__contexts": [{ + "__ref": "compound_context", + "__contexts": [ + {"__ref": "context", "__debug": "{'type': type}", + "__id": "16a04ed5a194"} + ], + "__eval_context": { + "__ref": "compound_context", + "__contexts": [ + {"lang": "en_US", "tz": false, "uid": 1, + "journal_type": "sale", "section_id": false, + "default_type": "out_invoice", + "type": "out_invoice", "department_id": false}, + {"id": false, "journal_id": 10, + "number": false, "type": "out_invoice", + "currency_id": 1, "partner_id": 4, + "fiscal_position": false, + "date_invoice": false, "period_id": false, + "payment_term": false, "reference_type": "none", + "reference": false, "account_id": 440, + "name": false, "invoice_line": [], + "tax_line": [], "amount_untaxed": 0, + "amount_tax": 0, "reconciled": false, + "amount_total": 0, "state": "draft", + "residual": 0, "company_id": 1, + "date_due": false, "user_id": 1, + "partner_bank_id": false, "origin": false, + "move_id": false, "comment": false, + "payment_ids": [[6, false, []]], + "active_id": false, "active_ids": [], + "active_model": "account.invoice", + "parent": {}} + ], "__eval_context": null} + }, { + "id": false, + "product_id": 4, + "name": "[PC1] Basic PC", + "quantity": 1, + "uos_id": 1, + "price_unit": 100, + "account_id": 853, + "discount": 0, + "account_analytic_id": false, + "company_id": false, + "note": false, + "invoice_line_tax_id": [[6, false, [1]]], + "active_id": false, + "active_ids": [], + "active_model": "account.invoice.line", + "parent": { + "id": false, "journal_id": 10, "number": false, + "type": "out_invoice", "currency_id": 1, + "partner_id": 4, "fiscal_position": false, + "date_invoice": false, "period_id": false, + "payment_term": false, "reference_type": "none", + "reference": false, "account_id": 440, "name": false, + "tax_line": [], "amount_untaxed": 0, "amount_tax": 0, + "reconciled": false, "amount_total": 0, + "state": "draft", "residual": 0, "company_id": 1, + "date_due": false, "user_id": 1, + "partner_bank_id": false, "origin": false, + "move_id": false, "comment": false, + "payment_ids": [[6, false, []]]} + }], + "__eval_context": null + } + }]); + deepEqual(result, {type: 'out_invoice'}); + }); +}); |
