diff --git a/setup/web_widget_one2many_product_picker_sale_stock/odoo/addons/web_widget_one2many_product_picker_sale_stock b/setup/web_widget_one2many_product_picker_sale_stock/odoo/addons/web_widget_one2many_product_picker_sale_stock new file mode 120000 index 000000000..19bc00420 --- /dev/null +++ b/setup/web_widget_one2many_product_picker_sale_stock/odoo/addons/web_widget_one2many_product_picker_sale_stock @@ -0,0 +1 @@ +../../../../web_widget_one2many_product_picker_sale_stock \ No newline at end of file diff --git a/setup/web_widget_one2many_product_picker_sale_stock/setup.py b/setup/web_widget_one2many_product_picker_sale_stock/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_widget_one2many_product_picker_sale_stock/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_widget_one2many_product_picker_sale_stock/README.rst b/web_widget_one2many_product_picker_sale_stock/README.rst new file mode 100644 index 000000000..4db82a204 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/README.rst @@ -0,0 +1,86 @@ +============================================= +Web Widget One2Many Product Picker Sale Stock +============================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/12.0/web_widget_one2many_product_picker_sale_stock + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_one2many_product_picker_sale_stock + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Adds support for 'sale_stock_info_popup' in the product picker + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Install and use it + +Widget options: +~~~~~~~~~~~~~~~ + +* show_sale_stock > Enable/Disable show the stock + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Alexandre D. Díaz + * Pedro M. Baeza + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_one2many_product_picker_sale_stock/__init__.py b/web_widget_one2many_product_picker_sale_stock/__init__.py new file mode 100644 index 000000000..d9d1f13de --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_widget_one2many_product_picker_sale_stock/__manifest__.py b/web_widget_one2many_product_picker_sale_stock/__manifest__.py new file mode 100644 index 000000000..562748fd3 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020 Tecnativa - Alexandre D. Díaz +# 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": "13.0.1.0.0", + "category": "Website", + "author": "Tecnativa, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "license": "AGPL-3", + "depends": ["web_widget_one2many_product_picker", "sale_stock"], + "data": ["templates/assets.xml"], + "qweb": ["static/src/xml/one2many_product_picker.xml"], + "installable": True, + "auto_install": False, +} diff --git a/web_widget_one2many_product_picker_sale_stock/i18n/web_widget_one2many_product_picker_sale_stock.pot b/web_widget_one2many_product_picker_sale_stock/i18n/web_widget_one2many_product_picker_sale_stock.pot new file mode 100644 index 000000000..d2e396f15 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/i18n/web_widget_one2many_product_picker_sale_stock.pot @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + diff --git a/web_widget_one2many_product_picker_sale_stock/readme/CONTRIBUTORS.rst b/web_widget_one2many_product_picker_sale_stock/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f3d7389e1 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Alexandre D. Díaz + * Pedro M. Baeza diff --git a/web_widget_one2many_product_picker_sale_stock/readme/DESCRIPTION.rst b/web_widget_one2many_product_picker_sale_stock/readme/DESCRIPTION.rst new file mode 100644 index 000000000..093f70019 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Adds support for 'sale_stock_info_popup' in the product picker diff --git a/web_widget_one2many_product_picker_sale_stock/readme/USAGE.rst b/web_widget_one2many_product_picker_sale_stock/readme/USAGE.rst new file mode 100644 index 000000000..444dc6d6e --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/readme/USAGE.rst @@ -0,0 +1,6 @@ +Install and use it + +Widget options: +~~~~~~~~~~~~~~~ + +* show_sale_stock > Enable/Disable show the stock diff --git a/web_widget_one2many_product_picker_sale_stock/static/description/icon.png b/web_widget_one2many_product_picker_sale_stock/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_one2many_product_picker_sale_stock/static/description/icon.png differ diff --git a/web_widget_one2many_product_picker_sale_stock/static/description/index.html b/web_widget_one2many_product_picker_sale_stock/static/description/index.html new file mode 100644 index 000000000..f9246dfdf --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/description/index.html @@ -0,0 +1,440 @@ + + + + + + +Web Widget One2Many Product Picker Sale Stock + + + +
+

Web Widget One2Many Product Picker Sale Stock

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

Adds support for ‘sale_stock_info_popup’ in the product picker

+

Table of contents

+ +
+

Usage

+

Install and use it

+
+

Widget options:

