Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Make selection field using values of another few fields

By
rukshani
on 11/8/16, 1:13 AM 149 views

I have add name as "first name", "middle" and "last name".

Want to get them three for another drop-down. (V8)

1
Ameera PP
On 11/8/16, 5:41 AM

Check this link:

https://www.odoo.com/forum/help-1/question/how-to-give-rec-name-as-a-combination-of-two-fields-40034

1
Anjana Arora
On 11/8/16, 5:48 AM

def name_get(self, cr, uid, ids, context=None):
      res = []       

     for record in self.browse(cr, uid, ids, context=context):
            name = ''           

            if record.first_name or record.middle or record.last_name:
                name = str(record.first_name)+ '/' + str(record.middle)   + '/' + str(record.last_name)

            res.append((record.id, name))    

    return res

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 11/8/16, 3:22 AM

Write a Selection function, and inside the function, build the Selection tuple in whichever way you needed.

Something this like


@api.model    
def _get_xyz_selection(self):
return [('option1', 'Option1'),
('option2', 'Option2),...]

xyz_column = fields.Selection(selection=_get_xyz_selection, ...)
0
shameem@aχoncoms
On 11/8/16, 3:12 AM


Hi Rukshani,


Create the fields

class ResPartnerInherited(models.Model):
     _inherit = 'res.partner'
     _rec_name = 'full_name'

     middle_name = fields.Char('Middle Name')
     last_name = fields.Char('Last Name')
     
     def _get_full_name(self):
         self.full_name=self.name+self.middle_name+self.last_name
     full_name = fields.Char(compute='_get_full_name')

Create Many2One field in another model

    partner_id = fields.Many2one('res.partner', 'Partner')     

xml

<field name="partner_id"/><!--   It will display like dropdown box                     -->

Thanks 


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/8/16, 1:13 AM
Seen: 149 times
Last updated: 11/9/16, 10:53 PM