Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
7 Odpowiedzi
7145 Widoki

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!

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

 

Awatar
Odrzuć
Autor

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.

Najlepsza odpowiedź

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')
Awatar
Odrzuć
Autor

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

Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
1
maj 23
2557
2
maj 15
6645
3
mar 15
9717
3
sty 22
53263
5
lut 18
8600