~unifield-team/unifield-wm/sync-UF-1.0-2

« back to all changes in this revision

Viewing changes to sync_client/sync_client.py

  • Committer: jf
  • Date: 2014-10-16 09:10:47 UTC
  • mfrom: (471.1.8 sync)
  • Revision ID: jfb@tempo-consulting.fr-20141016091047-2nhbzb27275hllxj
UF-2437 [IMP] Automatic backups
lp:~unifield-team/unifield-wm/sync-odoo-task-9535

Show diffs side-by-side

added added

removed removed

Lines of Context:
787
787
    """
788
788
    def sync_threaded(self, cr, uid, recover=False, context=None):
789
789
        BackgroundProcess(cr, uid,
790
 
            ('sync_recover' if recover else 'sync'),
 
790
            ('sync_recover_withbackup' if recover else 'sync_withbackup'),
 
791
            context).start()
 
792
        return True
 
793
 
 
794
    def sync_manual_threaded(self, cr, uid, recover=False, context=None):
 
795
        BackgroundProcess(cr, uid,
 
796
            ('sync_manual_recover_withbackup' if recover else 'sync_manual_withbackup'),
791
797
            context).start()
792
798
        return True
793
799
 
804
810
        return True
805
811
 
806
812
    @sync_process()
 
813
    def sync_recover_withbackup(self, cr, uid, context=None):
 
814
        """
 
815
        Call both pull_all_data and recover_message functions - used in manual sync wizard
 
816
        """
 
817
        #Check for a backup before automatic sync
 
818
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'beforeautomaticsync', context=context)
 
819
        self.sync_recover(cr, uid, context=context)
 
820
        #Check for a backup after automatic sync
 
821
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'afterautomaticsync', context=context)
 
822
        return {'type': 'ir.actions.act_window_close'}
 
823
 
 
824
    @sync_process()
 
825
    def sync_manual_recover_withbackup(self, cr, uid, context=None):
 
826
        """
 
827
        Call both pull_all_data and recover_message functions - used in manual sync wizard
 
828
        """
 
829
        #Check for a backup before automatic sync
 
830
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'beforemanualsync', context=context)
 
831
        self.sync_recover(cr, uid, context=context)
 
832
        #Check for a backup after automatic sync
 
833
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'aftermanualsync', context=context)
 
834
        return {'type': 'ir.actions.act_window_close'}
 
835
 
 
836
    @sync_process()
807
837
    def sync(self, cr, uid, context=None):
808
838
        self._logger.info("Start synchronization")
809
839
        self.pull_update(cr, uid, context=context)
813
843
        self._logger.info("Synchronization succesfully done")
814
844
        return True
815
845
 
 
846
    @sync_process()
 
847
    def sync_withbackup(self, cr, uid, context=None):
 
848
        """
 
849
        Call both pull_all_data and recover_message functions - used in manual sync wizard
 
850
        """
 
851
        #Check for a backup before automatic sync
 
852
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'beforeautomaticsync', context=context)
 
853
        self.sync(cr, uid, context=context)
 
854
        #Check for a backup after automatic sync
 
855
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'afterautomaticsync', context=context)
 
856
        return {'type': 'ir.actions.act_window_close'}
 
857
 
 
858
    @sync_process()
 
859
    def sync_manual_withbackup(self, cr, uid, context=None):
 
860
        """
 
861
        Call both pull_all_data and recover_message functions - used in manual sync wizard
 
862
        """
 
863
        #Check for a backup before automatic sync
 
864
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'beforemanualsync', context=context)
 
865
        self.sync(cr, uid, context=context)
 
866
        #Check for a backup after automatic sync
 
867
        self.pool.get('backup.config').exp_dump_for_state(cr, uid, 'aftermanualsync', context=context)
 
868
        return {'type': 'ir.actions.act_window_close'}
 
869
 
816
870
    def get_upgrade_status(self, cr, uid, context=None):
817
871
        return ""
818
872