Skip to content

Commit

Permalink
Merge PR #17 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 20, 2024
2 parents 5d603a0 + 7d1f412 commit 56c2f20
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @odoo-module **/
import FormController from "web.FormController";
import FormRenderer from "web.FormRenderer";
import FormView from "web.FormView";
import viewRegistry from "web.view_registry";

const WeightRecordingFormController = FormController.extend({
custom_events: _.extend({}, FormController.prototype.custom_events, {
click_control_button: "_onClickControlButton",
}),
_onClickControlButton: function (ev) {
if (this.$buttons) {
ev.stopPropagation();
this.$buttons.find(".default-enter:visible:first()").click();
}
},
});

const WeightRecordingFormRenderer = FormRenderer.extend({
/**
* Use enter key to trigger a controllable event
*
* @private
* @override
*/
_onNavigationMove: function (ev) {
ev.stopPropagation();
if (ev.data.direction !== "next_line") {
return this._super.apply(this, arguments);
}
this.trigger_up("click_control_button");
},
});

export const WeightRecordingFormView = FormView.extend({
config: Object.assign({}, FormView.prototype.config, {
Controller: WeightRecordingFormController,
Renderer: WeightRecordingFormRenderer,
}),
});

viewRegistry.add("weight_recording_form", WeightRecordingFormView);
1 change: 1 addition & 0 deletions stock_weighing/wizards/weighing_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@ def reload_action_wizard(self):
"view_mode": "form",
"res_id": self.id,
"target": "new",
"context": dict(self.env.context, reload_wizard_action=False),
}
9 changes: 7 additions & 2 deletions stock_weighing/wizards/weighing_wizard_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<record id="weighing_wizard_form_view" model="ir.ui.view">
<field name="model">weighing.wizard</field>
<field name="arch" type="xml">
<form create="false" string="Record Weight">
<form
create="false"
string="Record Weight"
js_class="weight_recording_form"
>
<field name="selected_move_line_id" invisible="1" />
<field name="wizard_state" invisible="1" />
<field name="move_id" invisible="1" />
Expand All @@ -27,6 +31,7 @@
name="weight"
class="input-group-lg"
nolabel="1"
default_focus="1"
widget="numeric_step"
options="{'auto_select': True, 'min': 0, 'add_class': 'form-control-lg text-center text-info o_input_weight', 'remove_class': 'form-control'}"
/>
Expand Down Expand Up @@ -58,7 +63,7 @@
<button
name="add_operation_and_record"
type="object"
class="btn btn-secondary"
class="btn btn-secondary default-enter"
attrs="{'invisible': [('wizard_state', '=', 'weight')]}"
data-hotkey="s"
context="{'reload_wizard_action': True}"
Expand Down

0 comments on commit 56c2f20

Please sign in to comment.