Odoo Help


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.


How to get actual attachment id in ir.attachment override?

Pascal Tremblay
on 1/7/15, 7:34 AM 915 views

I have an override of the class ../openerp/addons/base/ir/ir_attachment.py.

I need the id value of the instance in my method overrided _get_path().

My override file contents :

from openerp.osv import osv
import logging
_logger = logging.getLogger(__name__)

class PT_ir_attachment(osv.osv):
    _inherit = 'ir.attachment'
    _name = 'ir.attachment'

    def _get_path(self, cr, uid, bin_data):
        fmonth = "avril-2015"
        fname = 'osot.png'
        fpath = 'dsd'
        test = self._full_path(cr, uid, fname)
        context = {}

       ids = ???? (how could I get instance ID here)

        for attach in self.browse(cr, uid, ids, context=context):
            if attach.store_fname:
                result[attach.id] = self._file_read(cr, uid, attach.store_fname, bin_size)
                result[attach.id] = attach.db_datas

        return fname, fpath


Somebody could help please?


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)


Asked: 1/7/15, 7:34 AM
Seen: 915 times
Last updated: 3/16/15, 8:10 AM