Odoo Aide

0

0
1 Answer
0
Samo Arko
14/05/2019 04:55

Damn I wasted 1 hour googling for a error that I made in the code. The problem was in the if clause, because I tried pass project_id from a record that had no project_id.  I was checking if the partner_id record existed and not the project_id! 

Fixed:

    def transfer_project_id(self):
        all_pvz_data = self.env['pvz.hours'].sudo().search([])
        for data in all_pvz_data:
            if data.project_id:
                if len(data.project_ids.ids) > 0:
                    continue
                try:
                    data.project_ids = [(6, 0, [data.project_id.id])]
                except Exception as e:
                    raise ValidationError(u'ERROR on project id transfer! \n{}'.format(e))
Poser une question
Writer
Étiquettes
Keep Informed
1 Abonné(e)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