Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
7 Risposte
7130 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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.

Risposta migliore

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
Abbandona
Autore

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

Autore

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

Post correlati Risposte Visualizzazioni Attività
1
mag 23
2557
2
mag 15
6643
3
mar 15
9714
3
gen 22
53245
5
feb 18
8572