Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Importing Document file into project .

By
Logicious
on 10/5/15, 7:32 AM 698 views

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...

pks
on 10/7/15, 12:40 AM

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

Drees Far
on 10/8/15, 8:26 AM

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

Logicious
on 10/8/15, 9:05 AM

Thanks a lot friend happy for hearing this ;)

Drees Far
on 10/8/15, 9:34 AM

@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

Logicious
on 10/9/15, 2:21 AM
1
pks
On 10/9/15, 7:53 AM

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.....

Logicious
on 10/9/15, 7:55 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/5/15, 7:32 AM
Seen: 698 times
Last updated: 10/9/15, 7:54 AM