How do I add multiple models to one view?

2019-09-13 23:34发布

I'm trying to use three different models in one view. I've created a new model that inherits the models which seems to work fine.

from openerp import models, fields, api

class ProjectNote(models.Model):
    _name = "triangle.project.note"
    _inherit = ["note.note", "project.project", "triangle.note"]

My problem is in the view. I use my new model as the model and inherit a view from project.

<record id="view_project_notes_form" model="ir.ui.view">
      <field name="name">triangle.project.note.form</field>
      <field name="model">triangle.project.note</field>
      <field name="inherit_id" ref="project.edit_project"/>
      <field name="arch" type="xml">
        <data>
          <xpath expr="//field[@name='privacy_visibility']" position="replace">
            <h2>
              <field name="title" placeholder="Title"/>
            </h2>
          </xpath>
        </data>
      </field>
    </record>

I don't get any errors but my field is not being added.

Any help is appreciated!

1条回答
贼婆χ
2楼-- · 2019-09-14 00:19

If you're trying to open a project.project view and wondering why there is no field title in it: there can't be. You aren't extending the project view for model project.project but are defining a form view for your model triangle.project.note which inherits the project view.

So the project views are untouched, you've just created the first form view for your new model.

查看更多
登录 后发表回答