diff --git a/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/record.js b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/record.js
index bc1b6fba3..f855fbf42 100644
--- a/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/record.js
+++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/record.js
@@ -1,44 +1,21 @@
// Copyright 2020 Tecnativa - Alexandre Díaz
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-odoo.define("web_widget_one2many_product_picker_sale_stock.One2ManyProductPickerRecord", function (
- require
-) {
- "use strict";
+odoo.define(
+ "web_widget_one2many_product_picker_sale_stock.One2ManyProductPickerRecord",
+ function(require) {
+ "use strict";
- var One2ManyProductPickerRecord = require(
- "web_widget_one2many_product_picker.One2ManyProductPickerRecord");
+ var One2ManyProductPickerRecord = require("web_widget_one2many_product_picker.One2ManyProductPickerRecord");
- One2ManyProductPickerRecord.include({
- /**
- * @override
- */
- _getQWebContext: function () {
- var qweb_context = this._super.apply(this, arguments);
- qweb_context.show_sale_stock = this.options.showSaleStock;
- return qweb_context;
- },
-
- /**
- * @override
- */
- on_detach_callback: function () {
- if (!_.isEmpty(this.widgets.front)) {
- for (var index in this.widgets.front) {
- var widget = this.widgets.front[index];
- if (widget.template === 'sale_stock.qtyAtDate') {
- widget.$el.popover("hide");
- }
- }
- }
- this._super.apply(this, arguments);
- },
-
- /**
- * @override
- */
- destroy: function () {
- this.on_detach_callback();
- this._super.apply(this, arguments);
- },
- });
-});
+ One2ManyProductPickerRecord.include({
+ /**
+ * @override
+ */
+ _getQWebContext: function() {
+ var qweb_context = this._super.apply(this, arguments);
+ qweb_context.show_sale_stock = this.options.showSaleStock;
+ return qweb_context;
+ },
+ });
+ }
+);
diff --git a/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/renderer.js b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/renderer.js
index 434bab558..ad6794ba6 100644
--- a/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/renderer.js
+++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/renderer.js
@@ -1,18 +1,21 @@
// Copyright 2020 Tecnativa - Alexandre Díaz
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-odoo.define("web_widget_one2many_product_picker_sale_stock.One2ManyProductPickerRenderer", function (require) {
- "use strict";
+odoo.define(
+ "web_widget_one2many_product_picker_sale_stock.One2ManyProductPickerRenderer",
+ function(require) {
+ "use strict";
- var One2ManyProductPickerRenderer = require("web_widget_one2many_product_picker.One2ManyProductPickerRenderer");
+ var One2ManyProductPickerRenderer = require("web_widget_one2many_product_picker.One2ManyProductPickerRenderer");
- One2ManyProductPickerRenderer.include({
- /**
- * @override
- */
- _getRecordOptions: function (search_record) {
- var options = this._super.apply(this, arguments);
- options["showSaleStock"] = this.options.show_sale_stock;
- return options;
- },
- });
-});
+ One2ManyProductPickerRenderer.include({
+ /**
+ * @override
+ */
+ _getRecordOptions: function() {
+ var options = this._super.apply(this, arguments);
+ options.showSaleStock = this.options.show_sale_stock;
+ return options;
+ },
+ });
+ }
+);
diff --git a/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js
index ad410cabd..6d5bea775 100644
--- a/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js
+++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js
@@ -1,6 +1,8 @@
// Copyright 2020 Tecnativa - Alexandre Díaz
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", function (require) {
+odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", function(
+ require
+) {
"use strict";
var AbstractView = require("web.AbstractView");
@@ -13,17 +15,20 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
* @returns {Object}
*/
function _constructFakeFieldDef(params) {
- return _.extend({
- change_default: false,
- company_dependent: false,
- manual: false,
- views: {},
- searchable: true,
- store: false,
- readonly: true,
- required: false,
- sortable: false,
- }, params);
+ return _.extend(
+ {
+ change_default: false,
+ company_dependent: false,
+ manual: false,
+ views: {},
+ searchable: true,
+ store: false,
+ readonly: true,
+ required: false,
+ sortable: false,
+ },
+ params
+ );
}
/**
@@ -33,10 +38,12 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
/**
* @override
*/
- init: function (viewInfo, params) {
- if (viewInfo.model === 'sale.order') {
- var widget_name = $(viewInfo.arch).find("field[name='order_line']").attr("widget");
- if (widget_name === "one2many_product_picker") {
+ init: function(viewInfo, params) {
+ if (viewInfo.model === "sale.order") {
+ var $fields = $(viewInfo.arch)
+ .find("field[name='order_line']");
+ var has_product_picker = _.some($fields, function(elm) { return $(elm).attr("widget") === "one2many_product_picker"; });
+ if (has_product_picker) {
this._injectSaleStockFields(viewInfo);
}
return this._super(viewInfo, params);
@@ -48,7 +55,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
* @private
* @param {Object} viewInfo
*/
- _injectSaleStockFields: function (viewInfo) {
+ _injectSaleStockFields: function(viewInfo) {
var to_inject = {
product_type: _constructFakeFieldDef({
depends: ["product_id.type"],
@@ -61,7 +68,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"customer_lead",
"product_uom_qty",
"order_id.warehouse_id",
- "order_id.commitment_date"
+ "order_id.commitment_date",
],
type: "float",
}),
@@ -71,7 +78,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"customer_lead",
"product_uom_qty",
"order_id.warehouse_id",
- "order_id.commitment_date"
+ "order_id.commitment_date",
],
type: "float",
}),
@@ -81,7 +88,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"customer_lead",
"product_uom_qty",
"order_id.warehouse_id",
- "order_id.commitment_date"
+ "order_id.commitment_date",
],
type: "float",
}),
@@ -91,7 +98,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"customer_lead",
"product_uom_qty",
"order_id.warehouse_id",
- "order_id.commitment_date"
+ "order_id.commitment_date",
],
type: "datetime",
}),
@@ -100,7 +107,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"product_id",
"product_uom_qty",
"qty_delivered",
- "state"
+ "state",
],
relation: "stock.warehouse",
type: "many2one",
@@ -111,7 +118,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"customer_lead",
"product_uom_qty",
"order_id.warehouse_id",
- "order_id.commitment_date"
+ "order_id.commitment_date",
],
group_operator: "sum",
type: "float",
@@ -121,7 +128,7 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"product_id",
"route_id",
"order_id.warehouse_id",
- "product_id.route_ids"
+ "product_id.route_ids",
],
type: "boolean",
}),
@@ -130,30 +137,32 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
"product_id",
"product_uom_qty",
"qty_delivered",
- "state"
+ "state",
],
type: "boolean",
}),
};
- viewInfo.viewFields.order_line.views.form.fields =
- _.extend({}, to_inject, viewInfo.viewFields.order_line.views.form.fields);
+ viewInfo.viewFields.order_line.views.form.fields = _.extend(
+ {},
+ to_inject,
+ viewInfo.viewFields.order_line.views.form.fields
+ );
// Add fields to arch
var field_names = Object.keys(to_inject);
var $arch = $(viewInfo.viewFields.order_line.views.form.arch);
for (var index in field_names) {
var field_name = field_names[index];
- var $field = $arch.find("field[name='"+field_name+"']");
+ var $field = $arch.find("field[name='" + field_name + "']");
if (!$field.length) {
$("", {
name: field_name,
invisible: 1,
- modifiers: "{\"invisible\": true}",
+ modifiers: '{"invisible": true}',
}).appendTo($arch);
}
}
viewInfo.viewFields.order_line.views.form.arch = $arch[0].outerHTML;
- }
+ },
});
-
});
diff --git a/web_widget_one2many_product_picker_sale_stock/static/src/js/widgets/field_one2many_product_picker.js b/web_widget_one2many_product_picker_sale_stock/static/src/js/widgets/field_one2many_product_picker.js
index a3a9c9109..47499622a 100644
--- a/web_widget_one2many_product_picker_sale_stock/static/src/js/widgets/field_one2many_product_picker.js
+++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/widgets/field_one2many_product_picker.js
@@ -1,20 +1,21 @@
// Copyright 2020 Tecnativa - Alexandre Díaz
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-odoo.define("web_widget_one2many_product_picker_sale_stock.FieldOne2ManyProductPicker", function (
- require
-) {
- "use strict";
+odoo.define(
+ "web_widget_one2many_product_picker_sale_stock.FieldOne2ManyProductPicker",
+ function(require) {
+ "use strict";
- var FieldOne2ManyProductPicker = require("web_widget_one2many_product_picker.FieldOne2ManyProductPicker");
+ var FieldOne2ManyProductPicker = require("web_widget_one2many_product_picker.FieldOne2ManyProductPicker");
- FieldOne2ManyProductPicker.include({
- /**
- * @override
- */
- _getDefaultOptions: function () {
- var defaults = this._super.apply(this, arguments);
- defaults["show_sale_stock"] = true;
- return defaults;
- },
- });
-});
+ FieldOne2ManyProductPicker.include({
+ /**
+ * @override
+ */
+ _getDefaultOptions: function() {
+ var defaults = this._super.apply(this, arguments);
+ defaults.show_sale_stock = false;
+ return defaults;
+ },
+ });
+ }
+);
diff --git a/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss b/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss
index d1850c378..5bbae6092 100644
--- a/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss
+++ b/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss
@@ -21,20 +21,18 @@
.oe_flip_card_inner {
.stock_info {
- top: 50%;
- left: 5px;
- transform: translateY(-50%);
+ top: 5px;
+ right: 8px;
> .o_widget {
> div {
background-color: white;
border-radius: 50%;
- width: 2.5em;
- height: 2.5em;
+ width: 2em;
+ height: 2em;
.fa {
- margin-top: -3px;
- font-size: 3em;
+ font-size: 2.5em;
}
}
}
diff --git a/web_widget_one2many_product_picker_sale_stock/static/src/xml/one2many_product_picker.xml b/web_widget_one2many_product_picker_sale_stock/static/src/xml/one2many_product_picker.xml
index 2a99bb91a..43d164131 100644
--- a/web_widget_one2many_product_picker_sale_stock/static/src/xml/one2many_product_picker.xml
+++ b/web_widget_one2many_product_picker_sale_stock/static/src/xml/one2many_product_picker.xml
@@ -1,14 +1,15 @@
-
-
-
-
-