[REF] stock: alert on show details if not saved

It's not possible to click on the show details button if the picking is
not saved. It's a limitation of the webclient. This commit introduces a
waring telling the user to save the form view first.
This commit is contained in:
Simon Lejeune
2017-10-02 20:01:58 +02:00
parent b5de65ed6b
commit cde5b232e8
3 changed files with 14 additions and 2 deletions
+1 -1
View File
@@ -300,7 +300,7 @@
<field name="reserved_availability" string="Reserved" attrs="{'column_invisible': ['|', ('parent.state','=', 'done'), ('parent.picking_type_code', '=', 'incoming')]}"/>
<field name="quantity_done" string="Done" attrs="{'readonly': [('is_quantity_done_editable', '=', False)]}"/>
<field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft'), ('additional', '=', False)]}" options="{'no_open': True, 'no_create': True}" string="Unit of Measure" groups="product.group_uom"/>
<button name="action_show_details" string="Register lots, packs, location" type="object" icon="fa-list" attrs="{'invisible': [('show_details_visible', '=', False)]}"/>
<button name="action_show_details" string="Register lots, packs, location" type="object" icon="fa-list" attrs="{'invisible': [('show_details_visible', '=', False)]}" options='{"warn": true}'/>
</tree>
</field>
<button class="oe_link oe_right" name="put_in_pack" type="object" string="&#8627;Put in Pack" attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}" groups="stock.group_tracking_lot"/>
@@ -408,6 +408,9 @@ return core.Class.extend({
if (!_.isObject(node.attrs.modifiers)) {
node.attrs.modifiers = node.attrs.modifiers ? JSON.parse(node.attrs.modifiers) : {};
}
if (!_.isObject(node.attrs.options) && node.tag === 'button') {
node.attrs.options = node.attrs.options ? JSON.parse(node.attrs.options) : {};
}
if (node.tag === 'field') {
fieldsInfo[node.attrs.name] = self._processField(viewType,
fields[node.attrs.name], node.attrs ? _.clone(node.attrs) : {});
@@ -4,6 +4,7 @@ odoo.define('web.ListRenderer', function (require) {
var BasicRenderer = require('web.BasicRenderer');
var config = require('web.config');
var core = require('web.core');
var Dialog = require('web.Dialog');
var dom = require('web.dom');
var field_utils = require('web.field_utils');
var Pager = require('web.Pager');
@@ -323,7 +324,15 @@ var ListRenderer = BasicRenderer.extend({
});
});
} else {
$button.prop('disabled', true);
if (node.attrs.options.warn) {
var self = this;
$button.on("click", function (e) {
e.stopPropagation();
self.do_warn(_t("Warning"), _t('Please click on the "save" button first'));
});
} else {
$button.prop('disabled', true);
}
}
return $button;