Odoo Help

Welcome!

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.

0

[V8] How to pass res_id to the attachment object?

By
Wilbert Tan
on 3/7/16, 11:22 PM 297 views

Dear guys,

I have this field on my incident.report object that will become the input place for user to upload some attachment

attachments = fields.Many2many('ir.attachment', string="Attachments"

Question is how to pass the incident id to the res_id field in ir.attachment? I need this res_id for other purposes

I tried to extend the ir.attachment object and print the vals['res_id], it returns 0 instead

class document_file(Model):_inherit = 'ir.attachment'    def create(self, cr, uid, vals, context=None):
    print 'RES ID on create: ', vals['res_id'] #should return the incident id not 0
    return super(document_file, self).create(cr, uid, vals, context) 

But everytime I use the default Attachment(s) menu from the tree view, it always pass the res_id correctly. Why this happens?

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)

Stats

Asked: 3/7/16, 11:22 PM
Seen: 297 times
Last updated: 3/8/16, 12:52 AM