+
    +
  • show_sale_stock > Enable/Disable show the stock
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:

    +
    +
      +
    • Alexandre D. Díaz
    • +
    • Pedro M. Baeza
    • +
    +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + 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 new file mode 100644 index 000000000..506746ffb --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/record.js @@ -0,0 +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"; + + const 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; + }, + }); + } +); 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 new file mode 100644 index 000000000..5eec841f9 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/renderer.js @@ -0,0 +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"; + + const One2ManyProductPickerRenderer = require("web_widget_one2many_product_picker.One2ManyProductPickerRenderer"); + + 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 new file mode 100644 index 000000000..fed37d0c9 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js @@ -0,0 +1,168 @@ +// 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 +) { + "use strict"; + + const AbstractView = require("web.AbstractView"); + + /** + * Helper function to create field view definitions + * + * @private + * @param {Object} params + * @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 + ); + } + + /** + * This is pure hard-coded magic. Adds new fields to the widget form view. + */ + AbstractView.include({ + /** + * @override + */ + init: function(viewInfo, params) { + if (viewInfo.model === "sale.order") { + const widget_name = $(viewInfo.arch) + .find("field[name='order_line']") + .attr("widget"); + if (widget_name === "one2many_product_picker") { + this._injectSaleStockFields(viewInfo); + } + return this._super(viewInfo, params); + } + this._super.apply(this, arguments); + }, + + /** + * @private + * @param {Object} viewInfo + */ + _injectSaleStockFields: function(viewInfo) { + const to_inject = { + product_type: _constructFakeFieldDef({ + depends: ["product_id.type"], + related: ["product_id", "type"], + type: "selection", + }), + virtual_available_at_date: _constructFakeFieldDef({ + depends: [ + "product_id", + "customer_lead", + "product_uom_qty", + "order_id.warehouse_id", + "order_id.commitment_date", + ], + type: "float", + }), + qty_available_today: _constructFakeFieldDef({ + depends: [ + "product_id", + "customer_lead", + "product_uom_qty", + "order_id.warehouse_id", + "order_id.commitment_date", + ], + type: "float", + }), + free_qty_today: _constructFakeFieldDef({ + depends: [ + "product_id", + "customer_lead", + "product_uom_qty", + "order_id.warehouse_id", + "order_id.commitment_date", + ], + type: "float", + }), + scheduled_date: _constructFakeFieldDef({ + depends: [ + "product_id", + "customer_lead", + "product_uom_qty", + "order_id.warehouse_id", + "order_id.commitment_date", + ], + type: "datetime", + }), + warehouse_id: _constructFakeFieldDef({ + depends: [ + "product_id", + "product_uom_qty", + "qty_delivered", + "state", + ], + relation: "stock.warehouse", + type: "many2one", + }), + qty_to_deliver: _constructFakeFieldDef({ + depends: [ + "product_id", + "customer_lead", + "product_uom_qty", + "order_id.warehouse_id", + "order_id.commitment_date", + ], + group_operator: "sum", + type: "float", + }), + is_mto: _constructFakeFieldDef({ + depends: [ + "product_id", + "route_id", + "order_id.warehouse_id", + "product_id.route_ids", + ], + type: "boolean", + }), + display_qty_widget: _constructFakeFieldDef({ + depends: [ + "product_id", + "product_uom_qty", + "qty_delivered", + "state", + ], + type: "boolean", + }), + }; + viewInfo.viewFields.order_line.views.form.fields = _.extend( + {}, + to_inject, + viewInfo.viewFields.order_line.views.form.fields + ); + + // Add fields to arch + const field_names = Object.keys(to_inject); + const $arch = $(viewInfo.viewFields.order_line.views.form.arch); + for (const index in field_names) { + var field_name = field_names[index]; + var $field = $arch.find("field[name='" + field_name + "']"); + if (!$field.length) { + $("", { + name: field_name, + invisible: 1, + 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 new file mode 100644 index 000000000..66b0a11d3 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/widgets/field_one2many_product_picker.js @@ -0,0 +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"; + + const FieldOne2ManyProductPicker = require("web_widget_one2many_product_picker.FieldOne2ManyProductPicker"); + + 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 new file mode 100644 index 000000000..5bbae6092 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss @@ -0,0 +1,43 @@ +.oe_field_one2many_product_picker { + .oe_one2many_product_picker_view { + .oe_flip_card { + &.oe_flip_card_maximized { + .oe_flip_card_inner { + .stock_info { + > .o_widget { + > div { + width: 5.1em !important; + height: 5.1em !important; + + .fa { + margin-top: -6px !important; + font-size: 6em !important; + } + } + } + } + } + } + + .oe_flip_card_inner { + .stock_info { + top: 5px; + right: 8px; + + > .o_widget { + > div { + background-color: white; + border-radius: 50%; + width: 2em; + height: 2em; + + .fa { + 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 new file mode 100644 index 000000000..7a5b78fd6 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/xml/one2many_product_picker.xml @@ -0,0 +1,15 @@ + + diff --git a/web_widget_one2many_product_picker_sale_stock/templates/assets.xml b/web_widget_one2many_product_picker_sale_stock/templates/assets.xml new file mode 100644 index 000000000..6c4e8eeca --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/templates/assets.xml @@ -0,0 +1,20 @@ + + +