예제 #1
0
파일: conect.py 프로젝트: hifans/kooltuo
    def item_sync_from_openerp(self, last_sync, _item_type):
        """docstring for contact_sync_from_openerp"""
        print "[openerp][item_sync_from_openerp] Start"
        ret = create_items = mod_items = []
        
        if _item_type == sync_item_type().contacts:
            if last_sync:
                mod_items = self.ooop.ResPartnerAddress.filter(write_date__gt=last_sync, create_date__lt=last_sync)
                create_items = self.ooop.ResPartnerAddress.filter(create_date__gt=last_sync)
            else:
                mod_items = self.ooop.ResPartnerAddress.all()
        elif _item_type == sync_item_type().calendar:
            if last_sync:
                mod_items = self.ooop.CrmMeeting.filter(write_date__gt=last_sync, create_date__lt=last_sync)
                create_items = self.ooop.CrmMeeting.filter(create_date__gt=last_sync)
            else:
                mod_items = self.ooop.CrmMeeting.all()
        elif _item_type == sync_item_type().tasks:
            #We need the modifyed items (all of them) in order to set the sync
            if last_sync:
                mod_items = self.ooop.CrmMeeting.filter(write_date__gt=last_sync, create_date__lt=last_sync)
            else:
                mod_items = self.ooop.CrmMeeting.all()
        
        for i in create_items:
            ret.append([i._ref, i])

        for i in mod_items:
            ret.append([i._ref, i])
            
        print "[openerp][item_sync_from_openerp] End"
        
        return ret
예제 #2
0
 def fix_openerp_data(self, openerp_items, items, item_type):
     """set the new fields in openerp and fix the information in table"""
     new_items = []
     for i in openerp_items:
         found = False
         for j in items:
             if j[fields.address_id] == i[0]:
                 j[fields.openerp_modified] = True
                 j[fields.oContact] = i[1]
                 if item_type == sync_item_type().contacts:
                     j[fields.oItem] = self.out_contacts.get_contact_from_id(j[fields.entry_id])
                 elif item_type == sync_item_type().calendar:
                     j[fields.oItem] = self.out_contacts.get_appointment_from_id(j[fields.entry_id])
                 elif item_type == sync_item_type().tasks:
                     j[fields.oItem] = self.out_contacts.get_task_from_id(j[fields.entry_id])
                 found = True
         if not found:
             #the task option has no a type in openerp there's no creation task erp->outlook
             if item_type <> sync_item_type().tasks:
                 if item_type == sync_item_type().calendar:
                     if not self.openerp.is_task(i[0]):
                         new_items.append([None, i[0], False, True, None, i[1], actions.create_outlook])
                 else:
                     # new record to outlook
                     new_items.append([None, i[0], False, True, None, i[1], actions.create_outlook])
                 
     for i in new_items:
         items.append(i)
         
     return items
예제 #3
0
파일: conect.py 프로젝트: hifans/kooltuo
 def get_item_by_id(self, _id, item_type):
     """Get the contact object by id"""
     if item_type == sync_item_type().contacts:
         return self.ooop.ResPartnerAddress.get(_id)
     elif item_type == sync_item_type().calendar:
         return self.ooop.CrmMeeting.get(_id)
     elif item_type == sync_item_type().tasks:
         return self.ooop.CrmMeeting.get(_id)
예제 #4
0
파일: conect.py 프로젝트: hifans/kooltuo
 def get_unique_items(self, item_type):
     """docstring for fname"""
     if item_type == sync_item_type().contacts:
         return self.ooop.KooltuoUniqueContacts.filter(outlook_application_id=self.oapp_id.name)
     elif item_type == sync_item_type().calendar:
         return self.ooop.KooltuoUniqueAppointmentsTasks.filter(outlook_application_id=self.oapp_id.name, otype="appointments")
     elif item_type == sync_item_type().tasks:
         return self.ooop.KooltuoUniqueAppointmentsTasks.filter(outlook_application_id=self.oapp_id.name, otype="tasks")
예제 #5
0
파일: conect.py 프로젝트: hifans/kooltuo
 def get_item_by_id(self, _id, item_type):
     """Get the contact object by id"""
     if item_type == sync_item_type().contacts:
         return self.ooop.ResPartnerAddress.get(_id)
     elif item_type == sync_item_type().calendar:
         return self.ooop.CrmMeeting.get(_id)
     elif item_type == sync_item_type().tasks:
         return self.ooop.CrmMeeting.get(_id)
