~openerp-dev/openobject-client/trunk-dev-client_merge_rev1222

« back to all changes in this revision

Viewing changes to bin/widget/screen/screen.py

  • Committer: Stephane Wirtel
  • Date: 2010-04-01 11:59:28 UTC
  • mfrom: (1202.1.20 trunk-dev-client)
  • Revision ID: stephane@openerp.com-20100401115928-n7usfuaypq97173h
[MERGE] lp:~openerp-dev/openobject-client/trunk-dev-client 

revno: 1222
revision-id: nch@tinyerp.com-20100401071511-btkyuld52qd3004h
parent: nch@tinyerp.com-20100401065749-ukknmty6qrdunjqw
committer: nch@tinyerp.com
branch nick: trunk-dev-client
timestamp: Thu 2010-04-01 12:45:11 +0530
message:
  [IMP,REF]:Columns move in multilevel group by

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        self.view_fields = {} # Used to switch self.fields when the view switchs
110
110
        self.sort_domain = []
111
111
        self.old_ctx = {}
112
 
 
113
112
        if view_type:
114
113
            self.view_to_load = view_type[1:]
115
114
            view_id = False
724
723
                    show_search=self.show_search and vt in ('tree', 'graph','calendar'),
725
724
            )
726
725
 
 
726
    def groupby_next(self):
 
727
        if not self.models.models:
 
728
             self.current_model = self.models.list_group.lst[0]
 
729
        elif self.current_view.store.on_iter_has_child(self.current_model):
 
730
                path = self.current_view.store.on_get_path(self.current_model)
 
731
                if path == (0,):
 
732
                     self.current_view.expand_row(path)
 
733
                self.current_model = self.current_view.store.on_iter_children(self.current_model)
 
734
        else:
 
735
            if self.current_model in self.current_model.list_group.lst:
 
736
                idx = self.current_model.list_group.lst.index(self.current_model)
 
737
                if idx + 1 >= len(self.current_model.list_group.lst):
 
738
                    parent = True
 
739
                    while parent:
 
740
                        parent = self.current_view.store.on_iter_parent(self.current_model)
 
741
                        if parent:
 
742
                            self.current_model = parent
 
743
                            if self.current_view.store.on_iter_next(parent):
 
744
                                break
 
745
                    self.current_model = self.current_view.store.on_iter_next(self.current_model)
 
746
                    if self.current_model == None:
 
747
                        self.current_model = self.current_view.store.on_get_iter \
 
748
                                            (self.current_view.store.on_get_path \
 
749
                                             (self.current_view.store.get_iter_first()))
 
750
                else:
 
751
                    idx = (idx+1) % len(self.current_model.list_group.lst)
 
752
                    self.current_model = self.current_model.list_group.lst[idx]
 
753
        if self.current_model:
 
754
            path = self.current_view.store.on_get_path(self.current_model)
 
755
            self.current_view.expand_row(path)
 
756
        return
 
757
 
 
758
    def groupby_prev(self):
 
759
        if not self.models.models :
 
760
             self.current_model = self.models.list_group.lst[-1]
 
761
        else:
 
762
             if self.current_model in self.current_model.list_group.lst:
 
763
                idx = self.current_model.list_group.lst.index(self.current_model) - 1
 
764
                if idx < 0 :
 
765
                    parent = self.current_view.store.on_iter_parent(self.current_model)
 
766
                    if parent:
 
767
                        self.current_model = parent
 
768
                else:
 
769
                    idx = (idx) % len(self.current_model.list_group.lst)
 
770
                    self.current_model = self.current_model.list_group.lst[idx]
 
771
        if self.current_model:
 
772
            path = self.current_view.store.on_get_path(self.current_model)
 
773
            self.current_view.collapse_row(path)
 
774
        return
 
775
 
727
776
    def display_next(self):
728
777
        self.current_view.set_value()
729
 
        if self.context.get('group_by',False):
730
 
            if not self.models.models:
731
 
                self.models.list_group.lst[0].children
732
 
            elif isinstance(self.current_model, group_record):
733
 
                path = self.current_view.store.on_get_path(self.current_model)
734
 
                self.current_view.expand_row(path)
735
 
            elif self.models.models.index(self.current_model) + 1 == len(self.models.models):
736
 
                idx = self.models.list_parent.list_group.lst.index(self.current_model.list_parent)
737
 
                idx = (idx+1) % len(self.models.list_parent.list_group.lst)
738
 
                self.models.list_parent.list_group.lst[idx].children
739
 
        if self.current_model in self.models.models:
740
 
            idx = self.models.models.index(self.current_model)
741
 
            idx = (idx+1) % len(self.models.models)
742
 
            self.current_model = self.models.models[idx]
 
778
        if self.context.get('group_by',False) and \
 
779
                    not self.current_view.view_type == 'form':
 
780
            if self.current_model:
 
781
                self.groupby_next()
743
782
        else:
744
 
            self.current_model = len(self.models.models) and self.models.models[0]
 
783
            if self.current_model in self.models.models:
 
784
                idx = self.models.models.index(self.current_model)
 
785
                idx = (idx+1) % len(self.models.models)
 
786
                self.current_model = self.models.models[idx]
 
787
            else:
 
788
                self.current_model = len(self.models.models) and self.models.models[0]
745
789
        self.check_state()
746
790
        self.current_view.set_cursor()
747
791
 
748
792
    def display_prev(self):
749
793
        self.current_view.set_value()
750
 
        if self.current_model in self.models.models:
751
 
            idx = self.models.models.index(self.current_model)-1
752
 
            if idx<0:
753
 
                idx = len(self.models.models)-1
754
 
            self.current_model = self.models.models[idx]
 
794
        if self.context.get('group_by',False) and \
 
795
                 not self.current_view.view_type == 'form':
 
796
            if self.current_model:
 
797
               self.groupby_prev()
755
798
        else:
756
 
            self.current_model = len(self.models.models) and self.models.models[-1]
 
799
            if self.current_model in self.models.models:
 
800
                idx = self.models.models.index(self.current_model)-1
 
801
                if idx<0:
 
802
                    idx = len(self.models.models)-1
 
803
                self.current_model = self.models.models[idx]
 
804
            else:
 
805
                self.current_model = len(self.models.models) and self.models.models[-1]
757
806
        self.check_state()
758
807
        self.current_view.set_cursor()
759
808