0

我的视图.xml

<odoo>
  <data>
    <record model = "ir.ui.view" id = "custom_expense.list">
      <field name = "name"> custom_expense list </field>
      <field name = "model"> custom_expense.custom_expense </field>
      <field name = "arch" type = "xml">
        <tree>
          <field name = "name" />
          <field name = "test" />
        </tree>
      </field>
    </record>

    <record model = "ir.actions.act_window" id = "custom_expense.action_window">
      <field name = "name"> custom_expense </field>
      <field name = "res_model"> custom_expense.custom_expense </field>
      <field name = "view_mode"> tree, form </field>
    </record>

    <menuitem name = "custom_expense" id = "custom_expense.menu_root" />
    <menuitem name = "Menu 1" id = "custom_expense.menu_1" parent = "custom_expense.menu_root" />
    <menuitem name = "Submenu 1" id = "custom_expense.menu_1_list" parent = "custom_expense.menu_1"

              action = "custom_expense.action_window" />
  </data>
</odoo>

我的模型.py

from odoo import models, fields, api
class custom_expense (models.Model):
    _name = 'custom_expense.custom_expense'
    _inherit = 'hr.expense'

    test = fields.Char (string = 'Valuethird')

我想显示 hr.expense 模型中的“名称”字段,但我发现错误:TypeError: Many2many fields custom_expense.custom_expense.tax_ids 和 hr.expense.tax_ids 使用相同的表和列 - - -

4

1 回答 1

0

我认为您正在尝试向 hr.expense 添加一个新字段。如果是这种情况,您不需要创建新模型。只有_inherit就足够了,python文件中不需要_name,只需继承xml文件。如果您想要新表,则需要在父模型中重新定义 many2many。

于 2020-03-27T07:20:01.673 回答