diff options
| author | Aurélien Warnon <awa@odoo.com> | 2019-03-06 07:24:28 +0000 |
|---|---|---|
| committer | Aurélien Warnon <awa@odoo.com> | 2019-03-28 14:55:00 +0000 |
| commit | 220f5ae53f66400320b697c778039b0585da8fc4 (patch) | |
| tree | c043173861eeb83ee54688a20ef983bd3c39744c /addons/account/static/src/js/section_and_note_fields_backend.js | |
| parent | 55ed70f405a7614756f878599ddc7e7d34f6b508 (diff) | |
[IMP] sale_product_configurator: improve p. configurator
Task #1891970
Original p. configurator commit d3530eb
Purpose
=======
- The p. configurator now comes with a widget that is "o2m" like in the SO lines view.
The widget is only used on the added "product_template_id" field on the SO line.
This widget controls the opening of the configuration window and removes the need of a "Configure a product" button.
The "SectionAndNoteListRenderer" is now cleaned from p. configurator specific code.
The widget is also responsible for handling the configuration provided by the p. configurator form
and applying it on the SO line with a 'field_changed' event that updates all the necessary fields.
- Added support for 'MULTI' and 'DELETE_ALL' operations on X2Many fields in basic_model.js
- 'MULTI' allows to batch multiple operations at once
- 'DELETE_ALL' behaves like 'DELETE' with all the current data of the field
Spec
=======
- remove "configure a product" from sale order lines
When the product configurator is active, replace the product_product_id by a product_template_id
in the sale order line. When we select a template without variants, it sets the variant automatically,
but when we select a product template having variants, it opens the configurator dialog.
- add a widget to modify the product configuration in the sale order line (next to product template field)
- UX improvements:
- Invert image and configuration in the main screen
- If the product doesn't have an image, hide it instead of showing the placeholder (only for first screen?)
- new independent option in sales settings to activate product configurator.
(same in e-commerce)
- demo data: Change demo data to set Customizable Desk & Conference Chair as make to order
- If only one attribute value that is Custom, don't display radio, selection or even color box
Diffstat (limited to 'addons/account/static/src/js/section_and_note_fields_backend.js')
| -rw-r--r-- | addons/account/static/src/js/section_and_note_fields_backend.js | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/addons/account/static/src/js/section_and_note_fields_backend.js b/addons/account/static/src/js/section_and_note_fields_backend.js index 26328cc045b..1f232ac0db8 100644 --- a/addons/account/static/src/js/section_and_note_fields_backend.js +++ b/addons/account/static/src/js/section_and_note_fields_backend.js @@ -6,9 +6,6 @@ odoo.define('account.section_and_note_backend', function (require) { // [UPDATED] now also allows configuring products on sale order. "use strict"; -var pyUtils = require('web.py_utils'); -var core = require('web.core'); -var _t = core._t; var FieldChar = require('web.basic_fields').FieldChar; var FieldOne2Many = require('web.relational_fields').FieldOne2Many; var fieldRegistry = require('web.field_registry'); @@ -72,121 +69,6 @@ var SectionAndNoteListRenderer = ListRenderer.extend({ return this._super.apply(this, arguments).then(function () { self.$('> table').addClass('o_section_and_note_list_view'); }); - }, - /** - * Add support for product configurator - * - * @override - * @private - */ - _onAddRecord: function (ev) { - // we don't want the browser to navigate to a the # url - ev.preventDefault(); - - // we don't want the click to cause other effects, such as unselecting - // the row that we are creating, because it counts as a click on a tr - ev.stopPropagation(); - - // but we do want to unselect current row - var self = this; - this.unselectRow().then(function () { - var context = ev.currentTarget.dataset.context; - - var pricelistId = self._getPricelistId(); - if (context && pyUtils.py_eval(context).open_product_configurator){ - self._rpc({ - model: 'ir.model.data', - method: 'xmlid_to_res_id', - kwargs: {xmlid: 'sale.sale_product_configurator_view_form'}, - }).then(function (res_id) { - self.do_action({ - name: _t('Configure a product'), - type: 'ir.actions.act_window', - res_model: 'sale.product.configurator', - views: [[res_id, 'form']], - target: 'new', - context: { - 'default_pricelist_id': pricelistId - } - }, { - on_close: function (products) { - if (products && products !== 'special'){ - self.trigger_up('add_record', { - context: self._productsToRecords(products), - forceEditable: "bottom" , - allowWarning: true, - onSuccess: function (){ - self.unselectRow(); - } - }); - } - } - }); - }); - } else { - self.trigger_up('add_record', {context: context && [context]}); // TODO write a test, the deferred was not considered - } - }); - }, - - /** - * Will try to get the pricelist_id value from the parent sale_order form - * - * @private - * @returns {integer} pricelist_id's id - */ - _getPricelistId: function () { - var saleOrderForm = this.getParent() && this.getParent().getParent(); - var stateData = saleOrderForm && saleOrderForm.state && saleOrderForm.state.data; - var pricelist_id = stateData.pricelist_id && stateData.pricelist_id.data && stateData.pricelist_id.data.id; - - return pricelist_id; - }, - - /** - * Will map the products to appropriate record objects that are - * ready for the default_get - * - * @private - * @param {Array} products The products to transform into records - */ - _productsToRecords: function (products) { - var records = []; - _.each(products, function (product){ - var record = { - default_product_id: product.product_id, - default_product_uom_qty: product.quantity - }; - - if (product.no_variant_attribute_values) { - var default_product_no_variant_attribute_values = []; - _.each(product.no_variant_attribute_values, function (attribute_value) { - default_product_no_variant_attribute_values.push( - [4, parseInt(attribute_value.value)] - ); - }); - record['default_product_no_variant_attribute_value_ids'] - = default_product_no_variant_attribute_values; - } - - if (product.product_custom_attribute_values) { - var default_custom_attribute_values = []; - _.each(product.product_custom_attribute_values, function (attribute_value) { - default_custom_attribute_values.push( - [0, 0, { - attribute_value_id: attribute_value.attribute_value_id, - custom_value: attribute_value.custom_value - }] - ); - }); - record['default_product_custom_attribute_value_ids'] - = default_custom_attribute_values; - } - - records.push(record); - }); - - return records; } }); |
