コンテンツへスキップ
メニュー
この質問にフラグが付けられました
7 返信
7126 ビュー

Trying to inherit model note.note in my form view but keep getting the error Field "alias_model" does not exist. I also inherit note.note in my models and my fields are added just fine.

Here is my view:

<record id="view_project_notes_form" model="ir.ui.view">
    <field name="name">Project Notes Form View</field>
    <field name="model">note.note</field>
    <field name="inherit_id" ref="project.edit_project"/>
    <field name="arch" type="xml">
        <data>
            <xpath expr="//notebook/page[1]" position="after">
                <page string="Notes"> <field name="title" placeholer="Title"/>
                    <field name="tag_ids"/>
                    <field name="memo"/>
                </page>
            </xpath>
        </data>
    </field>
</record>

and my model:

from openerp import models, fields, api
class Notes(models.Model):
    _inherit = "note.note"
    title = fields.Char(string="Title")
    employee = fields.Many2many(string="Employee")
    modified_by = fields.Many2many(string="Modified By")

Any help is appreciated!

アバター
破棄
著作者 最善の回答

You can't reference one object's view with another object's model. So to expand the project.edit_project view, you have to reference model project.project. I still haven't figured out how to use note.note fields in the view. I've posted another question after trying to solve this problem: 

http://stackoverflow.com/questions/42566652/how-do-i-add-multiple-models-to-one-view

アバター
破棄
最善の回答

Hi Lindsay,

As I can see at you model, I found that the field employee and modified by has not been defined correctly.That is not the correct way to define the Many2many field.

 

アバター
破棄
著作者

Hi Raaj,

Thank you for the comment. I've already added comodels to the fields. However, my issue does not have to do with this. It doesn't even get this far in the code. Read above comment.

最善の回答

Hi..

 Use this format to define a Many2many field.

Example :-

user_rel_ids = fields.Many2many(comodel_name='course',  relation='user_course_rel',  column1='user_id',                column2='course_id')
アバター
破棄
著作者

Hi Aslam,

Thanks for the example. I did end up adding 'hr.employee' as a comodel, but that's irrelevant to the issue that I'm having. It's not liking the 'note.note' in '<field name = model>' . It DOES work fine for me when I change inherit ID to 'note.some_view.' So I think it has to do with the project inheritance. I still need to use it thins way, and need to figure out how to get it to work

Hi Lindsay,

You cannot use view ref="project.edit_project" in model 'note.note' as it was defined using the model 'project.project'. So once you need to inherit view ref="project.edit_project" you must use model name 'project.project' !!!!

著作者

Yes, I've actually worked that out already. I still need to figure out HOW to do it though. I need to be able to reference note.note fields in project.edit_project. I've created a model that inherits both note.note and project.project and use that for my model now. I don't get any error but My fields aren't displayed. See my new question I posted please. http://stackoverflow.com/questions/42566652/how-do-i-add-multiple-models-to-one-view

関連投稿 返信 ビュー 活動
1
5月 23
2555
2
5月 15
6643
3
3月 15
9713
3
1月 22
53243
5
2月 18
8571