Odoo Help

0

0
2 Answers
1
Avatar

Ibrahim

--Ibrahim--
2807
| 6 3 7
Casablanca, 摩洛哥
--Ibrahim--


Ibrahim
2019/1/3 上午9:29

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
2019/1/3 上午10:03

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
2019/1/3 上午11:22

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

Paul
2019/1/3 下午8:54

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 eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now