~unifield-team/unifield-web/main

« back to all changes in this revision

Viewing changes to addons/openerp/static/javascript/form.js

[MERGE] openerp-6.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
// Developed by OpenERP (http://openerp.com) and Axelor (http://axelor.com).
8
8
//
9
9
// The OpenERP web client is distributed under the "OpenERP Public License".
10
 
// It's based on Mozilla Public License Version (MPL) 1.1 with following 
 
10
// It's based on Mozilla Public License Version (MPL) 1.1 with following
11
11
// restrictions:
12
12
//
13
13
// -   All names, links and logos of OpenERP must be kept as in original
212
212
        action = 'save';
213
213
        args['_terp_return_edit'] = 1;
214
214
    }
215
 
    
 
215
 
216
216
    if(action == 'save_and_close') {
217
217
        action = 'save';
218
218
        args['_terp_close'] = 1;
403
403
                case "picture":
404
404
                    name = this.id;
405
405
                    break;
406
 
                case 'text_html':
407
 
                    if (!tinyMCE.get(this.name)) {
408
 
                        break;
409
 
                    }
410
 
                    attrs['value'] = tinyMCE.get(this.name).getContent();
411
 
                    break;
412
406
                case 'reference':
413
407
                    if (!value) {
414
408
                        break;
486
480
    var select = function (id) { return $form.find(idSelector(id_prefix + id)); };
487
481
 
488
482
    var post_url = callback ? '/openerp/form/on_change' : '/openerp/form/change_default_get';
489
 
    
 
483
 
490
484
    var form_data = getFormData(1, true);
491
485
    /* testing if the record is an empty record, if it does not contain anything except
492
486
     * an id, the on_change method is not called
610
604
                        new ListView(prefix + k).reload();
611
605
                    }
612
606
                }
613
 
                
 
607
 
614
608
                switch (kind) {
615
609
                    case 'picture':
616
610
                        fld.src = value;
649
643
                        openobject.dom.get(prefix + k + '_checkbox_').checked = value || false;
650
644
                        break;
651
645
                    case 'text_html':
652
 
                        if (tinyMCE.get(prefix + k)) {
653
 
                            tinyMCE.execInstanceCommand(prefix + k, 'mceSetContent', false, value || '')
654
 
                        }
 
646
                        $('#' + prefix + k).val(value || '');
655
647
                        break;
656
648
                    case 'selection':
657
649
                        if (typeof(value)=='object') {
673
665
                    // do nothing on default
674
666
                }
675
667
 
676
 
                MochiKit.Signal.signal(fld, 'onchange');
 
668
                $fld.trigger('change');
677
669
                MochiKit.Signal.signal(window.document, 'onfieldchange', fld);
678
670
            }
679
671
 
811
803
 
812
804
    var prefix = id.indexOf('/') > -1 ? id.slice(0, id.lastIndexOf('/')) + '/' : '';
813
805
    if ((prefix.split('/')[0])== '_terp_listfields') {
814
 
        prefix = ''
 
806
        prefix = (prefix.split('/')[1]);
815
807
    }
816
808
 
817
 
    var model = prefix ? openobject.dom.get(prefix + '_terp_model').value : openobject.dom.get('_terp_model').value;
 
809
    var model = prefix ? openobject.dom.get(prefix + '/_terp_model').value : openobject.dom.get('_terp_model').value;
818
810
 
819
811
    openobject.http.postJSON(act, {
820
812
        'model': model,
825
817
    }).addCallback(function(obj){
826
818
        var $tbody = jQuery('<tbody>');
827
819
        jQuery.each(obj.defaults, function (_, default_) {
828
 
            
 
820
 
829
821
            jQuery('<tr>').append(jQuery('<td>').append(
830
822
                jQuery('<span>').click(function () {
831
823
                    hideContextMenu();
963
955
        var id = eval(params['_terp_selection'])[0]
964
956
    } else {
965
957
        var id = jQuery('[id="'+field+'"]').val();
 
958
        if (id == 'False') {
 
959
                error_display(_("You must save this record to perform the action !"));
 
960
            return;
 
961
        }
966
962
    }
967
963
 
968
964
    var action_id = $src.attr('action_id') || null;
969
965
    var relation = $src.attr('relation');
970
966
    var datas = $src.attr('data') || null;
971
 
    
 
967
 
972
968
    var domain = $src.attr('domain');
973
969
    var context = $src.attr('context');
974
970
    var context_menu = context_menu ? true: null;