0
votes

I am building a simple module in Odoo 8.

I have two models (semester_no and scheme) and I want to have One2many relation from scheme to semester_no. The relation is giving me an error and I don't know the reason.*

I am using the same relation from semester_no to another model subject with the same pattern exactly and following the same steps and it's working, but in this models it isn't!

XmlHttpRequestError INTERNAL SERVER ERROR 500 Internal Server Error

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

the problem is caused when uncommenting the commented lines

This error has appeared previously with other models and suddenly disappeared without changing anything, even the relation from semester_no and subject wasn't working then suddenly it does.

I tried the same module in another machine and same error is there

class semester_no(models.Model):
    _name = 'uet.semester_no'

    name = fields.Char(string="Semester No.")

    subjects = fields.One2many(comodel_name='uet.subject', inverse_name='semester', string="Subjects")
    #scheme = fields.Many2one(comodel_name='uet.scheme')


class scheme(models.Model):
    _name = 'uet.scheme'

    name = fields.Char(string="Name")

    #semester = fields.One2many(comodel_name='uet.semester_no', inverse_name='scheme', string="Semesters")


class subject(models.Model):
    _name = 'uet.subject'

    subject_name = fields.Char(string="Name", required=True)
    subject_code_prefix = fields.Char(string="Code Prefix")
    subject_code = fields.Integer(string="Code")
    subject_type = fields.Char(string="Type", required=True)
    subject_level = fields.Char(string="Level")
    credit_hours = fields.Integer(string = "No. of Credit Hours", required = True)
    contact_hours = fields.Integer(string="No. of Contact Hours", required = True)
    pre_requisites = fields.Char(string="Pre-Requisites")
    co_requisites = fields.Char(string="Co-Requisites")

    semester = fields.Many2one(comodel_name="uet.semester_no", string="Semester")
    program = fields.Many2one(comodel_name='uet.program', string="Program")
    department = fields.Many2one(comodel_name='uet.department', string="Department")
2
Can you please check error in log file and paste it here ?Emipro Technologies Pvt. Ltd.
if you mean /server/openerp-server.log then this is the last lines " File "C:\Program Files (x86)\Odoo 8.0-20150622\server\openerp\addons\UET\models.py", line 58 scheme = fields.Many2one(comodel_name='uet.scheme') ^ IndentationError: unindent does not match any outer indentation level " I am sure it's 4 space indentation and I even did it manually without tab!!! I tried deleting the indentation entirely but I get another error from view file " Error details: Field scheme does not exist " @emiprotechnologiespvt.ltdAmjad992

2 Answers

0
votes

You should try following,

class semester_no(models.Model):
    _name = 'uet.semester_no'

    name = fields.Char(string="Semester No.")

    subjects = fields.One2many(comodel_name='uet.subject', inverse_name='semester', string="Subjects")
    scheme = fields.Many2one('uet.scheme','Scheme')


class scheme(models.Model):
    _name = 'uet.scheme'

    name = fields.Char(string="Name")

    semester = fields.One2many(comodel_name='uet.semester_no', inverse_name='scheme', string="Semesters")

You need to restart service and update your module.

0
votes

I did restarted the service and updated the module but nothing worked.

but now it's solved as it was indentation error and 4 manual spaces didn't work as well as tab. I had a workaround as I looked for 2 correctly indented fields and copied the space from the bracket of the first one with bracket up-to the beginning of the next field the then replaced that in place of previous space. This solved the problem for me, It's a strange issue and I have no explanation for it. Thank you for your help as knowing the log file now really helps me in debugging any errors