diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 000000000..445d8585b --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +stock-logistics-warehouse 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..3066b8ecf --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/__manifest__.py @@ -0,0 +1,25 @@ +# 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': '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, +} 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/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..52521066d --- /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"; + + 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; + }, + }); +}); 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..bd03bfec0 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/One2ManyProductPicker/renderer.js @@ -0,0 +1,18 @@ +// 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"; + + 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 + }, + }); +}); 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..ad410cabd --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/views/abstract_view.js @@ -0,0 +1,159 @@ +// 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"; + + var 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') { + var 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) { + var 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 + 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+"']"); + 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..f1755dca6 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/js/widgets/field_one2many_product_picker.js @@ -0,0 +1,20 @@ +// 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"; + + 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"] = 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..d1850c378 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/scss/one2many_product_picker.scss @@ -0,0 +1,45 @@ +.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: 50%; + left: 5px; + transform: translateY(-50%); + + > .o_widget { + > div { + background-color: white; + border-radius: 50%; + width: 2.5em; + height: 2.5em; + + .fa { + margin-top: -3px; + font-size: 3em; + } + } + } + } + } + } + } +} 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..f8ae40950 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/static/src/xml/one2many_product_picker.xml @@ -0,0 +1,14 @@ + + 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..bda3468c8 --- /dev/null +++ b/web_widget_one2many_product_picker_sale_stock/templates/assets.xml @@ -0,0 +1,10 @@ + + + +