예제 #6
0
 def create_item(self, erpItem, item_type):
     """docstring for create_item"""
     item = None
     if item_type == sync_item_type().contacts:
         return self.modify_contact(erpItem, self.outlook.create_item(outlook_types().contact))
     elif item_type == sync_item_type().calendar:
         return self.modify_appointment(erpItem, self.outlook.create_item(outlook_types().appointment))
     elif item_type == sync_item_type().tasks:
         pass
예제 #7
0
파일: conect.py 프로젝트: hifans/kooltuo
def item_type_str(item_type):
    if item_type == sync_item_type().contacts:
        ittype = "contacts"
    elif item_type == sync_item_type().calendar:
        ittype = "appointments"
    elif item_type == sync_item_type().tasks:
        ittype = "tasks"
    
    return ittype
예제 #8
0
 def modify_item(self, erpItem, oItem, item_type):
     """docstring for create_item"""
     item = None
     if item_type == sync_item_type().contacts:
         return self.modify_contact(erpItem, oItem)
     elif item_type == sync_item_type().calendar:
         return self.modify_appointment(erpItem, oItem)
     elif item_type == sync_item_type().tasks:
         return self.modify_task(erpItem, oItem)
예제 #9
0
 def modify_item(self, erpItem, oItem, item_type):
     """docstring for create_item"""
     item = None
     if item_type == sync_item_type().contacts:
         return self.modify_contact(erpItem, oItem)
     elif item_type == sync_item_type().calendar:
         return self.modify_appointment(erpItem, oItem)
     elif item_type == sync_item_type().tasks:
         return self.modify_task(erpItem, oItem)
예제 #10
0
파일: conect.py 프로젝트: hifans/kooltuo
def item_type_str(item_type):
    if item_type == sync_item_type().contacts:
        ittype = "contacts"
    elif item_type == sync_item_type().calendar:
        ittype = "appointments"
    elif item_type == sync_item_type().tasks:
        ittype = "tasks"

    return ittype
예제 #11
0
파일: conect.py 프로젝트: hifans/kooltuo
 def get_unique_items(self, item_type):
     """docstring for fname"""
     if item_type == sync_item_type().contacts:
         return self.ooop.KooltuoUniqueContacts.filter(
             outlook_application_id=self.oapp_id.name)
     elif item_type == sync_item_type().calendar:
         return self.ooop.KooltuoUniqueAppointmentsTasks.filter(
             outlook_application_id=self.oapp_id.name, otype="appointments")
     elif item_type == sync_item_type().tasks:
         return self.ooop.KooltuoUniqueAppointmentsTasks.filter(
             outlook_application_id=self.oapp_id.name, otype="tasks")
예제 #12
0
 def create_item(self, erpItem, item_type):
     """docstring for create_item"""
     item = None
     if item_type == sync_item_type().contacts:
         return self.modify_contact(
             erpItem, self.outlook.create_item(outlook_types().contact))
     elif item_type == sync_item_type().calendar:
         return self.modify_appointment(
             erpItem, self.outlook.create_item(outlook_types().appointment))
     elif item_type == sync_item_type().tasks:
         pass
예제 #13
0
파일: conect.py 프로젝트: hifans/kooltuo
    def modify_item(self, erpItem, oItem, item_type):
        """ Global function to modify diferents types of items """
        if item_type == sync_item_type().contacts:
            self.contact_set_fields(erpItem, oItem)

        elif item_type == sync_item_type().calendar:
            print "modify appointment item"
            self.modify_appointment(erpItem, oItem)

        elif item_type == sync_item_type().tasks:
            print "modify task item"
            self.modify_task(erpItem, oItem)
예제 #14
0
파일: conect.py 프로젝트: hifans/kooltuo
    def modify_item(self, erpItem, oItem, item_type):
        """ Global function to modify diferents types of items """
        if item_type == sync_item_type().contacts:
            self.contact_set_fields(erpItem, oItem)

        elif item_type == sync_item_type().calendar:
            print "modify appointment item"
            self.modify_appointment(erpItem, oItem)

        elif item_type == sync_item_type().tasks:
            print "modify task item"
            self.modify_task(erpItem, oItem)
예제 #15
0
    def sync_all(self):
        """docstring for sync_all"""
        #para usar el outlook como parent
        # window = wx.Window_FromHWND(None, hwnd)
        self.dlg = syncDialog()
        self.dlg.reset()
        self.dlg.max(33)

        self.item_sync(sync_item_type().contacts)
        self.item_sync(sync_item_type().calendar)
        self.item_sync(sync_item_type().tasks)

        self.dlg.close()
        self.dlg = None
