Skip to content

Commit 56c2f20

Browse files
committed
Merge PR #17 into 15.0
Signed-off-by pedrobaeza
2 parents 5d603a0 + 7d1f412 commit 56c2f20

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** @odoo-module **/
2+
import FormController from "web.FormController";
3+
import FormRenderer from "web.FormRenderer";
4+
import FormView from "web.FormView";
5+
import viewRegistry from "web.view_registry";
6+
7+
const WeightRecordingFormController = FormController.extend({
8+
custom_events: _.extend({}, FormController.prototype.custom_events, {
9+
click_control_button: "_onClickControlButton",
10+
}),
11+
_onClickControlButton: function (ev) {
12+
if (this.$buttons) {
13+
ev.stopPropagation();
14+
this.$buttons.find(".default-enter:visible:first()").click();
15+
}
16+
},
17+
});
18+
19+
const WeightRecordingFormRenderer = FormRenderer.extend({
20+
/**
21+
* Use enter key to trigger a controllable event
22+
*
23+
* @private
24+
* @override
25+
*/
26+
_onNavigationMove: function (ev) {
27+
ev.stopPropagation();
28+
if (ev.data.direction !== "next_line") {
29+
return this._super.apply(this, arguments);
30+
}
31+
this.trigger_up("click_control_button");
32+
},
33+
});
34+
35+
export const WeightRecordingFormView = FormView.extend({
36+
config: Object.assign({}, FormView.prototype.config, {
37+
Controller: WeightRecordingFormController,
38+
Renderer: WeightRecordingFormRenderer,
39+
}),
40+
});
41+
42+
viewRegistry.add("weight_recording_form", WeightRecordingFormView);

stock_weighing/wizards/weighing_wizard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,5 @@ def reload_action_wizard(self):
156156
"view_mode": "form",
157157
"res_id": self.id,
158158
"target": "new",
159+
"context": dict(self.env.context, reload_wizard_action=False),
159160
}

stock_weighing/wizards/weighing_wizard_views.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
<record id="weighing_wizard_form_view" model="ir.ui.view">
44
<field name="model">weighing.wizard</field>
55
<field name="arch" type="xml">
6-
<form create="false" string="Record Weight">
6+
<form
7+
create="false"
8+
string="Record Weight"
9+
js_class="weight_recording_form"
10+
>
711
<field name="selected_move_line_id" invisible="1" />
812
<field name="wizard_state" invisible="1" />
913
<field name="move_id" invisible="1" />
@@ -27,6 +31,7 @@
2731
name="weight"
2832
class="input-group-lg"
2933
nolabel="1"
34+
default_focus="1"
3035
widget="numeric_step"
3136
options="{'auto_select': True, 'min': 0, 'add_class': 'form-control-lg text-center text-info o_input_weight', 'remove_class': 'form-control'}"
3237
/>
@@ -58,7 +63,7 @@
5863
<button
5964
name="add_operation_and_record"
6065
type="object"
61-
class="btn btn-secondary"
66+
class="btn btn-secondary default-enter"
6267
attrs="{'invisible': [('wizard_state', '=', 'weight')]}"
6368
data-hotkey="s"
6469
context="{'reload_wizard_action': True}"

0 commit comments

Comments
 (0)