1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
odoo.define('sale.product_configurator_tests', function (require) {
"use strict";
const FormView = require('web.FormView');
const testUtils = require('web.test_utils');
const createView = testUtils.createView;
QUnit.module('product_configurator', {
beforeEach: function () {
this.data = {
order: {
fields: {
line_ids: {
string: "Lines",
type: 'one2many',
relation: 'line',
relation_field: 'order_id'
},
},
records: [
{id: 1, line_ids: [1, 2]},
],
},
line: {
fields: {
product_id: {
string: "Product",
type: 'many2one',
relation: 'product',
},
order_id: {
string: "Order",
type: 'many2one',
relation: 'order'
},
sequence: {
string: "Sequence",
type: 'number',
},
},
records: [
{id: 1, sequence: 4, product_id: 3, order_id: 1},
{id: 2, sequence: 14, product_id: 4, order_id: 1},
]
},
product: {
fields: {
name: {
string: "Name",
type: 'char',
},
},
records: [
{id: 3, name: "Chair"},
{id: 4, name: "Table"},
],
},
};
},
}, function () {
QUnit.test('drag and drop rows containing product_configurator many2one', async function (assert) {
assert.expect(4);
const form = await createView({
View: FormView,
model: 'order',
data: this.data,
arch: `
<form>
<field name="line_ids"/>
</form>`,
archs: {
'line,false,list': `
<tree editable="bottom">
<field name="sequence" widget="handle"/>
<field name="product_id" widget="product_configurator"/>
</tree>`,
},
res_id: 1,
viewOptions: {
mode: 'edit',
},
});
assert.containsN(form, '.o_data_row', 2);
assert.strictEqual(form.$('.o_data_row').text(), 'ChairTable');
assert.containsN(form, '.o_data_row .o_row_handle', 2);
// move first row below second
const $firstHandle = form.$('.o_data_row:nth(0) .o_row_handle');
const $secondHandle = form.$('.o_data_row:nth(1) .o_row_handle');
await testUtils.dom.dragAndDrop($firstHandle, $secondHandle);
assert.strictEqual(form.$('.o_data_row').text(), 'TableChair');
form.destroy();
});
});
});
|