Odoo Help


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

Pascal Tremblay
on 1/7/15, 7:34 AM 1,548 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?


About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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