From 5b23e66b10723c820055dede6bdb855d8d30d981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 2 Jul 2024 15:57:48 +0200 Subject: [PATCH] Manage default value for client selection --- sao/src/common.js | 10 +++++++--- tryton/tryton/common/common.py | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sao/src/common.js b/sao/src/common.js index 41e0fadd78..40115b9136 100644 --- a/sao/src/common.js +++ b/sao/src/common.js @@ -127,7 +127,8 @@ return result; }; - Sao.common.selection = function(title, values, alwaysask=false) { + Sao.common.selection = function( + title, values, alwaysask=false, default_=null) { var prm = jQuery.Deferred(); if (jQuery.isEmptyObject(values)) { prm.reject(); @@ -152,11 +153,14 @@ .prepend(jQuery('', { 'type': 'radio', 'name': 'selection-' + dialog.modal.attr('id'), - 'value': i + 'value': i, + 'checked': values[keys[i]] == default_, }))) .appendTo(dialog.body); }); - dialog.body.find('input').first().prop('checked', true); + if (!default_) { + dialog.body.find('input').first().prop('checked', true); + } jQuery('