Skip to content

Commit

Permalink
[FIX] web_m2x_options: Functions used on buttons are not working
Browse files Browse the repository at this point in the history
Before this PR when trying to create a record using the Dialog, when
pressing the buttons Create or Create and Edit they are having no effect.

After this PR the code is addapted to the new dialog to make the buttons
work as usual.

Steps to reproduce the problem:
    1. Go to any m2o field
    2. Write a name that does not exist
    3. Loose the focus
    4. Press on button "Create" or "Create and Edit"
  • Loading branch information
CarlosRoca13 committed Jul 31, 2024
1 parent 677727b commit 080795d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions web_m2x_options/static/src/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
init: function (parent, name, value) {
this.name = name;
this.value = value;
// Define methods for the dialog binding the parent Object to make the
// actions on the correct context.
this.quickCreate = parent._quickCreate.bind(parent);
this.searchCreatePopup = parent._searchCreatePopup.bind(parent);
this.createContext = parent._createContext.bind(parent);
this._super(parent, {
title: _.str.sprintf(_t("Create a %s"), this.name),
size: "medium",
Expand All @@ -37,25 +42,17 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
text: _t("Create"),
classes: "btn-primary",
click: function () {
if (this.$("input").val()) {
this.trigger_up("quick_create", {
value: this.$("input").val(),
});
this.close(true);
} else {
this.$("input").focus();
}
this.quickCreate(this.value);
this.close(true);
},
},
{
text: _t("Create and edit"),
classes: "btn-primary",
close: true,
click: function () {
this.trigger_up("search_create_popup", {
view_type: "form",
value: this.$("input").val(),
});
const valueContext = this.createContext(this.value);
this.searchCreatePopup("form", false, valueContext);
},
},
{
Expand Down

0 comments on commit 080795d

Please sign in to comment.