Skip to Content
Menu
This question has been flagged
2 Replies
5704 Views

I am create module cal salesman

1. i created model


salesman.py

class Salesman(models.Model):
 _name = 'smartsales.salesman'
 _description ='Salesman'
 _inherit = 'mail.thread'
salesname = fields.Many2one('res.users', string='Name', defalut=lambda self: self.env.uid)
companyname = fields.Char(string='Companyname')
@api.onchange('salesname.company_id','companyname')
 def update_company(self):
  self.companyname = self.salesname.company_id


view

<field name="salesname"  />
<field name="companyname" on_change="0" readonly="1"/>


I want to create dropdownlist that when i select user and it will show companyname  of user 

how can i do it ? 


Avatar
Discard

companyname = fields.Many2one('res.company', string='Companyname')

@api.onchange('salesname')

def update_company(self):

self.companyname = self.salesname.company_id.id

Author

thank you Niyas Raphy

Best Answer

I f you want only companyname 


  self.companyname = self.salesname.company_id.name

Avatar
Discard
Related Posts Replies Views Activity
0
Oct 22
942
7
Apr 18
8728
0
Mar 17
3437
1
May 22
14215
6
Dec 23
108032