Odoo Help


Extending calendar event throws LINE 1: delete from calendar_event_res_partner_rel where turns_turn_...

Sebastián Seifert
on 1/25/16, 9:10 AM 468 views

I´m trying to extend calendar.event as prototype inheritance.  It looks like it is trying to access the relationship with wrong fields. I gess I´m making some mistake with this type of inheritance. 

My code is this.

# -*- coding: utf-8 -*-


Created on 17 de dic. de 2015

@author: seba


from openerp import models, fields, api

from openerp.exceptions import ValidationError

from datetime import date

import logging

_logger = logging.getLogger(__name__)

class turns_turn(models.Model):

_name = 'turns.turn'

_inherit = 'calendar.event'

court = fields.Many2one("turns.court","Cancha",required="True",help="La chancha que se vaya a ocupar en este turno")

cash_advance = fields.Float("Seña",required="True",default=0,help="Seña para reserva de cancha")

client = fields.Many2one("turns.client",string="Cliente",required = "True",help="El cliente al cual se le asigna el turno")

total_cost = fields.Float("Costo total",readonly=True,help="Costo total calculado como precio de cancha unitario x duración del turno")

state = fields.Selection([("reserva","Reserva de turnos"),

("canchatomada","Cancha Tomada"),

("turnocerrado","Turno Cerrado"),


_defaults = {

'state': 'reserva',

'name': 'turno',

'start': '2016-01-19 09:00:00',

'stop': '2016-01-19 09:00:00'



@api.returns('self', lambda value:value.id)

def create(self, vals):

court_selected = self.env['turns.court'].search([('id','=',vals['court'])])

vals['total_cost'] = vals['duration'] * court_selected.court_unity_price

return models.Model.create(self, vals)

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

if context is None:

context = {}

if isinstance(ids, (int, long)):

ids = [ids]

res = []

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

name = record.client

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

return res

def take_court(self):

self.state = "canchatomada"

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

2 follower(s)


Asked: 1/25/16, 9:10 AM
Seen: 468 times
Last updated: 7/12/16, 4:37 AM