Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Overwrite create function of calendar.event

Naroči se

Get notified when there's activity on this post

This question has been flagged
calendarcreateoverwritecalendar.eventgoogle_calendar
6302 Prikazi
Avatar
Koffi KPONOUGLO

I have tree models and i want to overwrite create function of calendar.event models to get in the patners_ids field, who is patient and append it on the medical.appointment model on create. 

Here a part of code : 

Class MedicalAppointment(models.Model):

_name = "medical.appointment"

patient = fields.Many2one ('medical.patient', 'Patient', readonly=True, states={'draft': [('readonly', False)]}, help="Patient Name", required=True,)

class MedicalPatient(models.Model):

_name = "medical.patient"

name = fields.Many2one('res.partner', 'Patient', required="1", track_visibility='onchange', domain=[('is_patient', '=', True), ('is_person', '=', True)], help="Patient Name")

@api.multi

@api.depends('name', 'patient_id')

def name_get(self):

result = []

for partner in self:

name = partner.name.name

if partner.patient_id:

name = '[' + partner.patient_id + ']' + name

result.append((partner.id, name))

return result

@api.model

def name_search(self, name, args=None, operator='ilike', limit=100):

args = args or []

recs = self.browse()

# if name:

# recs = self.search(['|', '|', '|', '|', '|', ('name', operator , name), ('patient_id', operator , name), ('mobile', operator , name), ('other_mobile', operator , name), ('lastname', operator , name), ('middle_name', operator , name) ] )

if not recs:

recs = self.search([('name', operator, name)])

return recs.name_get()

class Meeting(models.Model):

_name = 'calendar.event'

partner_ids = fields.Many2many('res.partner', 'calendar_event_res_partner_rel', string='Attendees', states={'done': [('readonly', True)]}, default=_default_partners)

I write this code but it is not working well : 

class Meeting(models.Model):

_name = 'calendar.event'

_inherit = ["calendar.event"]

@api.model

def create(self, values):

if not 'user_id' in values: # Else bug with quick_create when we are filter on an other user

values['user_id'] = self.env.user.id

# compute duration, if not given

if not 'duration' in values:

values['duration'] = self._get_duration(values['start'], values['stop'])

meeting = super(Meeting, self).create(values)

final_date = meeting._get_recurrency_end_date()

# `dont_notify=True` in context to prevent multiple notify_next_alarm

meeting.with_context(dont_notify=True).write({'final_date': final_date})

meeting.with_context(dont_notify=True).create_attendees()

# Notify attendees if there is an alarm on the created event, as it might have changed their

# next event notification

if not self._context.get('dont_notify'):

if len(meeting.alarm_ids) > 0:

self.env['calendar.alarm_manager'].notify_next_alarm(meeting.partner_ids.ids)

if meeting.partner_ids:

patients = meeting.partner_ids.search([('is_patient', '=', True)])

patient = patients[0]

pat_name = patient.name

patient_obj = self.env['medical.patient']

current_patient = patient_obj.search(pat_name)

if meeting.start:

self.env['medical.appointment'].create({'patient': current_patient})

return meeting


I need a help 







0
Avatar
Opusti
Sehrish

Whats the error log?

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Google Calendar sync creates contacts from past events – how to limit?
calendar google_calendar
Avatar
Avatar
1
jul. 25
1637
Google Calendar sync creates contacts from past events – how to limit?
calendar google_calendar
Avatar
0
jul. 25
1350
How to pass query parameters in URL to the Odoo calendar module?
calendar calendar.event
Avatar
0
jun. 25
1539
How to create a Google event in an Organization shared calendar (not individual) when creating an appointment in Odoo?
calendar google_calendar
Avatar
Avatar
1
jan. 25
2414
Sync specific caoendar with Google calendar
calendar google_calendar
Avatar
Avatar
2
nov. 23
2741
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now