← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix-js into lp:openerp-humanitarian-ngo/purchase-wkfl

 

Nicolas Bessi - Camptocamp has proposed merging lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix-js into lp:openerp-humanitarian-ngo/purchase-wkfl.

Requested reviews:
  OpenERP for Humanitarian Core Editors (humanitarian-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix-js/+merge/246902

Fix javascript to be resilient to return values~humanitarian-core-editors/openerp-humanitarian-ngo/ngo-github-7.0
-- 
Your team OpenERP for Humanitarian Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix-js into lp:openerp-humanitarian-ngo/purchase-wkfl.
=== modified file 'purchase_requisition_extended/model/purchase_requisition.py'
--- purchase_requisition_extended/model/purchase_requisition.py	2014-05-01 12:12:51 +0000
+++ purchase_requisition_extended/model/purchase_requisition.py	2015-01-19 14:44:10 +0000
@@ -395,7 +395,7 @@
         for id in ids:
             wf_service.trg_validate(uid, 'purchase.requisition',
                                     id, 'close_bid', cr)
-        return False
+        return True
 
 
 class purchase_requisition_line(orm.Model):

=== modified file 'purchase_requisition_extended/static/src/js/web_addons.js'
--- purchase_requisition_extended/static/src/js/web_addons.js	2013-11-01 11:44:19 +0000
+++ purchase_requisition_extended/static/src/js/web_addons.js	2015-01-19 14:44:10 +0000
@@ -1,29 +1,51 @@
 openerp.purchase_requisition_extended = function(instance) {
     var QWeb = instance.web.qweb,
-        _t = instance.web._t;
-
-    instance.web.purchase_requisition.CompareListView.include({
-        init: function () {
-            var self = this;
-            this._super.apply(this, arguments);
-            this.on('list_view_loaded', this, function() {
-                if(self.$buttons.find('.oe_close_bid').length == 0){
-                    var button = $("<button type='button' class='oe_button oe_highlight oe_close_bid'>Confirm Selection</button>")
-                        .click(this.proxy('close_bids_selection'));
-                    button.after('<span class="oe_fade" style="margin:0 4px">or</span>');
-                    button.after($('<a accesskey="D" class="oe_bold oe_form_button_cancel" href="#">Close</a>')
-                        .click(function(){self.do_action('history_back')}));
-                    self.$buttons.append(button);
-                }
-                self.$buttons.find('.oe_generate_po').remove();
-            });
-        },
-        close_bids_selection: function () {
-            var self = this;
-            new instance.web.Model('purchase.requisition').call("close_callforbids",[self.dataset.context.active_id,self.dataset.context]).then(function(result) {
-                self.do_action(result,{on_close:function(){self.do_action('history_back')}});
-            });
-        },
-    });
-
+    _t = instance.web._t;
+
+    instance.web.purchase_requisition.CompareListView.include(
+        {
+            init: function () {
+                var self = this;
+                this._super.apply(this, arguments);
+                this.on(
+                    'list_view_loaded',
+                    this,
+                    function() {
+                        if(self.$buttons.find('.oe_close_bid').length == 0){
+                            var button_body = "<button type='button' class='oe_button oe_highlight oe_close_bid'>Confirm Selection</button>"
+                            var return_link = '<a accesskey="D" class="oe_bold oe_form_button_cancel" href="#">Close</a>'
+                            var button = $(button_body).click(
+                                this.proxy('close_bids_selection')
+                            );
+                            button.after('<span class="oe_fade" style="margin:0 4px">or</span>');
+                            button.after(
+                                $(return_link).click(
+                                    function(){self.do_action('history_back')}
+                                )
+                            );
+                            self.$buttons.append(button);
+                        }
+                        self.$buttons.find('.oe_generate_po').remove();
+                    }
+                );
+            },
+            close_bids_selection: function () {
+                var self = this;
+                new instance.web.Model('purchase.requisition').call(
+                    "close_callforbids",
+                    [self.dataset.context.active_id, self.dataset.context]
+                ).then(
+                    function(result) {
+                        self.do_action(
+                            false,
+                            {
+                                on_close: function(){self.do_action('history_back')},
+                                context: {}
+                            }
+                        );
+                    }
+                );
+            },
+        }
+    );
 }