diff --git a/addons/web/static/src/js/tour.js b/addons/web/static/src/js/tour.js
index b5cb3a8cfbb..ea64a55f22c 100644
--- a/addons/web/static/src/js/tour.js
+++ b/addons/web/static/src/js/tour.js
@@ -56,6 +56,9 @@ $.extend($.expr[':'],{
propValue: function(element, index, matches) {
return $(element).prop("value") === matches[3];
},
+ propValueContains: function(element, index, matches) {
+ return $(element).prop("value") && $(element).prop("value").indexOf(matches[3]) !== -1;
+ },
});
$.ajaxSetup({
beforeSend:function(){
@@ -655,6 +658,9 @@ var Tour = {
click_event("mousedown");
click_event("mouseup");
click_event("click");
+ if ($element.is("input, textarea, select") && !$element.is(":focus")) {
+ $element.focus();
+ }
// trigger after for step like: mouseenter, next step click on button display with mouseenter
setTimeout(function () {
@@ -663,7 +669,6 @@ var Tour = {
}, self.defaultDelay<<1);
}
if (step.sampleText) {
-
$element.trigger($.Event("keydown", { srcElement: $element[0] }));
if ($element.is("input") || $element.is('textarea')) {
$element.val(step.sampleText);
diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js
index 9357badcef1..a6ffcd3d058 100644
--- a/addons/web/static/src/js/views/form_relational_widgets.js
+++ b/addons/web/static/src/js/views/form_relational_widgets.js
@@ -926,9 +926,8 @@ var One2ManyListView = ListView.extend({
this._mousedown_blur_line = function (event) {
if (self.__focus) {
self.__ignore_blur = true;
- var $dom = self.editor.$el.add(self.$el);
if ($(event.target).closest("button, *:not(.oe_form_field_one2many_list_row_add) > a").length ||
- ($dom.index(event.target) === -1 && !_.any($(event.target).parents(), function (p) { return $dom.index(p) !== -1 ; }))) {
+ (!$(event.target).closest(self.editor.$el[0]).length && !$(event.target).closest(self.$el[0]).length)) {
self.__ignore_blur = false;
}
}
diff --git a/addons/web_tests/static/src/js/web.tour.js b/addons/web_tests/static/src/js/web.tour.js
index 53da3af357d..6d107a103db 100644
--- a/addons/web_tests/static/src/js/web.tour.js
+++ b/addons/web_tests/static/src/js/web.tour.js
@@ -34,12 +34,12 @@ Tour.register({
},
{
title: "insert body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'a'
},
{
title: "create new message",
- waitFor: 'textarea.field_text:propValue(a)',
+ waitFor: '.modal textarea.field_text:propValue(a)',
element: '.oe_abstractformpopup-form-save'
},
@@ -47,17 +47,18 @@ Tour.register({
{
title: "create new message",
- waitFor: '.oe_list_field_cell',
+ waitNot: '.modal',
+ waitFor: '.oe_application:has(.oe_list_field_cell):has(textarea[name="message_concat"]:propValue([test] Administrator:a))',
element: '.oe_form_field_one2many_list_row_add a'
},
{
title: "insert body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'b'
},
{
title: "create new message",
- waitFor: 'textarea.field_text:propValue(b)',
+ waitFor: '.modal textarea.field_text:propValue(b)',
element: '.oe_abstractformpopup-form-save'
},
@@ -65,27 +66,37 @@ Tour.register({
{
title: "insert title",
- waitFor: '.oe_list_field_cell:eq(2)',
+ waitNot: '.modal',
+ waitFor: 'textarea[name="message_concat"]:propValue([test] Administrator:a\n[test] Administrator:b)',
element: '.oe_form_required input',
- sampleText: 'test trigger'
+ sampleText: 'test_trigger'
+ },
+ {
+ title: "blur the title field",
+ waitFor: '.oe_form_required input:propValue(test_trigger)',
+ element: '.oe_form_field_many2one input:first',
+ },
+ {
+ title: "check onchange",
+ waitFor: 'textarea[name="message_concat"]:propValue([test_trigger] Administrator:a\n[test_trigger] Administrator:b)',
},
// change message b
{
title: "edit message b",
- waitFor: 'tr:has(.oe_list_field_cell):not(:has(.oe_list_record_selector)):eq(1) .oe_list_field_cell:contains([test trigger] )',
+ waitFor: 'tr:has(.oe_list_field_cell):not(:has(.oe_list_record_selector)):eq(1) .oe_list_field_cell:contains([test_trigger] )',
waitNot: 'tr:has(.oe_list_field_cell):not(:has(.oe_list_record_selector)):eq(2)',
element: '.oe_list_field_cell:containsExact(b)'
},
{
title: "change the body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'bbb'
},
{
title: "save changes",
- waitFor: 'textarea.field_text:propValue(bbb)',
+ waitFor: '.modal textarea.field_text:propValue(bbb)',
element: '.oe_abstractformpopup-form-save'
},
@@ -94,17 +105,17 @@ Tour.register({
{
title: "create new message",
waitNot: '.modal',
- waitFor: 'tr:has(.oe_list_field_cell):not(:has(.oe_list_record_selector)):eq(1) .oe_list_field_text:contains(bbb)',
+ waitFor: 'textarea[name="message_concat"]:propValue([test_trigger] Administrator:a\n[test_trigger] Administrator:bbb)',
element: '.oe_form_field_one2many_list_row_add a'
},
{
title: "insert body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'c'
},
{
title: "create new message",
- waitFor: 'textarea.field_text:propValue(c)',
+ waitFor: '.modal textarea.field_text:propValue(c)',
element: '.oe_abstractformpopup-form-save'
},
@@ -112,6 +123,7 @@ Tour.register({
{
title: "change tab to Participants",
+ waitNot: '.modal',
waitFor: '.oe_form_field_one2many .oe_list_field_cell:eq(3)',
element: '[data-toggle="tab"]:contains(Participants)'
},
@@ -152,7 +164,7 @@ Tour.register({
},
{
title: "check data 2",
- waitFor: '.oe_form_field_one2many tr:has(.oe_list_field_text:containsExact(bbb)):has(.oe_list_field_char:containsExact([test trigger] Administrator))',
+ waitFor: '.oe_form_field_one2many tr:has(.oe_list_field_text:containsExact(bbb)):has(.oe_list_field_char:containsExact([test_trigger] Administrator))',
},
{
title: "check data 3",
@@ -182,12 +194,12 @@ Tour.register({
},
{
title: "insert body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'd'
},
{
title: "create new message",
- waitFor: 'textarea.field_text:propValue(d)',
+ waitFor: '.modal textarea.field_text:propValue(d)',
element: '.oe_abstractformpopup-form-save'
},
@@ -195,17 +207,18 @@ Tour.register({
{
title: "create new message",
+ waitNot: '.modal',
waitFor: '.oe_list_field_cell:containsExact(d)',
element: '.oe_form_field_one2many_list_row_add a'
},
{
title: "insert body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'e'
},
{
title: "create new message",
- waitFor: 'textarea.field_text:propValue(e)',
+ waitFor: '.modal textarea.field_text:propValue(e)',
element: '.oe_abstractformpopup-form-save'
},
@@ -213,17 +226,18 @@ Tour.register({
{
title: "create new message",
+ waitNot: '.modal',
waitFor: '.oe_list_field_cell:containsExact(e)',
element: '.oe_list_field_cell:containsExact(a)'
},
{
title: "change the body",
- element: 'textarea.field_text',
+ element: '.modal textarea.field_text',
sampleText: 'aaa'
},
{
title: "save changes",
- waitFor: 'textarea.field_text:propValue(aaa)',
+ waitFor: '.modal textarea.field_text:propValue(aaa)',
element: '.oe_abstractformpopup-form-save'
},
@@ -231,8 +245,8 @@ Tour.register({
{
title: "remove b",
- waitFor: '.oe_list_field_text:contains(aaa)',
waitNot: '.modal',
+ waitFor: '.oe_list_field_text:contains(aaa)',
element: 'tr:has(.oe_list_field_cell:containsExact(bbb)) .oe_list_record_delete button'
},
{
@@ -240,6 +254,9 @@ Tour.register({
waitNot: 'tr:has(.oe_list_field_cell:containsExact(bbb))',
element: 'tr:has(.oe_list_field_cell:containsExact(e)) .oe_list_record_delete button'
},
+
+ // save
+
{
title: "save discussion",
waitNot: 'tr:has(.oe_list_field_cell:containsExact(e))',
@@ -258,7 +275,7 @@ Tour.register({
},
{
title: "check data 6",
- waitFor: '.oe_form_field_one2many tr:has(.oe_list_field_text:containsExact(aaa)):has(.oe_list_field_char:containsExact([test trigger] Administrator))',
+ waitFor: '.oe_form_field_one2many tr:has(.oe_list_field_text:containsExact(aaa)):has(.oe_list_field_char:containsExact([test_trigger] Administrator))',
},
{
title: "check data 7",
@@ -266,9 +283,128 @@ Tour.register({
waitNot: '.oe_form_field_many2many tbody tr:has(.oe_list_field_char):eq(2)',
},
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+
{
- title: "finish",
+ title: "switch to the second form view to test one2many with editable list",
waitFor: '.oe_list_field_cell:eq(3)',
+ element: 'a.oe_menu_leaf:contains(Discussions 2)'
+ },
+
+ {
+ title: "switch to list view",
+ waitFor: ".oe_list_editable",
+ element: '.oe-cp-switch-list',
+ },
+ {
+ title: "select previous created record",
+ element: 'td[data-field="name"]:contains(test_trigger):last',
+ },
+ {
+ title: "click on edit",
+ element: '.oe_form_button_edit',
+ },
+
+ {
+ title: "click on a field of the editable list to edit content",
+ element: '.oe_list_editable tr[data-id]:eq(1) .oe_list_field_cell:eq(2)',
+ },
+ {
+ title: "change text value",
+ element: '.oe_form_field[data-fieldname="body"] textarea',
+ sampleText: 'ccc'
+ },
+ {
+ title: "click on a many2one (trigger the line onchange)",
+ element: '.oe_list_editable tr[data-id]:eq(1) .oe_list_field_cell:eq(1)',
+ },
+ {
+ title: "test on2many's line onchange",
+ waitFor: '.oe_list_editable tr[data-id]:eq(1) .oe_list_field_cell:eq(3):contains(3)',
+ },
+ {
+ title: "test on2many field not triggered onchange",
+ waitNot: 'textarea[name="message_concat"]:propValueContains(ccc)',
+ },
+
+ {
+ title: "open the many2one to select an other user",
+ element: '.oe_m2o_drop_down_button',
+ },
+ {
+ title: "select an other user",
+ element: '.oe_application li a:contains(Demo User)',
+ },
+ {
+ title: "test on2many's line onchange after many2one",
+ waitFor: '.oe_form_char_content:contains([test_trigger] Demo User)',
+ },
+ {
+ title: "test on2many field not triggered onchange",
+ waitNot: 'textarea[name="message_concat"]:propValueContains(ccc)',
+ },
+ {
+ title: "change text value",
+ element: '.oe_form_field[data-fieldname="body"] textarea',
+ sampleText: 'ccccc'
+ },
+
+ // check onchange
+
+ {
+ title: "click outside to trigger one2many onchange",
+ waitNot: 'textarea[name="message_concat"]:propValueContains(Demo User)',
+ element: '.oe_form_required input',
+ },
+ {
+ title: "test one2many onchange",
+ waitFor: 'textarea[name="message_concat"]:propValueContains([test_trigger] Demo User:ccccc)',
+ },
+
+ {
+ title: "click outside to trigger one2many onchange",
+ element: '.oe_tags .text-arrow',
+ },
+ {
+ title: "click outside to trigger one2many onchange",
+ element: '.text-label:first',
+ },
+
+ {
+ title: "click outside to trigger one2many onchange",
+ element: '.text-label:first',
+ },
+
+ // remove record
+
+ {
+ title: "delete the last item in the editable list",
+ element: '.oe_list_record_delete button:visible:last',
+ },
+ {
+ title: "test one2many onchange after delete",
+ waitNot: 'textarea[name="message_concat"]:propValueContains(Administrator:d)',
+ },
+
+ // save
+
+ {
+ title: "save discussion",
+ waitNot: 'tr:has(.oe_list_field_cell:containsExact(e))',
+ element: 'button.oe_form_button_save'
+ },
+
+ // check saved data
+
+ {
+ title: "check data 8",
+ waitFor: '.oe_form_text_content:containsExact([test_trigger] Administrator:aaa\n[test_trigger] Demo User:ccccc)',
+ },
+ {
+ title: "check data 9",
+ waitFor: '.oe_form_field_one2many tbody tr:has(.oe_list_field_cell):eq(1)',
+ waitNot: '.oe_form_field_one2many tbody tr:has(.oe_list_field_cell):eq(2)',
},
]
});
diff --git a/openerp/addons/test_new_api/models.py b/openerp/addons/test_new_api/models.py
index 55611f6029d..52fd53a937d 100644
--- a/openerp/addons/test_new_api/models.py
+++ b/openerp/addons/test_new_api/models.py
@@ -85,7 +85,7 @@ class Discussion(models.Model):
'test_new_api_discussion_category', 'discussion', 'category')
participants = fields.Many2many('res.users')
messages = fields.One2many('test_new_api.message', 'discussion')
- message_changes = fields.Integer(string='Message changes')
+ message_concat = fields.Text(string='Message concatenate')
@api.onchange('moderator')
def _onchange_moderator(self):
@@ -93,7 +93,7 @@ class Discussion(models.Model):
@api.onchange('messages')
def _onchange_messages(self):
- self.message_changes = len(self.messages)
+ self.message_concat = "\n".join(["%s:%s" % (m.name, m.body) for m in self.messages])
class Message(models.Model):
diff --git a/openerp/addons/test_new_api/tests/test_onchange.py b/openerp/addons/test_new_api/tests/test_onchange.py
index 3d0745a5f8b..08cb0a89bad 100644
--- a/openerp/addons/test_new_api/tests/test_onchange.py
+++ b/openerp/addons/test_new_api/tests/test_onchange.py
@@ -193,8 +193,9 @@ class TestOnChange(common.TransactionCase):
'categories': [(4, cat.id) for cat in discussion.categories],
'messages': messages,
'participants': [(4, usr.id) for usr in discussion.participants],
- 'message_changes': 0,
+ 'message_concat': False,
}
result = discussion.onchange(values, 'messages', field_onchange)
- self.assertIn('message_changes', result['value'])
- self.assertEqual(result['value']['message_changes'], len(discussion.messages))
+ self.assertIn('message_concat', result['value'])
+ self.assertEqual(result['value']['message_concat'],
+ "\n".join(["%s:%s" % (m.name, m.body) for m in discussion.messages]))
diff --git a/openerp/addons/test_new_api/views.xml b/openerp/addons/test_new_api/views.xml
index 2e1290f5a09..56b29c362c3 100644
--- a/openerp/addons/test_new_api/views.xml
+++ b/openerp/addons/test_new_api/views.xml
@@ -33,12 +33,17 @@
discussion form view
test_new_api.discussion
+
+
+
+ discussion form view
+ test_new_api.discussion
+
+
+
+
+
+
+
+ Discussions 2
+ test_new_api.discussion
+ tree,form
+
+
+
+
+
message tree view