diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-04-02 21:04:31 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 9100e675dfe7ae60ea3c8f1a5ef1e9a78a4ab4c6 (patch) | |
| tree | 08f98b2fe727ece38153afb99c99611baf2e9395 /addons/web/static/src/js/fields/abstract_field.js | |
| parent | 0f96189b7fbc481b21f0b7b7a2fdcb82916d6bae (diff) | |
[FIX] web: add support for discarding lines in o2m
This is not a complete work, but it introduces the basic infrastructure
to properly edit various more sophisticated editing behaviours.
The main focus of this commit is to handle discarding invalid lines in
one2many, potentially asking the user for confirmation. So, the
relevant methods have to be modified to return some deferred, because
the operation is now asynchronous.
Diffstat (limited to 'addons/web/static/src/js/fields/abstract_field.js')
| -rw-r--r-- | addons/web/static/src/js/fields/abstract_field.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index 47802d5d8c7..6eac12a2dba 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -153,7 +153,7 @@ var AbstractField = Widget.extend({ // the 'required' flag is basically only needed to determine if the widget // is in a valid state (not valid if empty and required) - this.required = options.required || false; + this.required = options.required || this.field.required; // the 'idForLabel' is the (html) id that should be set to the relevent // dom entity. If done correctly, clicking on the corresponding label @@ -202,7 +202,13 @@ var AbstractField = Widget.extend({ * a field widget is valid if its value is valid and if there is a value when * it is required. This is checked before saving a record, by the form view. * - * @returns {boolean} + * Note: the return value may be a boolean. It is necessary for some fields + * (x2many) to sometimes ask confirmation to the user if the current dirty + * invalid line can be discarded. This is an asynchronous operation, so we + * need the expressivity of something like a deferred. + * + * @returns {boolean|Deferred} true/false if the widget is valid, or a + * deferred which resolves to true/false if the widget is valid or not */ isValid: function () { var is_required = this.required; |
