Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
7 Odpovědi
7129 Zobrazení

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!

Avatar
Zrušit
Autor Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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.

 

Avatar
Zrušit
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.

Nejlepší odpověď

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')
Avatar
Zrušit
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

Related Posts Odpovědi Zobrazení Aktivita
1
kvě 23
2557
2
kvě 15
6643
3
bře 15
9714
3
led 22
53245
5
úno 18
8572