-1

I have a custom odoo app. In my model I have a Many2One form the type res.partner. If I display the field <field name="projectmanager" domain="[('partner_type', '=', 'Manager')]"/> in a form view, I get the name, address, city and country. How can I hind the address and display only the name?

The model:

class CalamityCalamity(models.Model):
    _name = 'calamity.calamity'
    _inherit = ['mail.thread']
    _description = 'Schadelijsten'
    _order = "projectnr"
    _rec_name = "projectnr"

    projectnr       = fields.Char(string='Projectnummer')
    projectmanager  = fields.Many2one('res.partner', ondelete='set null', string="Projectmanager", index=True,  domain=[('partner_type','=','Manager')])
Naglis
  • 2,583
  • 1
  • 19
  • 24
wim_til
  • 140
  • 10

3 Answers3

1

Many2one field always open the default form view but you can change this And define witch form using xml id

 <field name="projectmanager"  context="{'form_view_ref': 'module_name.form_id'}"/>

Just create a new form that display what you need exactly

Charif DZ
  • 14,415
  • 3
  • 21
  • 40
0

did you tried this

<field name="projectmanager" options='{"widget": "contact", "fields": ["name"]}'/>
Lakshminarayanan
  • 320
  • 4
  • 18
0

try to replace "res.partner" with "partner_id.field_name".

projectmanager  = fields.Many2one('partner_id.name', ondelete='set null', string="Projectmanager", index=True,  domain=[('partner_type','=','Manager')])

Hope this will help you.

Gautam Bothra
  • 565
  • 1
  • 8
  • 23