diff options
| author | Christophe Matthieu <chm@odoo.com> | 2018-07-26 09:55:01 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2018-08-13 17:09:28 +0200 |
| commit | 61eef73b52c078daaae37f8d57e93830a2e53410 (patch) | |
| tree | 8b144174691de487a584bf8ac449fb55d3ad12ab /addons/web/static/tests/fields/special_fields.js | |
| parent | 149eb38b07cace0ec2118d214c56995402008efc (diff) | |
[IMP] base, *: use a many2one for the company report layout
Before this rev. one could set the report layout on the company using a
hardcoded list (background, clean, standard, etc.). Other modules (typically
accounting modules) could add options in this list. The used template was built
on the layout key.
Now, the layout is a many2one field to a newly created model `report.layout`,
which is linked to a view with the layout architecture.
This gives more control to customize reports and create a new layout (without
creating a python module that extend the layout selection).
Diffstat (limited to 'addons/web/static/tests/fields/special_fields.js')
| -rw-r--r-- | addons/web/static/tests/fields/special_fields.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/special_fields.js b/addons/web/static/tests/fields/special_fields.js index 6786f6783b7..3592f813fae 100644 --- a/addons/web/static/tests/fields/special_fields.js +++ b/addons/web/static/tests/fields/special_fields.js @@ -213,6 +213,53 @@ QUnit.module('special_fields', { form.destroy(); }); + QUnit.module('FieldReportLayout'); + + QUnit.test('report_layout widget in form view', function (assert) { + assert.expect(3); + + this.data['report.layout'] = { + fields: { + view_id: {string: "Document Template", type: "many2one", relation: "product"}, + image: {string: "Preview image src", type: "char"}, + pdf: {string: "Preview pdf src", type: "char"} + }, + records: [{ + id: 1, + view_id: 37, + image: "/web/static/toto.png", + pdf: "/web/static/toto.pdf", + }, { + id: 2, + view_id: 41, + image: "/web/static/tata.png", + pdf: "/web/static/tata.pdf", + }] + }; + this.data.partner.records[1].product_id = false; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="product_id" widget="report_layout"/> '+ + '</form>', + res_id: 2, + }); + + assert.strictEqual(form.$('.img.img-fluid').length, 2, + "Two images should be rendered"); + assert.strictEqual(form.$('.img.btn-info').length, 0, + "No image should be selected"); + + // select first image + form.$(".img.img-fluid:first").click(); + assert.ok(form.$(".img.img-fluid:first").hasClass('btn-info'), + "First image should be selected"); + + form.destroy(); + }); }); }); }); |
