~jfb-tempo-consulting/unifield-web/US-7530

« back to all changes in this revision

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

  • Committer: jf
  • Date: 2020-08-06 14:23:27 UTC
  • mfrom: (4989.2.5 web-US-5271)
  • Revision ID: jfb@tempo-consulting.fr-20200806142327-fy0fvg6ud982dxu7
US-5271 [IMP] new attr set_ids on button to retrieve the o2m ids
Refresh o2m in a 1st popup when the 2nd popup is closed

lp:~jfb-tempo-consulting/unifield-web/US-5271

Show diffs side-by-side

added added

removed removed

Lines of Context:
417
417
    return relation ? new ListView(relation).go(action) : submit_form(action ? action : 'find');
418
418
}
419
419
 
420
 
function buttonClicked(name, btype, model, id, sure, target, context){
 
420
function buttonClicked(name, btype, model, id, sure, target, context, set_ids){
421
421
 
422
422
    // to be able to get selected lines ids
423
423
    s_ids = [];
424
 
    if (jQuery('[id="order_line"]').length > 0) {
425
 
        s_ids = ListView('order_line').getSelectedRecords();
426
 
    } else if (jQuery('[id="move_lines"]').length > 0){
427
 
        s_ids = ListView('move_lines').getSelectedRecords();
428
 
    } else if (model == 'shipment' && jQuery('[id="pack_family_memory_ids"]').length > 0){
429
 
        s_ids = ListView('pack_family_memory_ids').getSelectedRecords();
430
 
    }  else if (model =='replenishment.inventory.review' && jQuery('[id="line_ids"]').length > 0){
431
 
        s_ids = ListView('line_ids').getSelectedRecords();
432
 
    } else if (model =='replenishment.segment' && jQuery('[id="line_ids"]').length > 0){
433
 
        s_ids = ListView('line_ids').getSelectedRecords();
434
 
    } else if (model =='wizard.compare.rfq' && jQuery('[id="line_ids"]').length > 0){
435
 
        s_ids = ListView('line_ids').getSelectedRecords();
 
424
    s_dom = [];
 
425
    if (set_ids) {
 
426
        if (jQuery('[id="' + set_ids + '"]').length > 0) {
 
427
            if ($('#'+set_ids+'_check_all').length) {
 
428
                // lines can be ticked
 
429
                s_ids = ListView(set_ids).getSelectedRecords();
 
430
 
 
431
            } else {
 
432
                // no tickbox on lines, get the filter
 
433
                s_dom = openobject.dom.get(set_ids + '/_terp_domain').value;
 
434
            }
 
435
        }
 
436
    }
 
437
    else {
 
438
        if (jQuery('[id="order_line"]').length > 0) {
 
439
            s_ids = ListView('order_line').getSelectedRecords();
 
440
        } else if (jQuery('[id="move_lines"]').length > 0){
 
441
            s_ids = ListView('move_lines').getSelectedRecords();
 
442
        } else if (model == 'shipment' && jQuery('[id="pack_family_memory_ids"]').length > 0){
 
443
            s_ids = ListView('pack_family_memory_ids').getSelectedRecords();
 
444
        }  else if (model =='replenishment.inventory.review' && jQuery('[id="line_ids"]').length > 0){
 
445
            s_ids = ListView('line_ids').getSelectedRecords();
 
446
        } else if (model =='replenishment.segment' && jQuery('[id="line_ids"]').length > 0){
 
447
            s_ids = ListView('line_ids').getSelectedRecords();
 
448
        } else if (model =='wizard.compare.rfq' && jQuery('[id="line_ids"]').length > 0){
 
449
        s_ids = ListView('line_ids').getSelectedRecords();
 
450
        }
436
451
    }
437
452
 
438
453
    if (sure && !confirm(sure.replace('%(number_selected)s',s_ids.length))) {
444
459
        '_terp_button/btype': btype,
445
460
        '_terp_button/model': model,
446
461
        '_terp_button/id': id,
447
 
        '_terp_button/selected_ids': s_ids
 
462
        '_terp_button/selected_ids': s_ids,
 
463
        '_terp_button/selected_domain': s_dom,
448
464
    };
449
465
 
450
466
    // if works as expected can be extended to other buttons
451
 
    test_double = name == 'import_file' && btype == 'object' && model == 'initial.stock.inventory'
 
467
    test_double = (name == 'import_file' && btype == 'object' && model == 'initial.stock.inventory') || ((name == 'copy_all' || name == 'uncopy_all')  && model == 'stock.incoming.processor')
452
468
    if (!context || context == "{}") {
453
469
        var act = get_form_action(btype == 'cancel' ? 'cancel' : 'save', params);
454
470
        submit_form(act, null, target, test_double);