-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Improved a Migrated js file and onchnage specification.
- Loading branch information
Showing
8 changed files
with
154 additions
and
178 deletions.
There are no files selected for viewing
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
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
81 changes: 27 additions & 54 deletions
81
product_configurator_mrp/static/src/js/form_controller.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 |
---|---|---|
@@ -1,60 +1,33 @@ | ||
odoo.define("product_configurator_mrp.FormController", function (require) { | ||
"use strict"; | ||
/** @odoo-module **/ | ||
|
||
var core = require("web.core"); | ||
var FormController = require("web.FormController"); | ||
var FormView = require("web.FormView"); | ||
var viewRegistry = require("web.view_registry"); | ||
import { _t } from "@web/core/l10n/translation"; | ||
import { registry } from "@web/core/registry"; | ||
import { useService } from "@web/core/utils/hooks"; | ||
import { formView } from "@web/views/form/form_view"; | ||
import { FormController } from "@web/views/form/form_controller"; | ||
|
||
var qweb = core.qweb; | ||
export class ProductConfiguratorFormController extends FormController { | ||
setup() { | ||
super.setup(); | ||
this.action = useService("action"); | ||
this.rpc = useService("rpc"); | ||
this.orm = useService("orm"); | ||
} | ||
|
||
var ConfigFormController = FormController.extend({ | ||
buttons_template: "ConfigFormView.buttons", | ||
events: _.extend({}, FormController.prototype.events, { | ||
"click .o_form_button_create_config": "_onConfigure", | ||
}), | ||
async _onConfigure() { | ||
let action = await this.orm.call("mrp.production", 'action_config_start', []) | ||
this.action.doAction(action) | ||
} | ||
} | ||
ProductConfiguratorFormController.components = { | ||
...FormController.components, | ||
}; | ||
|
||
renderButtons: function () { | ||
var self = this; | ||
var $footer = this.footerToButtons ? this.renderer.$("footer") : null; | ||
var mustRenderFooterButtons = $footer && $footer.length; | ||
self._super.apply(this, arguments); | ||
if (mustRenderFooterButtons); | ||
else if ( | ||
this.$buttons && | ||
self.modelName === "mrp.production" && | ||
self.initialState.context.custom_create_variant | ||
) { | ||
var button_create = this.$buttons.find(".o_form_button_create"); | ||
button_create.after( | ||
qweb.render("ConfigFormView.buttons", { | ||
widget: this, | ||
}) | ||
); | ||
this.$buttons | ||
.find(".o_form_button_create_config") | ||
.css("display", "inline"); | ||
} | ||
}, | ||
|
||
_onConfigure: function () { | ||
var self = this; | ||
return this._rpc({ | ||
model: "mrp.production", | ||
method: "action_config_start", | ||
args: [""], | ||
context: this.initialState.context, | ||
}).then(function (result) { | ||
self.do_action(result); | ||
}); | ||
}, | ||
}); | ||
export const ProductConfiguratorFormView = { | ||
...formView, | ||
Controller: ProductConfiguratorFormController, | ||
buttonTemplate: "product_configurator_mrp.FormButtons", | ||
}; | ||
|
||
var ConfigFormView = FormView.extend({ | ||
config: _.extend({}, FormView.prototype.config, { | ||
Controller: ConfigFormController, | ||
}), | ||
}); | ||
|
||
viewRegistry.add("product_configurator_mrp_form", ConfigFormView); | ||
}); | ||
registry.category("views").add("product_configurator_mrp_form", ProductConfiguratorFormView); |
69 changes: 27 additions & 42 deletions
69
product_configurator_mrp/static/src/js/kanban_controller.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 |
---|---|---|
@@ -1,48 +1,33 @@ | ||
odoo.define("product_configurator_mrp.KanbanController", function (require) { | ||
"use strict"; | ||
/** @odoo-module **/ | ||
|
||
var KanbanController = require("web.KanbanController"); | ||
var KanbanView = require("web.KanbanView"); | ||
var viewRegistry = require("web.view_registry"); | ||
import { _t } from "@web/core/l10n/translation"; | ||
import { registry } from "@web/core/registry"; | ||
import { useService } from "@web/core/utils/hooks"; | ||
import { kanbanView } from "@web/views/kanban/kanban_view"; | ||
import { KanbanController } from "@web/views/kanban/kanban_controller"; | ||
|
||
var ConfigKanbanController = KanbanController.extend({ | ||
buttons_template: "ConfigKanbanView.buttons", | ||
events: _.extend({}, KanbanController.prototype.events, { | ||
"click .o-kanban-button-new_config": "_onConfigure", | ||
}), | ||
export class ProductConfiguratorKanbanController extends KanbanController { | ||
setup() { | ||
super.setup(); | ||
this.action = useService("action"); | ||
this.rpc = useService("rpc"); | ||
this.orm = useService("orm"); | ||
|
||
renderButtons: function () { | ||
var self = this; | ||
self._super.apply(this, arguments); | ||
if ( | ||
this.$buttons && | ||
self.modelName === "mrp.production" && | ||
self.initialState.context.custom_create_variant | ||
) { | ||
this.$buttons | ||
.find(".o-kanban-button-new_config") | ||
.css("display", "inline"); | ||
} | ||
}, | ||
} | ||
|
||
_onConfigure: function () { | ||
var self = this; | ||
return this._rpc({ | ||
model: "mrp.production", | ||
method: "action_config_start", | ||
args: [""], | ||
context: this.initialState.context, | ||
}).then(function (result) { | ||
self.do_action(result); | ||
}); | ||
}, | ||
}); | ||
async _onConfigure() { | ||
let action = await this.orm.call("mrp.production", 'action_config_start', []) | ||
this.action.doAction(action) | ||
} | ||
} | ||
ProductConfiguratorKanbanController.components = { | ||
...KanbanController.components, | ||
}; | ||
|
||
var ConfigKanbanView = KanbanView.extend({ | ||
config: _.extend({}, KanbanView.prototype.config, { | ||
Controller: ConfigKanbanController, | ||
}), | ||
}); | ||
|
||
viewRegistry.add("product_configurator_mrp_kanban", ConfigKanbanView); | ||
}); | ||
export const ProductConfiguratorKanbanView = { | ||
...kanbanView, | ||
Controller: ProductConfiguratorKanbanController, | ||
buttonTemplate: "product_configurator_mrp.KanbanButtons", | ||
}; | ||
registry.category("views").add("product_configurator_mrp_kanban", ProductConfiguratorKanbanView); |
82 changes: 35 additions & 47 deletions
82
product_configurator_mrp/static/src/js/list_controller.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 |
---|---|---|
@@ -1,47 +1,35 @@ | ||
odoo.define("product_configurator_mrp.ListController", function (require) { | ||
"use strict"; | ||
var ListController = require("web.ListController"); | ||
var ListView = require("web.ListView"); | ||
var viewRegistry = require("web.view_registry"); | ||
|
||
var ConfigListController = ListController.extend({ | ||
buttons_template: "ConfigListView.buttons", | ||
events: _.extend({}, ListController.prototype.events, { | ||
"click .o_list_button_add_config": "_onConfigure", | ||
}), | ||
|
||
renderButtons: function () { | ||
var self = this; | ||
self._super.apply(this, arguments); | ||
if ( | ||
this.$buttons && | ||
self.modelName === "mrp.production" && | ||
self.initialState.context.custom_create_variant | ||
) { | ||
this.$buttons | ||
.find(".o_list_button_add_config") | ||
.css("display", "inline"); | ||
} | ||
}, | ||
|
||
_onConfigure: function () { | ||
var self = this; | ||
return this._rpc({ | ||
model: "mrp.production", | ||
method: "action_config_start", | ||
args: [""], | ||
context: this.initialState.context, | ||
}).then(function (result) { | ||
self.do_action(result); | ||
}); | ||
}, | ||
}); | ||
|
||
var ConfigListView = ListView.extend({ | ||
config: _.extend({}, ListView.prototype.config, { | ||
Controller: ConfigListController, | ||
}), | ||
}); | ||
|
||
viewRegistry.add("product_configurator_mrp_tree", ConfigListView); | ||
}); | ||
/** @odoo-module **/ | ||
|
||
import { _t } from "@web/core/l10n/translation"; | ||
import { registry } from "@web/core/registry"; | ||
import { listView } from "@web/views/list/list_view"; | ||
import { ListController } from "@web/views/list/list_controller"; | ||
import { useService } from "@web/core/utils/hooks"; | ||
|
||
export class ProductConfiguratorController extends ListController { | ||
setup() { | ||
super.setup(); | ||
this.action = useService("action"); | ||
this.rpc = useService("rpc"); | ||
this.orm = useService("orm"); | ||
|
||
} | ||
|
||
async _onConfigure() { | ||
let action = await this.orm.call("mrp.production", 'action_config_start', []) | ||
this.action.doAction(action) | ||
} | ||
}; | ||
|
||
ProductConfiguratorController.components = { | ||
...ListController.components, | ||
}; | ||
|
||
export const ProductConfiguratorListView = { | ||
...listView, | ||
Controller: ProductConfiguratorController, | ||
buttonTemplate: "product_configurator_mrp.ListButtons", | ||
}; | ||
|
||
|
||
registry.category("views").add("product_configurator_mrp_tree", ProductConfiguratorListView); |
Oops, something went wrong.