예제 #16
0
 def sync_all(self):
     """docstring for sync_all"""
     #para usar el outlook como parent
     # window = wx.Window_FromHWND(None, hwnd)
     self.dlg = syncDialog()
     self.dlg.reset()
     self.dlg.max(33)
     
     self.item_sync(sync_item_type().contacts)
     self.item_sync(sync_item_type().calendar)
     self.item_sync(sync_item_type().tasks)
     
     self.dlg.close()
     self.dlg = None
예제 #17
0
파일: conect.py 프로젝트: hifans/kooltuo
    def create_item(self, oItem, item_type):
        """ Global function to save diferents types of items"""
        if item_type == sync_item_type().contacts:
            self.contact_validate(oItem)

        elif item_type == sync_item_type().calendar:
            print "create appointment item"
            erpItem = self.create_appointment(oItem)
            self.create_unique(oItem, erpItem, item_type)
            print "create appointment item end"

        elif item_type == sync_item_type().tasks:
            print "create task item"
            erpItem = self.create_task(oItem)
            self.create_unique(oItem, erpItem, item_type)
예제 #18
0
파일: conect.py 프로젝트: hifans/kooltuo
    def create_item(self, oItem, item_type):
        """ Global function to save diferents types of items"""
        if item_type == sync_item_type().contacts:
            self.contact_validate(oItem)

        elif item_type == sync_item_type().calendar:
            print "create appointment item"
            erpItem = self.create_appointment(oItem)
            self.create_unique(oItem, erpItem, item_type)
            print "create appointment item end"

        elif item_type == sync_item_type().tasks:
            print "create task item"
            erpItem = self.create_task(oItem)
            self.create_unique(oItem, erpItem, item_type)
예제 #19
0
파일: conect.py 프로젝트: hifans/kooltuo
 def contact_create(self, item, part):
     """docstring for contact_create"""
     print "begin contact_create"
     contact = self.ooop.ResPartnerAddress.new()
     contact.partner_id = part
     contact = self.contact_set_fields(contact, item)
     print "begin unique contact create"
     contact = self.create_unique(item, contact, sync_item_type().contacts)
     print "end contact_create"
예제 #20
0
파일: conect.py 프로젝트: hifans/kooltuo
 def contact_create(self, item, part):
     """docstring for contact_create"""
     print "begin contact_create"
     contact = self.ooop.ResPartnerAddress.new()
     contact.partner_id = part
     contact = self.contact_set_fields(contact, item)
     print "begin unique contact create"
     contact = self.create_unique(item, contact, sync_item_type().contacts)
     print "end contact_create"
예제 #21
0
 def create_sync_table(self, unique_items, item_type):
     """docstring for create_sync_table"""
     items = []
     for i in  unique_items:
         """contact_entry_id, address_id, outlook_modified, openerp_modified, action
             actions (create, modify, conflict)"""
         if item_type == sync_item_type().contacts:
             _id = i.address_id
             _entry_id = i.contact_entry_id
         elif item_type == sync_item_type().calendar:
             _id = i.case_id
             _entry_id = i.appointment_entry_id
         elif item_type == sync_item_type().tasks:
             _id = i.case_id
             _entry_id = i.appointment_entry_id
             
         items.append([_entry_id, _id, False, False, None, 
             self.openerp.get_item_by_id(_id, item_type), actions.none])
             
     return items
예제 #22
0
    def fix_openerp_data(self, openerp_items, items, item_type):
        """set the new fields in openerp and fix the information in table"""
        new_items = []
        for i in openerp_items:
            found = False
            for j in items:
                if j[fields.address_id] == i[0]:
                    j[fields.openerp_modified] = True
                    j[fields.oContact] = i[1]
                    if item_type == sync_item_type().contacts:
                        j[fields.
                          oItem] = self.out_contacts.get_contact_from_id(
                              j[fields.entry_id])
                    elif item_type == sync_item_type().calendar:
                        j[fields.
                          oItem] = self.out_contacts.get_appointment_from_id(
                              j[fields.entry_id])
                    elif item_type == sync_item_type().tasks:
                        j[fields.oItem] = self.out_contacts.get_task_from_id(
                            j[fields.entry_id])
                    found = True
            if not found:
                #the task option has no a type in openerp there's no creation task erp->outlook
                if item_type <> sync_item_type().tasks:
                    if item_type == sync_item_type().calendar:
                        if not self.openerp.is_task(i[0]):
                            new_items.append([
                                None, i[0], False, True, None, i[1],
                                actions.create_outlook
                            ])
                    else:
                        # new record to outlook
                        new_items.append([
                            None, i[0], False, True, None, i[1],
                            actions.create_outlook
                        ])

        for i in new_items:
            items.append(i)

        return items
