Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
8348 Vizualizări

I am implementing the Knowledge Management module in odoo v8 and I have come across a major short coming.The directory field in the attachments is not automatically set by the system even if I configure the "Folders per resource" part in Knowledge.

For example, I have a Clients folder whose parent folder is documents. This folder is set as "Folders per resource" for the partner model. Now, if I attach an attachment on a customer, it is not being placed in the clients folder by default.

Does anyone know how to make attachments in odoo to go to a specific directory by default so I don't have to manually set the directory field in the attachment form. I feel this is a vital feature in as documents organisation is concerned. 

(Please upvote the question so that I can be able to comment)

Imagine profil
Abandonează
Autor Cel mai bun răspuns

I found some great explanation here https://www.odoo.com/forum/help-1/question/where-are-document-attachments-stored-529 (Antony Lesuisse's answer) on how to set odoo to save the attachments in the file system.

I then used the following piece of code to set a default for 'parent_id' field in the attachment. (ir.attachment class)

from openerp.osv import osv, fields
from openerp.tools.translate import _
class ir_attachment(osv.osv):
    #extend document
    _inherit = "ir.attachment"
    def create(self, cr, uid, vals, context=None):
        if context is None:
            context = {}
        if not vals.get('res_model', False) and context.get('default_res_model', False):
            vals.get['res_model'] = context.get('default_res_model', False)        
        if not vals.get('parent_id', False):
            parent_id = self.pool.get('document.directory').search(cr, uid, [('ressource_type_id','=',vals.get('res_model'))])
            if parent_id and parent_id[0]:
               vals['parent_id'] = parent_id[0]
            else:
                vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context)
        
        return super(ir_attachment, self).create(cr, uid, vals, context)
ir_attachment()
class document_directory(osv.osv):
    _inherit = 'document.directory'
    _sql_constraints = [
        ('dir_uniq', 'unique (ressource_id,ressource_parent_type_id)',
         'The Directory name must be unique per Resource Type and Resource !'),
    ]
This atleast did what I needed.
Imagine profil
Abandonează
Cel mai bun răspuns

Hello Cyrus,

The functionality "Folders by resource" only works in relation to module "document_ftp". That is, when you access to your repository using FTP, the application dynamically constructs one folder per resource (e.g. one folder for each sales order), based on the flag that you set to the 'Customers' folder in Odoo. These are not physical but 'virtual' folders.

What you ask for is interesting, but would require a specific development, so that each object in Odoo would create it's own physical folder per resource.


Regards,

Jordi.



 




Imagine profil
Abandonează
Autor

Unfortunately, document_ftp has not been ported to odoo v8. Please see how I achieved what I wanted in my answer below

Related Posts Răspunsuri Vizualizări Activitate
3
iun. 23
12669
1
iun. 16
5571
0
dec. 23
6902
2
apr. 19
10684
0
aug. 24
4662