How to load .js, in the web/database/manager form?
It seems this doesn't work on login form or before login
I even started odoo with --load web,mymodule adding .js in assets and they are not loaded.
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
How to load .js, in the web/database/manager form?
It seems this doesn't work on login form or before login
I even started odoo with --load web,mymodule adding .js in assets and they are not loaded.
Hello,
For This you have to copy paste database_manager.html file in your module and create one controller method for file like :
    @http.route('/web/database/manager', type='http', auth="none")
    def manager(self, **kw):
        request.session.logout()
        loader = jinja2.PackageLoader('openerp.addons.module_name', "views")
        env = jinja2.Environment(loader=loader, autoescape=True)
        return env.get_template("database_manager.html").render({
                'modules': simplejson.dumps(module_boot()),
            })
Now you can add your .js in header of database_manager.html where other .js file added.Hope this will help you !
Thanks for you answer i manage to load the scripts.
But I got openerp is not defined error :(
My scripts are defined as:
openerp.addons.mymodule = function (instance) {
instance.web.myfunc = instance.web.DatabaseManager.extend( {something...
});};
What could be the problem?
SOLVED: It was the order in the html file :)
=========================
Sorry text on comment is unreadable.
I was able to reach this point, the NEW.js is loaded, if I set a break point in "var break_point;" it stops there, I don't get any error, but it just don't execute the rest of the code...
openerp.MYMODULE = function (instance) {
  /*just for test in a break point*/
  var break_point;
  /* redefine from chrome.js:412 */
  instance.web.DatabaseManagerNEW = instance.web.DatabaseManager.extend( {
    do_render: function() {
      this._super(parent);
      /* add new submit handler*/
      self.$el.find("form[name=NEW_db_form]").validate({ submitHandler: self.do_NEW });
    },
    do_NEW: function(form) {
      var self = this;
      var $form = $(form),
          fields = $form.serializeArray();
      self.rpc("/web/database/NEW", {'fields': fields}).done(function(result) {
          if (result.error) {
            self.display_error(result);
            return;
          }
          self.start();
      });
    },
 });
 /* redefine view_form.js:72 */
 instance.web.FormViewNEW = instance.web.FormView.extend({
   load_form: function(data) {
       this._super(parent);
       /* redefine button */
       if (!this.sidebar && this.options.$sidebar) {
           this.sidebar.add_items('other', _.compact([
           self.is_action_enabled('create') && { label: _t('NEW'), callback: self.on_button_NEW }
 ]));
       }
   },
   on_button_NEW: function() {
       var self = this;
       return this.has_been_loaded.then(function() {
       return self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
           self.record_created(new_id);
           self.to_edit_mode();
        });
     });
   },
 });
};
This code inserted in those files works, but not in my NEW.js file.
It was the script order in html :P Now I don't have errors but it doesn't run :(
I think I'm fighting with js... openerp.MYMODULE = function (instance) { instance.web.DatabaseManagerNEW = instance.web.DatabaseManager.extend( { do_render_replicate: function() { this._super(parent); self.$el.find("form[name=NEW_db_form]").validate({ submitHandler: self.do_NEW }); }, do_NEW: function(form) { var self = this; var $form = $(form), fields = $form.serializeArray(); self.rpc("/web/database/NEW", {'fields': fields}).done(function(result) { if (result.error) { self.display_error(result); return; } self.start(); }); }, }); instance.web.FormViewNEW = instance.web.FormView.extend({ load_form_NEW: function(data) { this._super(parent); if (!this.sidebar && this.options.$sidebar) { this.sidebar.add_items('other', _.compact([ self.is_action_enabled('create') && { label: _t('NEW'), callback: self.on_button_NEW } ])); } }, on_button_NEW: function() { var self = this; return this.has_been_loaded.then(function() { return self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) { self.record_created(new_id); self.to_edit_mode(); }); }); }, }); }; Can you point me the right direction?
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|  | 1 mars 24  | 9521 | ||
|  | 3 mai 20  | 7634 | ||
|  | 1 janv. 16  | 5933 | ||
|  | 0 mars 25  | 1832 | ||
|  | 0 janv. 25  | 4101 |