예제 #23
0
 def search_outlook_item_by_modification_date(self, date, item_type):
     """you can get the list of the contacts modify after a date"""
     print "[outlook_contacts] search by modification date"
     restriction = None
     if date:
         fch = datetime(*time.strptime(date, "%Y-%m-%d %H:%M:%S.%f")[0:6])
         restriction = "[LastModificationTime] >= '%s'" % fch.strftime('%m/%d/%Y %H:%M')
     print "restriction %s" % restriction
     
     if restriction:
         if item_type == sync_item_type().contacts:
             items = self.contact_list().Restrict(restriction)
         elif item_type == sync_item_type().calendar:
             items = self.calendar_list().Restrict(restriction)
         elif item_type == sync_item_type().tasks:
             items = self.task_list().Restrict(restriction)
     else:
         if item_type == sync_item_type().contacts:
             items = self.contact_list()
         elif item_type == sync_item_type().calendar:
             items = self.calendar_list()
         elif item_type == sync_item_type().tasks:
             items = self.task_list()
             
     outlook_items = []
     for i in range(1, len(items) + 1):
         item = items.Item(i) 
         outlook_items.append([item.EntryID,  item])
     
     print "[outlook_contacts] end search by modification date"
     return outlook_items
예제 #24
0
    def search_outlook_item_by_modification_date(self, date, item_type):
        """you can get the list of the contacts modify after a date"""
        print "[outlook_contacts] search by modification date"
        restriction = None
        if date:
            fch = datetime(*time.strptime(date, "%Y-%m-%d %H:%M:%S.%f")[0:6])
            restriction = "[LastModificationTime] >= '%s'" % fch.strftime(
                '%m/%d/%Y %H:%M')
        print "restriction %s" % restriction

        if restriction:
            if item_type == sync_item_type().contacts:
                items = self.contact_list().Restrict(restriction)
            elif item_type == sync_item_type().calendar:
                items = self.calendar_list().Restrict(restriction)
            elif item_type == sync_item_type().tasks:
                items = self.task_list().Restrict(restriction)
        else:
            if item_type == sync_item_type().contacts:
                items = self.contact_list()
            elif item_type == sync_item_type().calendar:
                items = self.calendar_list()
            elif item_type == sync_item_type().tasks:
                items = self.task_list()

        outlook_items = []
        for i in range(1, len(items) + 1):
            item = items.Item(i)
            outlook_items.append([item.EntryID, item])

        print "[outlook_contacts] end search by modification date"
        return outlook_items
예제 #25
0
    def create_sync_table(self, unique_items, item_type):
        """docstring for create_sync_table"""
        items = []
        for i in unique_items:
            """contact_entry_id, address_id, outlook_modified, openerp_modified, action
                actions (create, modify, conflict)"""
            if item_type == sync_item_type().contacts:
                _id = i.address_id
                _entry_id = i.contact_entry_id
            elif item_type == sync_item_type().calendar:
                _id = i.case_id
                _entry_id = i.appointment_entry_id
            elif item_type == sync_item_type().tasks:
                _id = i.case_id
                _entry_id = i.appointment_entry_id

            items.append([
                _entry_id, _id, False, False, None,
                self.openerp.get_item_by_id(_id, item_type), actions.none
            ])

        return items
예제 #26
0
파일: conect.py 프로젝트: hifans/kooltuo
    def item_sync_from_openerp(self, last_sync, _item_type):
        """docstring for contact_sync_from_openerp"""
        print "[openerp][item_sync_from_openerp] Start"
        ret = create_items = mod_items = []

        if _item_type == sync_item_type().contacts:
            if last_sync:
                mod_items = self.ooop.ResPartnerAddress.filter(
                    write_date__gt=last_sync, create_date__lt=last_sync)
                create_items = self.ooop.ResPartnerAddress.filter(
                    create_date__gt=last_sync)
            else:
                mod_items = self.ooop.ResPartnerAddress.all()
        elif _item_type == sync_item_type().calendar:
            if last_sync:
                mod_items = self.ooop.CrmMeeting.filter(
                    write_date__gt=last_sync, create_date__lt=last_sync)
                create_items = self.ooop.CrmMeeting.filter(
                    create_date__gt=last_sync)
            else:
                mod_items = self.ooop.CrmMeeting.all()
        elif _item_type == sync_item_type().tasks:
            #We need the modifyed items (all of them) in order to set the sync
            if last_sync:
                mod_items = self.ooop.CrmMeeting.filter(
                    write_date__gt=last_sync, create_date__lt=last_sync)
            else:
                mod_items = self.ooop.CrmMeeting.all()

        for i in create_items:
            ret.append([i._ref, i])

        for i in mod_items:
            ret.append([i._ref, i])

        print "[openerp][item_sync_from_openerp] End"

        return ret
