Odoo Help

0
2 Answers
1
Ibrahim
1/3/19, 9:29 AM

Hi, 

@api.multi
def _compute_attachment_count(self):
        Attachment = self.env['ir.attachment']
        for record in self:
            record.attachment_count = Attachment.search_count([('res_model', '=', self._name), ('res_id', '=', record.id)])

Upvote if this helps.

Thanks.


0
Paul
1/3/19, 10:03 AM

thank you ibrahim, it does not work properly. I don't understand why it happened like that.

The problem becomes more complex than I think. when create does not manually res_model and res_id, so it cannot be counted.

2 Comments
Ibrahim
1/3/19, 11:22 AM

does my answer work properly for you ? or is there a problem with it ?

Paul
1/3/19, 8:54 PM

nó không hoạt động trong khi create or import. tôi không biết nó ra lỗi gì mà không oạt động

Ask a Question
Writer
Keep Informed
1 follower(s)
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.

Register
Odoo Training Center

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

Test it now