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
This commit is contained in:
parent
33c2901c0d
commit
7db9b82e79
|
@ -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()
|
|
@ -198,6 +198,44 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_auto_config_form" model="ir.ui.view">
|
||||
<field name="name">Auto Configure Directory</field>
|
||||
<field name="model">auto.configuration</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Auto Configure">
|
||||
<label string="" colspan="2"/>
|
||||
<newline/>
|
||||
<label string="Do you want to configure Directory Automatically ?" colspan="2"/>
|
||||
<newline/>
|
||||
<newline/>
|
||||
<group col="4" colspan="2">
|
||||
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
|
||||
<button name="action_config" string="Configure" icon='gtk-ok' type="object"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<label string="You Can use ftp://admin:admin@localhost:8021 " colspan="2"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_config_auto_directory" model="ir.actions.act_window">
|
||||
<field name="name">Auto Configure Directory</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">auto.configuration</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.todo"
|
||||
id="config_auto_directory">
|
||||
<field name="name">Auto Configure Directory</field>
|
||||
<field name="action_id" ref="action_config_auto_directory"/>
|
||||
<field name="state">open</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
||||
|
|
Loading…
Reference in New Issue