diff options
| author | Naresh Choksy <nch@tinyerp.com> | 2008-10-07 10:54:01 +0530 |
|---|---|---|
| committer | Naresh Choksy <nch@tinyerp.com> | 2008-10-07 10:54:01 +0530 |
| commit | 7db9b82e79ac0e226a2bafc51942c8f4d31a872d (patch) | |
| tree | 1f21e0ab84700cc756f8f809d117ab0b390940d2 /addons/document/document.py | |
| parent | 33c2901c0d79e5bd88515103558386729d51ec62 (diff) | |
Created a configuration wizard that explains you can connect on the server, port 8021.
This configuration wizard configures a structure by default, according to the modules installed:
Sales / All Sales Order -> Connected to Sales order if module sale is installed
-> + virtual file _print.pdf in directories that prints sales orders
Sales by Salesman is sale is installed
-> Level 1 is res.users
-> Level 2 is sales order related to this active_id user
Projects -> Connected to account.analytic.account if module account is installed with tree structure
-> + Quotations, Meetings, Analisys Reports subdirs in each project,Personal Folders -> Connected to Users
bzr revid: nch@tinyerp.com-20081007052401-3gf3nmdhrgxdqea3
Diffstat (limited to 'addons/document/document.py')
| -rw-r--r-- | addons/document/document.py | 108 |
1 files changed, 100 insertions, 8 deletions
diff --git a/addons/document/document.py b/addons/document/document.py index d312b33f366..deb830a6d7c 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -232,20 +232,20 @@ class document_directory(osv.osv): path=[] def _parent(dir_id,path): parent=self.browse(cr,uid,dir_id) - if parent.parent_id and not parent.ressource_parent_type_id: + if parent.parent_id and not parent.ressource_parent_type_id: _parent(parent.parent_id.id,path) path.append(parent.name) - else: - path.append(parent.name) + else: + path.append(parent.name) return path - directory=self.browse(cr,uid,dir_id) - model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) + directory=self.browse(cr,uid,dir_id) + model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) if directory: - _parent(dir_id,path) + _parent(dir_id,path) path.append(self.pool.get(directory.ressource_type_id.model).browse(cr,uid,res_id).name) user=self.pool.get('res.users').browse(cr,uid,uid) - #print "ftp://%s:%s@localhost:8021/%s/%s"%(user.login,user.password,cr.dbname,'/'.join(path)) + #print "ftp://%s:%s@localhost:8021/%s/%s"%(user.login,user.password,cr.dbname,'/'.join(path)) return "ftp://%s:%s@localhost:8021/%s/%s"%(user.login,user.password,cr.dbname,'/'.join(path)) return False def _check_duplication(self, cr, uid,vals): @@ -595,4 +595,96 @@ class document_file(osv.osv): except: pass return super(document_file, self).unlink(cr, uid, ids, context) -document_file() +document_file() + +class auto_configuration(osv.osv_memory): + _name='auto.configuration' + _rec_name = 'Auto Directory configuration' + _columns = { + } + def action_cancel(self,cr,uid,ids,conect=None): + return { + 'view_type': 'form', + "view_mode": 'form', + 'res_model': 'ir.actions.configuration.wizard', + 'type': 'ir.actions.act_window', + 'target':'new', + } + + def action_config(self, cr, uid, ids, context=None): + obj=self.pool.get('document.directory') + search_ids=obj.search(cr,uid,[]) + browse_lst=obj.browse(cr,uid,search_ids) + model_obj=self.pool.get('ir.model') + + for doc_obj in browse_lst: + if doc_obj.name in ('Partner','Contacts','Personnal Folders','Partner Category','Sales Order','All Sales Order','Sales by Salesman','Projects'): + res={} + id=[] + if doc_obj.name=='Partner': + id=model_obj.search(cr,uid,[('model','=','res.partner')]) + + if doc_obj.name=='Contacts': + id=model_obj.search(cr,uid,[('model','=','res.partner.address')]) + + if doc_obj.name=='Partner Category': + id=model_obj.search(cr,uid,[('model','=','res.partner.category')]) + + if doc_obj.name=='All Sales Order': + val={} + id=model_obj.search(cr,uid,[('model','=','sale.order')]) + if not len(doc_obj.content_ids): + val['name']='Sale Report' + val['suffix']='_report' + val['report_id']=self.pool.get('ir.actions.report.xml').search(cr,uid,[('report_name','=','sale.order')])[0] + val['extension']='.pdf' + val['directory_id']=doc_obj.id + self.pool.get('document.directory.content').create(cr,uid,val) + + if doc_obj.name=='Sales by Salesman': + id=model_obj.search(cr,uid,[('model','=','res.users')]) + + if doc_obj.name=='Personnal Folders': + id=model_obj.search(cr,uid,[('model','=','res.users')]) + + if doc_obj.name=='Projects': + id=model_obj.search(cr,uid,[('model','=','account.analytic.account')]) + res['ressource_tree']=True + + if id: + res['ressource_type_id']=id[0] + res['type']='ressource' + obj.write(cr,uid,doc_obj.id,res) + self.create_folder(cr, uid, ids, context=None) + return { + 'view_type': 'form', + "view_mode": 'form', + 'res_model': 'ir.actions.configuration.wizard', + 'type': 'ir.actions.act_window', + 'target':'new', + } + + def create_folder(self, cr, uid, ids, context=None): + doc_obj=self.pool.get('document.directory') + model_obj=self.pool.get('ir.model') + for name in ('Sales','Quotation','Meetings','Analysis Reports'): + res={} + if name=='Sales': + child_model=model_obj.search(cr,uid,[('model','=','sale.order')]) + link_model=model_obj.search(cr,uid,[('model','=','res.users')]) + if child_model: + res['type']='ressource' + res['ressource_type_id']=child_model[0] + res['ressource_parent_type_id']=link_model[0] + res['domain']="[('user_id','=',active_id)]" + else: + link_model=model_obj.search(cr,uid,[('model','=','account.analytic.account')]) + if link_model: + res['ressource_parent_type_id']=link_model[0] + res['ressource_id']=0 + if res: + res['name']=name + doc_obj.create(cr,uid,res) + return True + +auto_configuration()
\ No newline at end of file |
