This question has been flagged
1 Reply
3713 Views

I am a newbie to Odoo and everything about it. I have odoo12 installed on centOs.I installed the openeducat_core module and I am trying to make changes to it by extending a model and view. I want to make the fields required to create a student optional; birthdate and email field. I have written some code for it, but it does not seem to work.

this is my folder structure ;

-models/

-admission_details_extension.py

-student_details_edits.py

-__init__.py

-views

-student_details_edits.xml

 __manifest__.py 

__init__.py

Here is a copy of my code.

models/admission_details_extension.py

from odoo import models, fields
#Inherit op.admission model 

class OpAdmission(models.Model):

      _inherit = 'op.admission'      

birth_date = fields.Date('Birth Date',required=False, states={'done': [('readonly', True)]})      

email = fields.Char('Email',size=256, required=False, states={'done': [('readonly', True)]})

#redefine{modify}the two fields in that model.


models/student_details_edits.py

from odoo import models, fields
# Inherite op.faculty model

class OpFaculty(models.Model):

 _inherit = 'op.faculty'

 birth_date = fields.Date('Birth Date', required=False)

views/student_details_edits.xml

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<data>

<record model="ir.ui.view" id="view_op_student_form_inherited">

<field name="name">op.student.form.inherited</field>

<field name="model">op.student</field>            

<!-- reference the parent or original form id of model named -->            

<field name="inherit_id" ref="openeducat_core.view_op_student_form"/>            

<field name="priority" eval="8"/>            

<field name="arch" type="xml">                

<form string="Student">                    

<xpath expr="//field[@name='birth_date']" position="attribute" >                        

<attribute name="required">0</attribute>                    

</xpath>                    

<xpath expr="//field[@name='email']" position="attribute">                        

<attribute name="required">0</attribute>                    

</xpath>                

</form>            

</field>        

</record>    

</data>

</odoo>

__manifest__.py

{'category': 'Student details',

'version': '12.0.1',

'depends': ['board','document','hr','openeducat_core, openeducat_admission'],

'data': ['views/student_details_edits.xml'],

'installable': True,

'auto_install': False,

'application':False,

}



Avatar
Discard
Author

Oh my bad.typo. It is actually __manifest__.py on the source code.

Author

I have gone through the link and done the necessary changes. The module installs but does not do what I want it to do.ie change the field attribute to required= false

Best Answer

Hi,

It seems that you have named the manifest file as the manage.py . Rename the __manage__.py to __manifest__.py . Also cant see the __init__.py file in your module which loads the python files.

Please have a look at this documentation and see how to create a custom module in odoo:  How to Create a Module in Odoo


Thanks

Avatar
Discard