-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
stock_weighing/static/src/weight_recording_form/weight_recording_form.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters