Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
7 Trả lời
7123 Lượt xem

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!

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

 

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Câu trả lời hay nhất

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')
Ảnh đại diện
Huỷ bỏ
Tác giả

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' !!!!

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 23
2555
2
thg 5 15
6643
3
thg 3 15
9713
3
thg 1 22
53243
5
thg 2 18
8571