This question has been flagged

Hello,

Anybody have idea about how to do importing large amount of documents  as attachment files into  projects? Actually there are lots of projects , if we are get into project there are documents , issues,tasks... etc... i want to add my large amount of csv file into this documents. i can able to import form here its self, when i import from here all the documents should be in that projects itself. It is easy to do for specific one at a time. In my csv file has different project ids and each projects ids have lots of data, how could i do it?

thanking you

Logicious

Avatar
Discard

actually you need to write python script for that...

friend did you find a solution really i need the same thing like you

Author

@Drees Far: Friend i find the solution how to solve that, i am doing based up that.I will updated it on tomorrow morning.

Thanks a lot friend happy for hearing this ;)

Author

@Drees Far: i didn't complete that yet..still am i am trying... if you want my code i will send by mail.. mail me on this prasanth.logicious@gmail.com

Best Answer

1. create a wizard

2 add this function  into that button

def get_document(self, cr, uid, ids, context=None):

matter_obj = self.pool.get('project.project')

attach_obj=self.pool.get('ir.attachment')

path = '/home/logicious/Downloads/document/demo_document.csv'

files = glob.glob(path)

for file in files:

f=open(file, 'r')

for m in f.readlines():

print '%s' % m

get_lst=m.split(',')

if len(get_lst)>=4:

print'-------',get_lst[1]

print'#########',get_lst[4]

d = get_lst[4]

print 'dddddddddddddddd',d

search_ids= matter_obj.search(cr,uid,[('name','=',get_lst[1])])

print'%%%%%%%%%',len(search_ids)

if len(search_ids):

matter_data = matter_obj.browse(cr,uid,search_ids[0])

if get_lst[4]!=False:

print']]]]]]]',"/home/logicious/Downloads/document/files"+get_lst[4]

if get_lst[4].find('.')!=-1:

ext=get_lst[4].split('.')[1]

file_name=get_lst[4].split('.')[0]+ext.lower()

if os.path.exists("/home/logicious/Downloads/document/files/"+file_name):

print'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'

m = open('/home/logicious/Downloads/document/files/'+file_name,'rb')

attach_vals = {

'name': str(get_lst[4]),

'datas': base64.b64encode(m.read()),

'description': 'files',

'res_name': matter_data.name,

'res_model': 'project.project',

'res_id': matter_data.id,

}

attach_id = attach_obj.create(cr, uid, attach_vals)

f.close()

return 'True'


thanks

prasanth


Avatar
Discard
Author

thanks prasanth for your help.....