[IMP] stock: update orderpoint view
This commit updates the orderpoint (replenishment) view with the
following changes:
- group "Min Quantity", "Max Quantity", and "To Order" together
- make preferred route "selection" only (note that widget="selection"
does not work in list view => standard workaround applied)
- renaming of order buttons: "Order" => "Order Once" and "Order Always"
=> "Automate Orders"
- add a link to forecasted inventory report for the product (note this
link will show even if there is no data to show in the report)
- remove class decorates from replenishing related buttons ("Order
Once", "Automate Orders", and "Snooze")
Specifications 14 and 15 of inventory usability task.
Task: 2206279
Related Enterprise PR: odoo/enterprise#10723
closes odoo/odoo#51681
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,8 @@ odoo.define('stock.popover_widget', function (require) {
|
||||
var AbstractField = require('web.AbstractField');
|
||||
var core = require('web.core');
|
||||
var QWeb = core.qweb;
|
||||
var Context = require('web.Context');
|
||||
var data_manager = require('web.data_manager');
|
||||
var fieldRegistry = require('web.field_registry');
|
||||
|
||||
/**
|
||||
@@ -36,6 +38,7 @@ var PopoverWidgetField = AbstractField.extend({
|
||||
this.$el.html(QWeb.render(this.buttonTemplape, _.defaults(value, {color: this.color, icon: this.icon})));
|
||||
this.$el.find('a').prop('special_click', true);
|
||||
this.$popover = $(QWeb.render(value.popoverTemplate || this.popoverTemplate, value));
|
||||
this.$popover.on('click', '.action_open_forecast', this._openForecast.bind(this));
|
||||
this.$el.find('a').popover({
|
||||
content: this.$popover,
|
||||
html: this.html,
|
||||
@@ -46,6 +49,33 @@ var PopoverWidgetField = AbstractField.extend({
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Redirect to the product graph view.
|
||||
* (Based off of qty_at_date_widget.js method)
|
||||
*
|
||||
* @private
|
||||
* @param {MouseEvent} event
|
||||
* @returns {Promise} action loaded
|
||||
*/
|
||||
async _openForecast(ev) {
|
||||
ev.stopPropagation();
|
||||
// Change action context to choose a specific date and product(s)
|
||||
// As grid_anchor is set to now() by default in the data, we need
|
||||
// to load the action first, change the context then launch it via do_action
|
||||
// additional_context cannot replace a context value, only add new
|
||||
const action = await data_manager.load_action('stock.report_stock_quantity_action_product');
|
||||
const additional_context = {
|
||||
grid_anchor: this.recordData.delivery_date_grid,
|
||||
search_default_warehouse_id: [this.recordData.warehouse_id.data.id],
|
||||
search_default_below_warehouse: false
|
||||
};
|
||||
action.context = new Context(action.context, additional_context);
|
||||
action.domain = [
|
||||
['product_id', '=', this.recordData.product_id.data.id]
|
||||
];
|
||||
return this.do_action(action);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
this.$el.find('a').popover('dispose');
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="text-left btn btn-link action_open_forecast"
|
||||
type="button">
|
||||
<i class="fa fa-fw o_button_icon fa-arrow-right"></i>
|
||||
View Forecast
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<t t-name="StockOrderpoint.Buttons">
|
||||
|
||||
@@ -47,22 +47,22 @@
|
||||
<field name="product_id" attrs="{'readonly': [('product_id', '!=', False)]}" invisible="context.get('default_product_id')" force_save="1"/>
|
||||
<field name="location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="warehouse_id" options="{'no_create': True}" groups="stock.group_stock_multi_warehouses" optional="hide"/>
|
||||
<field name="route_id"/>
|
||||
<field name="qty_on_hand" force_save="1"/>
|
||||
<field name="qty_forecast" force_save="1"/>
|
||||
<field name="route_id" options="{'no_create': True, 'no_open': True}"/>
|
||||
<field name="trigger" optional="hide"/>
|
||||
<field name="product_min_qty" optional="show"/>
|
||||
<field name="product_max_qty" optional="show"/>
|
||||
<field name="qty_multiple" optional="hide"/>
|
||||
<field name="qty_on_hand" force_save="1"/>
|
||||
<field name="qty_forecast" force_save="1"/>
|
||||
<field name="json_lead_days_popover" optional="show" string=" " widget="popover_widget" attrs="{'invisible': [('id', '=', False)]}"/>
|
||||
<field name="qty_to_order"/>
|
||||
<field name="product_uom_name" string="UoM" groups="uom.group_uom"/>
|
||||
<field name="company_id" optional="hide" readonly="1" groups="base.group_multi_company"/>
|
||||
<button name="action_replenish" string="Order" type="object" class="btn btn-sm btn-primary pt-0 pb-0 o_replenish_buttons"
|
||||
<button name="action_replenish" string="Order Once" type="object" class="btn-secondary pt-0 pb-0 o_replenish_buttons"
|
||||
attrs="{'invisible': [('qty_to_order', '<', 1.0)]}"/>
|
||||
<button name="action_replenish_auto" string="Order Always" type="object" class="btn btn-sm btn-primary pt-0 pb-0 o_replenish_buttons"
|
||||
<button name="action_replenish_auto" string="Automate Orders" type="object" class="btn-secondary pt-0 pb-0 o_replenish_buttons"
|
||||
attrs="{'invisible': ['|', ('qty_to_order', '<', 1.0), ('trigger', '=', 'auto')]}"/>
|
||||
<button name="%(action_orderpoint_snooze)d" string="Snooze" type="action" class="btn btn-sm btn-secondary pt-0 pb-0"
|
||||
<button name="%(action_orderpoint_snooze)d" string="Snooze" type="action" class="btn-secondary pt-0 pb-0"
|
||||
attrs="{'invisible': [('trigger', '!=', 'manual')]}" context="{'default_orderpoint_ids': [id]}"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user