예제 #27
0
파일: conect.py 프로젝트: hifans/kooltuo
    def create_unique(self, oItem, erpItem, item_type):
        """ Create record data for outlook_unique_XXXXXXX outside """
        unique_item = None
        if item_type == sync_item_type().contacts:
            unique_item = self.ooop.KooltuoUniqueContacts.new()
            unique_item.address_id = erpItem._ref
            unique_item.contact_entry_id = oItem.EntryID
        elif item_type == sync_item_type().calendar:
            unique_item = self.ooop.KooltuoUniqueAppointmentsTasks.new()
            unique_item.case_id = erpItem._ref
            unique_item.appointment_entry_id = oItem.EntryID
            unique_item.otype = 'appointments'
        elif item_type == sync_item_type().tasks:
            unique_item = self.ooop.KooltuoUniqueAppointmentsTasks.new()
            unique_item.case_id = erpItem._ref
            unique_item.otype = 'tasks'
            unique_item.appointment_entry_id = oItem.EntryID

        if unique_item:
            unique_item.outlook_application_id = self.oapp_id
            unique_item.save()
            print unique_item

        return unique_item
예제 #28
0
파일: conect.py 프로젝트: hifans/kooltuo
 def create_unique(self, oItem, erpItem, item_type):
     """ Create record data for outlook_unique_XXXXXXX outside """
     unique_item = None
     if item_type == sync_item_type().contacts:
         unique_item = self.ooop.KooltuoUniqueContacts.new()
         unique_item.address_id = erpItem._ref
         unique_item.contact_entry_id = oItem.EntryID
     elif item_type == sync_item_type().calendar:
         unique_item = self.ooop.KooltuoUniqueAppointmentsTasks.new()
         unique_item.case_id = erpItem._ref
         unique_item.appointment_entry_id = oItem.EntryID
         unique_item.otype = 'appointments'
     elif item_type == sync_item_type().tasks:
         unique_item = self.ooop.KooltuoUniqueAppointmentsTasks.new()
         unique_item.case_id = erpItem._ref
         unique_item.otype = 'tasks'
         unique_item.appointment_entry_id = oItem.EntryID
         
     if unique_item:
         unique_item.outlook_application_id = self.oapp_id
         unique_item.save()
         print unique_item
         
     return unique_item
예제 #29
0
# sync.item_sync(sync_item_type().tasks)
# sync.item_sync(sync_item_type().contacts)

# oc = outlook_contacts()
# tl = oc.contact_list()
#
# print tl
# print type(tl)
# for i in range(1, len(tl) + 1):
#     item = tl.Item(i)
#     print item.ClassName

oc = outlook_contacts()
outlook_items = oc.search_outlook_item_by_modification_date(
    None,
    sync_item_type().contacts)  #, "contacts"
for x in outlook_items:
    x[1].Delete()
outlook_items = oc.search_outlook_item_by_modification_date(
    None,
    sync_item_type().calendar)  #, "contacts"
for x in outlook_items:
    x[1].Delete()
outlook_items = oc.search_outlook_item_by_modification_date(
    None,
    sync_item_type().tasks)  #, "contacts"
for x in outlook_items:
    x[1].Delete()

# sync = syncronize()
# sync.item_sync(sync_item_type().calendar)
예제 #30
0
파일: test.py 프로젝트: hifans/kooltuo
# sync = syncronize()
# sync.item_sync(sync_item_type().calendar)
# sync.item_sync(sync_item_type().tasks)
# sync.item_sync(sync_item_type().contacts)

# oc = outlook_contacts()
# tl = oc.contact_list()
# 
# print tl
# print type(tl)
# for i in range(1, len(tl) + 1):
#     item = tl.Item(i)    
#     print item.ClassName

oc = outlook_contacts()
outlook_items = oc.search_outlook_item_by_modification_date(None, sync_item_type().contacts) #, "contacts"
for x in outlook_items:
    x[1].Delete()
outlook_items = oc.search_outlook_item_by_modification_date(None, sync_item_type().calendar) #, "contacts"
for x in outlook_items:
    x[1].Delete()
outlook_items = oc.search_outlook_item_by_modification_date(None, sync_item_type().tasks) #, "contacts"
for x in outlook_items:
    x[1].Delete()


# sync = syncronize()
# sync.item_sync(sync_item_type().calendar)


#test manual