mirror of https://github.com/OCA/web.git
[IMP] web_widget_one2many_product_picker_sale_stock: black, isort, prettier
parent
bae6568a7f
commit
6e94d0a7d2
|
@ -0,0 +1 @@
|
|||
../../../../web_widget_one2many_product_picker_sale_stock
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -2,24 +2,16 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Web Widget One2Many Product Picker Sale Stock',
|
||||
'summary': 'Adds support for stock in the one2many product picker widget',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'Website',
|
||||
'author': "Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://www.tecnativa.com',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'web_widget_one2many_product_picker',
|
||||
'sale_stock_info_popup',
|
||||
],
|
||||
'data': [
|
||||
'templates/assets.xml',
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/one2many_product_picker.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
"name": "Web Widget One2Many Product Picker Sale Stock",
|
||||
"summary": "Adds support for stock in the one2many product picker widget",
|
||||
"version": "12.0.1.0.0",
|
||||
"category": "Website",
|
||||
"author": "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"website": "https://www.tecnativa.com",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["web_widget_one2many_product_picker", "sale_stock_info_popup",],
|
||||
"data": ["templates/assets.xml",],
|
||||
"qweb": ["static/src/xml/one2many_product_picker.xml",],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
// 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
|
||||
) {
|
||||
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({
|
||||
/**
|
||||
|
@ -14,8 +13,9 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.One2ManyProductPicker
|
|||
*/
|
||||
_getQWebContext: function() {
|
||||
var qweb_context = this._super.apply(this, arguments);
|
||||
qweb_context["show_sale_stock"] = this.options.showSaleStock;
|
||||
qweb_context.show_sale_stock = this.options.showSaleStock;
|
||||
return qweb_context;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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.One2ManyProductPickerRenderer", function (require) {
|
||||
odoo.define(
|
||||
"web_widget_one2many_product_picker_sale_stock.One2ManyProductPickerRenderer",
|
||||
function(require) {
|
||||
"use strict";
|
||||
|
||||
var One2ManyProductPickerRenderer = require("web_widget_one2many_product_picker.One2ManyProductPickerRenderer");
|
||||
|
@ -11,8 +13,9 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.One2ManyProductPicker
|
|||
*/
|
||||
_getRecordOptions: function(search_record) {
|
||||
var options = this._super.apply(this, arguments);
|
||||
options["showSaleStock"] = this.options.show_sale_stock;
|
||||
return options
|
||||
options.showSaleStock = this.options.show_sale_stock;
|
||||
return options;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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,7 +15,8 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
|
|||
* @returns {Object}
|
||||
*/
|
||||
function _constructFakeFieldDef(params) {
|
||||
return _.extend({
|
||||
return _.extend(
|
||||
{
|
||||
change_default: false,
|
||||
company_dependent: false,
|
||||
manual: false,
|
||||
|
@ -23,7 +26,9 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
|
|||
readonly: true,
|
||||
required: false,
|
||||
sortable: false,
|
||||
}, params);
|
||||
},
|
||||
params
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,8 +39,10 @@ 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 (viewInfo.model === "sale.order") {
|
||||
var widget_name = $(viewInfo.arch)
|
||||
.find("field[name='order_line']")
|
||||
.attr("widget");
|
||||
if (widget_name === "one2many_product_picker") {
|
||||
this._injectSaleStockFields(viewInfo);
|
||||
}
|
||||
|
@ -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,13 +137,16 @@ 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);
|
||||
|
@ -148,12 +158,11 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.AbstractView", functi
|
|||
$("<FIELD/>", {
|
||||
name: field_name,
|
||||
invisible: 1,
|
||||
modifiers: "{\"invisible\": true}",
|
||||
modifiers: '{"invisible": true}',
|
||||
}).appendTo($arch);
|
||||
}
|
||||
}
|
||||
viewInfo.viewFields.order_line.views.form.arch = $arch[0].outerHTML;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,8 +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.FieldOne2ManyProductPicker", function (
|
||||
require
|
||||
) {
|
||||
odoo.define(
|
||||
"web_widget_one2many_product_picker_sale_stock.FieldOne2ManyProductPicker",
|
||||
function(require) {
|
||||
"use strict";
|
||||
|
||||
var FieldOne2ManyProductPicker = require("web_widget_one2many_product_picker.FieldOne2ManyProductPicker");
|
||||
|
@ -13,8 +13,9 @@ odoo.define("web_widget_one2many_product_picker_sale_stock.FieldOne2ManyProductP
|
|||
*/
|
||||
_getDefaultOptions: function() {
|
||||
var defaults = this._super.apply(this, arguments);
|
||||
defaults["show_sale_stock"] = false;
|
||||
defaults.show_sale_stock = false;
|
||||
return defaults;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<template>
|
||||
|
||||
<t t-extend="One2ManyProductPicker.FlipCard">
|
||||
<t t-jquery="div[t-attf-class*=oe_flip_card_front] t[t-if='state']" t-operation="append">
|
||||
<t
|
||||
t-jquery="div[t-attf-class*=oe_flip_card_front] t[t-if='state']"
|
||||
t-operation="append"
|
||||
>
|
||||
<t t-if="state.model === 'sale.order.line'">
|
||||
<div class="position-absolute m-0 text-left stock_info">
|
||||
<widget name="qty_at_date_widget" width="0.1" />
|
||||
|
@ -10,5 +12,4 @@
|
|||
</t>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template id="assets_backend" name="Web Widget One2Many Product Picker Sale Stock - Backend Assets" inherit_id="web.assets_backend">
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="Web Widget One2Many Product Picker Sale Stock - Backend Assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss"/>
|
||||
<script type="text/javascript" src="/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js"></script>
|
||||
<link
|
||||
type="text/css"
|
||||
rel="stylesheet"
|
||||
href="/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue