wip
authorniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 17 Sep 2012 12:53:09 +0000 (14:53 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Mon, 17 Sep 2012 12:53:09 +0000 (14:53 +0200)
bzr revid: nicolas.vanhoren@openerp.com-20120917125309-0ioenvhlkaue1lc6

addons/account/static/src/js/account_move_reconciliation.js
addons/account/static/src/xml/account_move_reconciliation.xml

index 5f86171..c2df031 100644 (file)
@@ -12,9 +12,22 @@ openerp.account = function (instance) {
             this.current_partner = null;
         },
         on_loaded: function() {
+            var self = this;
             var tmp = this._super.apply(this, arguments);
-            if (this.partners)
+            if (this.partners) {
                 this.$el.prepend(QWeb.render("AccountReconciliation", {widget: this}));
+                this.$("oe_account_recon_previous").click(function() {
+                    self.current_partner = (self.current_partner - 1) % self.partners.length;
+                    self.search_by_partner();
+                });
+                this.$("oe_account_recon_next").click(function() {
+                    self.current_partner = (self.current_partner + 1) % self.partners.length;
+                    self.search_by_partner();
+                });
+                this.$("oe_account_recon_reconcile").click(function() {
+                    self.reconcile();
+                });
+            }
             return tmp;
         },
         do_search: function(domain, context, group_by) {
@@ -25,9 +38,17 @@ openerp.account = function (instance) {
             this.old_search = _.bind(this._super, this);
             var mod = new instance.web.Model(this.model, context, domain);
             return mod.query("partner_id").group_by(["partner_id"]).pipe(function(result) {
+                var current = self.current_partner !== null ? self.partner[self.current_partner][0] : null;
                 self.partners = _.chain(result).pluck("attributes").pluck("value")
                     .filter(function(el) {return !!el;}).value();
-                self.current_partner = self.partners.length == 0 ? null : 0;
+                var index = _.find(_.range(self.partners.length), function(el) {
+                    if (current === self.partners[el][0])
+                        return true;
+                });
+                if (index !== undefined)
+                    self.current_partner = index;
+                else
+                    self.current_partner = self.partners.length == 0 ? null : 0;
                 self.search_by_partner();
             });
         },
@@ -35,6 +56,10 @@ openerp.account = function (instance) {
             return this.old_search(new instance.web.CompoundDomain(this.last_domain, [["partner_id", "in", this.current_partner === null ? [] :
                 [this.partners[this.current_partner][0]] ]]), this.last_context, this.last_group_by);
         },
+        reconcile: function() {
+            var self = this;
+            var ids = this.get_selected_ids();
+        },
     });
     
     /*instance.web.views.add('form_clone', 'instance.account.extend_form_view');
index 33adc4e..e93790b 100644 (file)
@@ -5,33 +5,22 @@
     
     <t t-name="AccountReconciliation">
         <div>
-            <div>
-                <h3>
-                    <a>Previous</a>
-                    <a>Next</a>
-                    <t t-if="widget.current_partner === null">
-                        There is no pending reconciliation.
-                    </t>
-                    <t t-if="widget.current_partner !== null">
+            <t t-if="widget.current_partner === null">
+                There is no pending reconciliation.
+            </t>
+            <t t-if="widget.current_partner !== null">
+                <div>
+                    <h3>
+                        <a class="oe_account_recon_previous" href="javascript:void(0)">Previous</a>
+                        <a class="oe_account_recon_next" href="javascript:void(0)">Next</a>
                         <t t-esc="'' + widget.partners[widget.current_partner][1] + ' (' + (widget.current_partner + 1) + '/' + widget.partners.length + ')'"/>
-                    </t>
-                </h3>
-            </div>
-            <div>
-                <a>Reconcile</a>
-            </div>
+                    </h3>
+                </div>
+                <div>
+                    <a class="oe_account_recon_reconcile" href="javascript:void(0)">Reconcile</a>
+                </div>
+            </t>
         </div>
     </t>
 
-    <t t-extend="ViewManagerAction">
-          <t t-jquery=".oe_view_manager_header" t-operation="after">
-          <div class='oe_extended_form_view'></div>
-          </t>
-    </t>
-    <t t-name="ExtendedFormView">
-        <div class="oe_formview">
-            <div class="oe_form_container"/>
-       </div>
-   </t>
-
 </templates>