How do I add multiple models to one view?

萝らか妹 提交于 2019-12-13 07:02:26

问题


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:


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.



来源:https://stackoverflow.com/questions/42566652/how-do-i-add-multiple-models-to-one-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!