summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields
diff options
context:
space:
mode:
authorMohammed Shekha <msh@odoo.com>2019-12-06 06:17:49 +0000
committerAaron Bohy <aab@odoo.com>2020-04-06 14:42:34 +0000
commit2b776cbbb5e5a9c9dd8b68933c70080cae5f28e0 (patch)
tree9055e0a75b4bb0bb683cf70c28df0fd9ddefad97 /addons/web/static/tests/fields/relational_fields
parenta210d75f554e353f0ca1faec2506e454818814b8 (diff)
[IMP] do not propagate default_* key from parent context to sub view
before this commit: from commit: https://github.com/odoo/odoo/commit/d58d6e270f4106d717821438490f60bc4f71306e parent context was propagated to sub views, propagating whole context to sub view creates issue as it contains default_* key inside it, there is a chance that sub view has same field name which matches with default_fieldName in context, e.g. go to sale order form view and create sale order line, while selecting product, write in product_id field so that Create and Edit option comes, select Create and Edit option, so whatever previously written in product_id field will be added in product.product form's context as default_name, now go to Purchase tab of product form and try to create Supplier, but note that Vendors One2many should be editable, if it is not then to produce this issue, make Vendor o2m list editable top/bottom, as soon as you click on Vendor o2m's create button traceback generated which comes from name_get of res.partner, issue raised because vendor o2m has m2o of res.partner and field name is 'name', when default_get for vendor o2m is called it will propagate context and context has default_name='typed string in product_id', as name field is m2o with res.partner it will generate traceback as m2o accepts (id, name) tuple not string after this commit: propagate context to sub view but remove default_* keys from parent context task-2121161 closes odoo/odoo#49075 X-original-commit: 2e3756e0ce96a9e0c5fa304632a2600cbd832ef5 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields')
-rw-r--r--addons/web/static/tests/fields/relational_fields/field_one2many_tests.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js
index 4bd23d0d76b..c2801eb9ac1 100644
--- a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js
+++ b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js
@@ -7041,8 +7041,8 @@ QUnit.module('fields', {}, function () {
form.destroy();
});
- QUnit.test('propagate context to sub views', async function (assert) {
- assert.expect(5);
+ QUnit.test('propagate context to sub views without default_* keys', async function (assert) {
+ assert.expect(7);
var form = await createView({
View: FormView,
@@ -7060,9 +7060,23 @@ QUnit.module('fields', {}, function () {
mockRPC: function (route, args) {
assert.strictEqual(args.kwargs.context.flutter, 'shy',
'view context key should be used for every rpcs');
+ if (args.method === 'default_get') {
+ if (args.model === 'partner') {
+ assert.strictEqual(args.kwargs.context.default_flutter, 'why',
+ "should have default_* values in context for form view RPCs");
+ } else if (args.model === 'turtle') {
+ assert.notOk(args.kwargs.context.default_flutter,
+ "should not have default_* values in context for subview RPCs");
+ }
+ }
return this._super.apply(this, arguments);
},
- viewOptions: { context: { flutter: 'shy' } },
+ viewOptions: {
+ context: {
+ flutter: 'shy',
+ default_flutter: 'why',
+ },
+ },
});
await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
await testUtils.fields.editInput(form.$('input[name="turtle_foo"]'), 'pinky pie');