Odoo Help


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.


grab id from res_partner

on 12/13/13, 5:46 AM 591 views

hi guys, iam stuck for a while, i could use somebodys help. What i want to do is grab a id from a parent and use it to store in another field. ( the res_id ) see below :)

class document(osv.osv):
_name = 'ir.attachment'
_inherit= {
_columns = {
    'petmobiel_document_id': fields.many2one('a.petmobiel', 'document'),
_defaults = {
'description': lambda  *a: "0",
'res_id'   <================================ i want to use the partner_id from res_partner there

Alltough i have no clue how to get it there. below my other tables.

class klanten(osv.osv):
_name = 'res.partner'
_columns = {
    'mobiel_abbo': fields.one2many('a.petmobiel', 'petmobiel_klant_id', string="Telefoon abonnementen", select=True),


class petmobiel(osv.osv):
_name = 'a.petmobiel'
_columns = {
    'name': fields.char('telefoonnummer', size=10, required=True),
    'petmobiel_klant_id': fields.many2one('res.partner', 'Klant', select=True),
    'petmobiel_verlengduur': fields.selection((('1','1 jaar'),('2','2 jaar'),('3','3 jaar')),'Verleng duur'),   
    'petmobiel_contractduur': fields.selection((('1','1 jaar'),('2','2 jaar'),('3','3 jaar')),'Contract duur'), 
    'petmobiel_document': fields.one2many('ir.attachment', 'petmobiel_document_id', string="Mobiel", select=True),

} _defaults = { 'petmobiel_contractduur': lambda *a: "0", } petmobiel()

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)


Asked: 12/13/13, 5:46 AM
Seen: 591 times
Last updated: 3/16/15, 8:10 AM