~therp-nl/web-addons/6.1-icons

« back to all changes in this revision

Viewing changes to web_import_models_with_inherits/static/src/js/data_import.js

  • Committer: Guewen Baconnier
  • Author(s): Stefan Rijnhart
  • Date: 2013-02-18 08:41:44 UTC
  • mfrom: (2.1.3 6.1)
  • Revision ID: guewen.baconnier@camptocamp.com-20130218084144-z2az6cddulk0kj7g
[ADD] Module to allow the import of models with _inherits (workaround for lp:930318)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 
 
3
   Copyright (C) 2013 Therp BV
 
4
   License: GNU AFFERO GENERAL PUBLIC LICENSE
 
5
            Version 3 or any later version
 
6
 
 
7
 */
 
8
   
 
9
openerp.web_import_models_with_inherits = function(openerp) {
 
10
    openerp.web.DataImport.include({
 
11
        /* At widget start, tag on to the 'ready' queue with a function to
 
12
           add the model's _inherits fields to the list that contains all
 
13
           fields that need not be provided by the import file even if they
 
14
           have the 'required' attribute
 
15
        */
 
16
        start: function() {
 
17
            var self = this;
 
18
            this._super();
 
19
            this.ready.push(new openerp.web.DataSet(
 
20
                this, this.model, this.context).call(
 
21
                    'get_fields_inherits', [], function(fields) {
 
22
                        _.each(fields, function(val) {
 
23
                            self.fields_with_defaults.push(val);
 
24
                        });
 
25
                    }));
 
26
        },
 
27
    });
 
28
}