Odoo Help

0
5 Answers
1
Samo Arko
5/14/18, 3:44 AM

use api.constrains

@api.constrains('default_selected_student')
def _change_student_status(self):
    if self.default_selected_student:
        students = self.env['<_name>'].search([('id', '!=', self.id)])
        for student in students:
            student.default_selected_student = False

Ok... I think that you could do the the for with a single write, but don't know the exactly how to do it off my head.

Replace the <_name> with your models value for _name.  



1 Comment
Tabla d.o.o., Samo Arko
5/14/18, 3:45 AM

you could probably use api.depends

0
vickybp1130@gmail.com
12/6/18, 7:27 AM

for me its not working i am getting error plz solve this error brother


class AcademicYear (models.Model):
        _name = 'edudibonmaster.academicyear'
        _rec_name = 'academicyear'
        _description = 'Academic Year'

        academicyear = fields.Char(string="Academic Year", size = 9, required = True)
        startdate = fields.Date(string="Start Date", required = True)
        enddate = fields.Date(string="End Date", required = True)
        current = fields.Boolean(string = "Active", required = True)

        # constraints unique value


        @api.constrains('current')
        def _change_academic_year(self):
                if self.current:
                        years = self.env['edudibonmaster.academicyear'].search([('id', '!=', self.id)])
                        for year in years:
                                year.current = False

Error :

  File "/opt/odoo/odoo/odoo/service/model.py", line 141, in wrapper
    raise ValidationError(inst[0])
TypeError: 'IntegrityError' object does not support indexing


14 Comments
ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:38 AM

can you send me where the problem is?

ai
12/10/18, 4:39 AM

can you send me where the problem is?

vickybp1130@gmail.com
12/10/18, 4:43 AM

ok i will send my module

vickybp1130@gmail.com
12/10/18, 4:45 AM

hi can u help me

ai
12/18/18, 1:49 AM

try to use @api.multi

ai
12/18/18, 1:52 AM

I mean @api.onchange('current')

0
ai
5/16/18, 3:39 AM

it works. thanks a lot.

1 Comment
Tabla d.o.o., Samo Arko
5/17/18, 2:08 AM

no problem... than you could like it or select it as the correct answer :)

Ask a Question
Writer
16
ai
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