diff options
| author | Aurélien Warnon <awa@odoo.com> | 2018-09-25 18:41:27 +0200 |
|---|---|---|
| committer | Aurélien Warnon <awa@odoo.com> | 2018-09-25 18:42:07 +0200 |
| commit | d3530eb07e24278117ab396ecb86a59deecc312d (patch) | |
| tree | eb9bd5d52f0a4f93d11318cc6674e7111ea04efe /addons/web/static/src/js/fields | |
| parent | 96f7bda09e2cec442046b34c80713894fd16bfb6 (diff) | |
| parent | 90824fc0193c5f83d024660c5237328d89f3ae96 (diff) | |
[IMP] product,(website_)sale: Allow users to fully configure products
Purpose
=======
- Configure a product from a sales order as easily as in the ecommerce
The backend uses the same template as the frontend to configure a products and its options
- Display optionnal products of optionnal products in the "sale options" section
- Allow adding exlusions to some combinations of the product and/or
to some combinations of the optionnal and accessory products
- Product attributes can now have custom values.
These values are specified by the user during the SO creation.
They are also available on the webshop frontend.
- Product attributes can be configured to create variants "on demand".
This means that product.templates having these attributes will only create product.product variant
when that combination is actually selected in a sale order/in the web shop.
Product attribute values are also improved to handle extra prices and exclusions
in all three modes ("never", "dynamic, "always")
Specification
=============
1. Improve the "Add to cart" with optional products
- When you add an option to cart, move the product to the cart & show the options of this option
- Don't open the option wizard if no option available (in case this module becomes generic,
it's better to skip this step when it's not needed)
- Display the options right under their related product in the cart
2. Do not allow to add the product as an optional product for itself
Why ?
- No functional sense
- Creates issues in the add to cart wizard
3. Exclude some attribute combinations within the product or with related options and accessory products
- Rename VARIANT PRICES button -> CONFIGURE VARIANTS
- When you click this button and select a value, open form view rather than inline edition
- Form view of variant values:
- Attribute
- Value
- HTML Color Index
- Attribute Price Extra
- Not Compatible with: o2m tab with 2 fields: Product AND Attribute Value (of this product)
[m2m tag selection]
- in any new line, autocomplete the current product by default
- Tooltip: A list of product and attribute values that you want to exclude for
this product's attribue value. Also applies on optionnal and accessory products.
4. New option to configure a product in a sales order line
- This option is only visible if the corresponding option is activated in the sales settings
- It opens a wizard to select a product template, configure related attribute values
and select optional products (based on frontend view)
- Attributes not compatible with other selected attributes should not be selectable
- Must work like in the frontend
5. Create variants on demand
- add a new mode to generate variants as they are added to the order/cart
(needed for big # of combinations managed in the inventory and/or produced in mrp with specific boms)
- replace the boolean by a selection radio
tooltip for this new field:
Always:
Variants are generated straight away when
the attribute values are combined in the product configuration.
Only when the product is added to a sales order:
Variants are generated once the combination is selected in the sales order.
This is advised when variants are customized on demand and manufactured as such in Odoo.
Never:
Advised when variants are not needed in Odoo.
The selected values just show up in the description of sales order lines.
- ability to define attribute extra prices & exclude combinations in all variant modes
- if at least one attribute of the product in set to "on demand" mode, generate all the variants "on demand"
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/abstract_field.js | 1 | ||||
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 21 |
2 files changed, 19 insertions, 3 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index 2ea40a2602b..37d2f22ef55 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -496,6 +496,7 @@ var AbstractField = Widget.extend({ viewType: this.viewType, doNotSetDirty: options && options.doNotSetDirty, notifyChange: !options || options.notifyChange !== false, + allowWarning: options && options.allowWarning, onSuccess: def.resolve.bind(def), onFailure: def.reject.bind(def), }); diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 7a428923608..6c6919cce4d 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1453,6 +1453,15 @@ var FieldOne2Many = FieldX2Many.extend({ * @param {OdooEvent|MouseEvent} ev this event comes either from the 'Add * record' link in the list editable renderer, or from the 'Create' button * in the kanban view + * @param {Array} ev.data.context additional context for the added records, + * if several contexts are provided, multiple records will be added + * (form dialog will only use the context at index 0 if provided) + * @param {boolean} ev.data.forceEditable this is used to bypass the dialog opening + * in case you want to add record(s) to a list + * @param {function} ev.data.onSuccess called when the records are correctly created + * (not supported by form dialog) + * @param {boolean} ev.data.allowWarning defines if the records can be added + * to the list even if warnings are triggered (e.g: stock warning for product availability) */ _onAddRecord: function (ev) { var self = this; @@ -1461,7 +1470,7 @@ var FieldOne2Many = FieldX2Many.extend({ // we don't want interference with the components upstream. ev.stopPropagation(); - if (this.editable) { + if (this.editable || data.forceEditable) { if (!this.activeActions.create) { if (data.onFail) { data.onFail(); @@ -1471,15 +1480,21 @@ var FieldOne2Many = FieldX2Many.extend({ this.trigger_up('edited_list', { id: this.value.id }); this._setValue({ operation: 'CREATE', - position: this.editable, + position: this.editable || data.forceEditable, context: data.context, + }, { + allowWarning: data.allowWarning }).always(function () { self.creatingRecord = false; + }).done(function(){ + if(data.onSuccess){ + data.onSuccess(); + } }); } } else { this._openFormDialog({ - context: data.context, + context: data.context && data.context[0], on_saved: function (record) { self._setValue({ operation: 'ADD', id: record.id }); }, |
