콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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

아바타
취소

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

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

작성자

@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 ;)

작성자

@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

베스트 답변

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


아바타
취소
작성자

thanks prasanth for your help.....

관련 게시물 답글 화면 활동
1
10월 16
13458
0
1월 21
2860
1
7월 24
1223
3
6월 23
12947
3
6월 20
4103