콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
12014 화면

Hello. I am trying to inherit res.partner into a new model, adding a field as suggested in "Creating a model" tutorial. I suppose that a line from the code must be changed to make it work, avoiding the "instructor field does no exist" error: 

instructor = fields.Boolean("Instructor", default=False) 

must be changed for 

_column = {'instructor': fields.Boolean("Instructor", default=False)}

according with a help forum in Odoo. The code for partner.py which does not provoke errors is this:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class Partner(models.Model):
_inherit = 'res.partner'
# Add a new column to the res.partner model, by default partners are not
# instructors
# instructor = fields.Boolean("Instructor", default=False)
_column = {'instructor': fields.Boolean("Instructor", default=False)}
session_ids = fields.Many2many('openacademy.session',
string="Sesiones Atendidas", readonly=True)

However, when enabling partner.xml to module the error appears again:

ParseError: "Invalid view definition
Error details:
Field `instructor` does not exist
Error context:
View `partner.instructor`

It's code is next:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Add instructor field to existing view -->
<record model="ir.ui.view" id="partner_instructor_form_view">
<field name="name">partner.instructor</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Sesiones">
<group>
<field name="instructor"/>
<field name="session_ids"/>
</group>
</page>
</notebook>
</field>
</record>
<record model="ir.actions.act_window" id="contact_list_action">
<field name="name">Contacts</field>
<field name="res_model">res.partner</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="configuration_menu" name="Configuration"
parent="main_openacademy_menu"/>
<menuitem id="contact_menu" name="Contacts"
parent="configuration_menu"
action="contact_list_action"/>
</data>
</openerp>

I guess that reference to 'instructor' field in view should be changed somehow to make it clear it does not belong to parent model, but to inherited one. 

Any help would be appreciated. Thanks in advance.




아바타
취소
작성자 베스트 답변

Thanks, Pawan. I both updated the module and restarted the server. Unfortunately, error appears the same.

Thank for your reply, Akhil. That is the first code I tried. I just returned it according to the way you suggested, and it did not work. I had previously set up two VMs for my tests. I was working in Odoo version 8. After restarting server, along with error at web browser, the log file shows this:

ProgrammingError: column res_partner.instructor does not exist
LINE 1: ...artner"."credit_limit","res_partner"."country_id","res_partn...
^

However, I did the same in Odoo 9, and it is working fine (!). This somewhat baffling to me, since I had previously tried with that code with no success.

Do you know if Odoo version, 8 or 9, this has something to do with this?

Best regards to both of you.

아바타
취소
베스트 답변

Raul,

Try restarting server by upgrading your module(and Db also if you are having multiple DB's)...

Hope it helps!

아바타
취소
베스트 답변

Hi,

You can do the coding either in new api or old api. But here, you are missing them in field definition part which is not in the proper way.

Try like this:

from openerp import models, fields, api
class Partner(models.Model):
    _inherit = 'res.partner'

    instructor = fields.Boolean("Instructor", default=False)
session_ids = fields.Many2many('openacademy.session',string="Sesiones Atendidas", readonly=True)

The tutorial is according to the new api. So please follow like that, because the inheriting classes and libraries are different for them. 

There is nothing wrong with your view definition.

Make sure that you have imported this py file in __init__.py and also added the view file in __openerp__.py

Restart the server n try.

Hope this helps!

아바타
취소
관련 게시물 답글 화면 활동
2
2월 19
4226
2
6월 16
6095
2
11월 23
3689
3
12월 22
7542
3
11월 22
7568