Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Odoo 10:从发票模块获取类似发票的视图_Python_Xml_Module_Customization_Odoo - Fatal编程技术网

Python Odoo 10:从发票模块获取类似发票的视图

Python Odoo 10:从发票模块获取类似发票的视图,python,xml,module,customization,odoo,Python,Xml,Module,Customization,Odoo,我正在扩展Employees模块,以列出员工从公司获得的所有设备。下面是my models.py: # -*- coding: utf-8 -*- from odoo import models, fields, api class device_types(models.Model): _name = "device.types" name = fields.Char() class device_names(models.Model): _name = "dev

我正在扩展Employees模块,以列出员工从公司获得的所有设备。下面是my models.py:

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class device_types(models.Model):
    _name = "device.types"
    name = fields.Char()

class device_names(models.Model):
    _name = "device.names"
    name = fields.Char()
    #devices_names = fields.Many2one('hr.employee')


class devices(models.Model):
    _name = "devices"

    #devices_types = fields.Many2one('device.types')
    devices_id = fields.Many2one('hr.employee')
    devices_types = fields.Char()
    devices_names = fields.Char()



    #employee_id = fields.Many2one('hr.employee')


class employee_devices(models.Model):
     _inherit = 'hr.employee'
     #devices_lines_ids = fields.One2many('devices','devices_id',string='Device Lines',readonly=True, states={'draft': [('readonly', False)]}, copy=True)
     devices_lines_ids = fields.One2many('devices','devices_id',string='Device Lines')
     #devices_names = fields.Many2one('devices')
     #devices_types = fields.Many2one('devices')
     devices_types = fields.One2many('devices','devices_types')
     devices_names = fields.One2many('devices.names')
和my view.xml:

<odoo>
  <data>
    <!-- explicit list view definition -->

    <record id="invoice_form" model="ir.ui.view">
    <field name="model">hr.employee</field>
    <field name="inherit_id" ref="hr.view_employee_form" />
    <field name="priority" eval="1"/>
    <field name="arch" type="xml"> 
        <xpath expr="//notebook//page[@name='hr_settings']" position="after">
         <page name="Devices" string="Devices" groups="hr.group_hr_user">
                                <group>
                                    <group string="Devices" name="devices_group">
                                        <field name="devices_lines_ids" nolabel="1" widget="one2many_list" mode="tree" >
                                         <tree string="Devices" editable="bottom">
                                           <field name="devices_types" />
                                              <field name="devices_names"/> 
                                         </tree> 
                                        </field>
                                    </group>
                                </group>
        </page>
       </xpath>
    </field>
</record>


  </data>
</odoo>

人力资源部员工
我能够做到这一点:

但是我希望在设备类型和设备名称列中有一个下拉菜单,能够创建新的类型和名称。我尝试了不同的组合,正如您在models.py的注释中所看到的。如何在我的视图中获得下拉菜单


简而言之,我想要这种类型的视图,我可以编辑树状视图中的每一列,有些列有下拉菜单:

已修复。my updated modules.py:

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class device_types(models.Model):
    _name = "device.types"
    name = fields.Char()

class device_names(models.Model):
    _name = "device.names"
    name = fields.Char()


class devices(models.Model):
    _name = "devices"
    employee_name = fields.Many2one('hr.employee')
    devices_names = fields.Many2one('device.names')
    devices_types = fields.Many2one('device.types')



class employee_devices(models.Model):
     _inherit = 'hr.employee'
     devices_lines_ids = fields.One2many('devices','employee_name',string='Device Lines',states={'draft': [('readonly', False)]}, copy=True)
和my views.xml:

    <odoo>
    <data>
    <!-- explicit list view definition -->

    <record id="invoice_form" model="ir.ui.view">
      <field name="model">hr.employee</field>
      <field name="inherit_id" ref="hr.view_employee_form" />
      <field name="priority" eval="1"/>
      <field name="arch" type="xml">
        <xpath expr="//notebook//page[@name='hr_settings']" position="after">
          <page name="Devices" string="Devices" groups="hr.group_hr_user">
            <group>
                <field name="devices_lines_ids" nolabel="1" widget="one2many_list" mode="tree">
                  <tree string="Devices" editable="bottom">
                    <field name="devices_types" />
                    <field name="devices_names"/>
                  </tree>
                </field>
            </group>
          </page>
        </xpath>
      </field>
    </record>
  </data>
</odoo>

人力资源部员工
是的,您只需创建与
device.name
device.types
的(多个)关系即可。