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

« back to all changes in this revision

Viewing changes to addons/openerp/controllers/templates/progress.mako

  • Committer: jf
  • Date: 2019-08-08 13:04:49 UTC
  • mfrom: (4959.6.29 US-5859-web)
  • Revision ID: jfb@tempo-consulting.fr-20190808130449-fvmwhhrevxve8qye
US-5859 [IMP] Pick/Pack/Ship: new behavior
    - start progress bar on button action
    - new button action {'type': 'ir.actions.refresh_o2m', 'o2m_refresh': 'move_lines'}, to only refresh a o2m field
    - form  new attribute force_string=1 to use string=XXX instead of the name of the action

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%inherit file="/openerp/controllers/templates/base_dispatch.mako"/>
 
2
 
 
3
<%def name="header()">
 
4
    <title>${_("Information")}</title>
 
5
    <link href="/openerp/static/css/style.css" rel="stylesheet" type="text/css"/>
 
6
    <script type="text/javascript">
 
7
        function set_as_read(target) {
 
8
            var req = openobject.http.postJSON('/openerp/progressbar/setread', {'model': "${model}", 'id': ${id}, "job_id": ${job_id}});
 
9
            req.addCallback(function(obj) {
 
10
                if (obj.error) {
 
11
                    jQuery.fancybox(obj.error, {scrolling: 'no'});
 
12
                }
 
13
            });
 
14
        }
 
15
 
 
16
        function open_progress_target(target) {
 
17
            if (target) {
 
18
                window.openAction(target);
 
19
            } else {
 
20
                window.editRecord(${id});
 
21
            }
 
22
            jQuery.fancybox.close();
 
23
        }
 
24
 
 
25
        get_progress = function () {
 
26
            var req = openobject.http.postJSON('/openerp/progressbar/get', {'model': "${model}", 'id': ${id}, "job_id": ${job_id}});
 
27
            req.addCallback(function(obj) {
 
28
                if (obj.error) {
 
29
                    jQuery.fancybox(obj.error, {scrolling: 'no'});
 
30
                }
 
31
                else {
 
32
                    $('#indicator').width((obj.progress*250)/100+'px');
 
33
                    $('#percentage').html(obj.progress+'%');
 
34
                    if (obj.state == 'error') {
 
35
                        set_as_read();
 
36
                        $('#boxtitle').html(_("Last Processing Error"));
 
37
                        $('#open_src').click(open_progress_target);
 
38
                        $('#open_src').show();
 
39
                        $('#pwidget').css('overflow', 'scroll');
 
40
                        $('#pwidget').css('white-space', 'pre');
 
41
                        $('#pwidget').html(obj.errormsg);
 
42
                    } else if (obj.state != 'done') {
 
43
                        setTimeout(get_progress, 1000);
 
44
                    } else {
 
45
                        set_as_read();
 
46
                        if (obj.job_name) {
 
47
                            $('#boxtitle').html(obj.job_name + " " + _("Done"));
 
48
                        } else {
 
49
                            $('#boxtitle').html(_("Done"));
 
50
                        }
 
51
                        if (obj.src_name) {
 
52
                            $('#open_src').html(_('View ')+obj.src_name)
 
53
                        }
 
54
                        $('#open_src').click(function() {open_progress_target()});
 
55
                        if (obj.target) {
 
56
                            if (obj.target_name) {
 
57
                                $('#open_target').html(_('View ')+obj.target_name);
 
58
                            }
 
59
                            $('#open_target').show();
 
60
                            $('#open_target').click(function() {open_progress_target(obj.target)});
 
61
                        } else {
 
62
                            $('#open_src').show();
 
63
                        }
 
64
                    }
 
65
                }
 
66
                });
 
67
 
 
68
        }
 
69
    jQuery(document).ready(function () {
 
70
        get_progress();
 
71
    });
 
72
    </script>
 
73
 
 
74
    <style>
 
75
        #progressbar {
 
76
            width: 250px;
 
77
            padding:1px;
 
78
            background-color:white;
 
79
            border:1px solid black;
 
80
            height:28px;
 
81
            line-height: 28px;
 
82
            vertical-align: middle;
 
83
            text-align: center;
 
84
            font-weight: bold;
 
85
            font-size: 120%;
 
86
            }
 
87
 
 
88
        #pwidget {
 
89
            background-color:lightgray;
 
90
            width:254px;
 
91
            margin-top: 20px;
 
92
            margin-left: auto;
 
93
            margin-right: auto;
 
94
            padding:2px;
 
95
            -moz-border-radius:3px;
 
96
            border-radius:3px;
 
97
            text-align:center;
 
98
            border:1px solid gray;
 
99
        }
 
100
 
 
101
        #indicator {
 
102
            width: 0px;
 
103
            background-image: linear-gradient(white, green);
 
104
            height: 28px;
 
105
            margin: 0;
 
106
        }
 
107
 
 
108
        #percentage {
 
109
            position: absolute;
 
110
        }
 
111
    </style>
 
112
</%def>
 
113
 
 
114
<%def name="content()">
 
115
    <table class="view" cellspacing="5" border="0" height="200px" width="400px">
 
116
        <tr>
 
117
            <td>
 
118
                <h1 id="boxtitle">${_("In Progress")}</h1>
 
119
            </td>
 
120
        </tr>
 
121
        <tr>
 
122
            <td>
 
123
                <div id="pwidget">
 
124
                    <div id="progressbar">
 
125
                    <span id="percentage"></span>
 
126
                    <div id="indicator" style="width: 25px"></div>
 
127
                    </div>
 
128
                </div>
 
129
            </td>
 
130
        </tr>
 
131
        <tr>
 
132
            <td>
 
133
            <button id="open_src" style="display:none">View Object</button>
 
134
            <button id="open_target" style="display:none">View Target</button>
 
135
            </td>
 
136
        </tr>
 
137
    </table>
 
138
</%def>