Hello,
Example of dropdown list from another model.
.py file :
class ResPartner(models.Model):
_inherit = 'res.partner'
software = fields.Many2one('partner.software', string='Software')
#this is the dropdown list
class PartnerSoft(models.Model):
_name = 'partner.software'
_description = 'Software'
software = fields.Char('Soft')
_rec_name = 'software'
#this is where I save my custom values
xml file for the dropdown list :
<record id="res_partner_form_view_extension" model="ir.ui.view">
<field name="name">res.partner.form.view.extension</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="model">res.partner</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='lang']" position="after">
<field name="software"/>
</xpath>
</field>
</record>
xml file for the second model where you store the dropdown list values:
<odoo>
<data>
<record id="res_partner_soft_form_view" model="ir.ui.view">
<field name="name">res.partner.soft.form.view</field>
<field name="model">partner.software</field>
<field name="arch" type="xml">
<form>
<sheet>
<div>
<label for="soft" string="Software" class="oe_edit_only"/>
<h1><field name="software"/></h1>
</div>
</sheet>
</form>
</field>
</record>
<record id="res_partner_soft_tree_view" model="ir.ui.view">
<field name="name">res.partner.soft.tree.view</field>
<field name="model">partner.software</field>
<field name="arch" type="xml">
<tree string="software">
<field name="software"/>
</tree>
</field>
</record>
<record id="res_partner_soft_search_view" model="ir.ui.view">
<field name="name">res.partner.soft.search.view</field>
<field name="model">partner.software</field>
<field name="arch" type="xml">
<search string="Software">
<field name="software"/>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="partner_soft_action">
<field name="name">Software</field>
<field name="res_model">partner.soft</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="res_partner_soft_tree_view"/>
<field name="view_type">form</field>
<field name="search_view_id" ref="res_partner_soft_search_view"/>
</record>
<menuitem id="partner_soft_menu_item"
name="Software"
action="partner_soft_action"
parent="contacts.menu_contacts"/>
</data>
</odoo>