Odoo Help


Do changes in objects added in one2many

on 5/24/16, 4:12 AM 359 views

This is my code: 

import openerpfrom openerp.osv 
import osv,fieldsfrom datetime 
import dateclass tickets(osv.Model):
    _name = 'tickets'
    _inherit = ['mail.thread']
    _rec_name = 'code'
? -->
    def _connect_tickets(self, cr, uid, ids, context=None):
        print context
        return False

    _columns = {
        'code': fields.char(string='Reference'),
        'title': fields.char(string='Title', required=True),
        'description': fields.text(string='Description', required=True),
        'partner_id': fields.many2one('res.partner', string='Partner', required=True),
        'responsible_id': fields.many2one('res.users', string='Responsible'),
        'channel_id': fields.many2one('crm.tracking.medium', string='Channel'),
        'email_from': fields.char(string='From:'),
        'email_cc': fields.char(string='CC:'),
        'date': fields.date(string='Date'),
        'write_date': fields.date(string='Update date'),
        'date_deadline': fields.date(string='Deadline date'),
        'date_closed': fields.date(string='Closed date'),
        'priority': fields.selection([('0', 'Low'), ('1', 'Normal'), ('2', 'High')], string='Priority'),
        'status': fields.selection(
            [('draft', 'New'),
            ('open', 'In Progress'),
            ('pending', 'Pending'),
            ('validate', 'To Validate'),
            ('done', 'Closed'),
            ('cancel', 'Cancelled')], string='Status', required=True),
        'ref': fields.char(string='Reference', selection=openerp.addons.base.res.res_request.referencable_models),         'ref2': fields.char(string='Reference 2', selection=openerp.addons.base.res.res_request.referencable_models),
        'spent_time': fields.float(string='Spent time'),         'is_email': fields.boolean(string='is_email'),         'parent_ticket_id': fields.many2one('tickets', string='Related tickets'),         'child_ticket_ids': fields.one2many('tickets', 'parent_ticket_id', compute='_connect_tickets', string='Related tickets'),         'registers_ids': fields.one2many('registers', 'tickets_id', string='Registers'),         'fused': fields.selection([('fused', 'Fused')], string='Status'),     }

What I want is when I add a ticket in child_ticket_ids field, the ticket associated has the ticket where I associate it. 

For example: 

I have ticket #001 and in the form view (in the child_ticket_ids field) I associate ticket #002, when I do this I want the ticket #002 has in its child_ticket_ids field ticket #001.

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: 5/24/16, 4:12 AM
Seen: 359 times
Last updated: 5/24/16, 4:13 AM