Odoo Help


Search function getting right value in many2one field?

Darius Martinkus
on 2/25/15, 12:32 PM 2,318 views

Hello Odoo community!

I want to replace that 4 with attribute record.control_id but when i do that record.control_id outputs pp.control(4,) which is correct but how to retrieve raw data only 4? without pp.control?

Code example below:
def end_date(self, cr, uid, ids, values, arg, context):
            y = self.pool.get('pp.control')

            for record in self.browse(cr, uid, ids):
                other_table2 = y.search(cr, uid,[('id','=',record.control_

                #other_table2 = y.search(cr, uid,[('id','=','4')])
                res2 = y.browse(cr, uid, other_table2[0])                          
                x[record.id] = (datetime.strptime(res2.start_date, '%Y-%m-%d') + relativedelta(months=record.platform_duration)).strftime('%Y-%m-%d')             
            return x

  _columns = {
    'name': fields.many2one('xref.option', 'Platform', required=True, domain="[('type','=','Platform')]"),
    'platform_start': fields.integer('Platform Start', help='Month during which platform will first be required'),
    'platform_duration': fields.integer('Duration', help='Number of months that that the platform is required)'),
    'control_id': fields.many2one('pp.control', 'Plan'),
    #'end_date': fields.char(compute='_end_date', string='End Date', help='Calculated as start date plus duration in months'),
    'end_date' : fields.function(end_date, method=True, string='End Date', type="char")


Thank you,


Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 2/25/15, 1:09 PM

Hi, what you need is the id of the many2one field.
other_table2 = y.search(cr, uid,[('id','=',record.control_ id.id)]) will give you #other_table2 = y.search(cr, uid,[('id','=','4')])

Darius Martinkus
On 2/26/15, 12:12 PM


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/25/15, 12:32 PM
Seen: 2318 times
Last updated: 10/23/15, 9:18 AM