Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Odoo docs Chapter 12: Inheritance

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
developmentdebug
1 Atsakyti
1740 Rodiniai
Portretas
Kareem
Python Inheritance -> 

 Exercise

Add business logic to the CRUD methods.

  • Prevent deletion of a property if its state is not ‘New’ or ‘Cancelled’

Tip: create a new method with the example)

any help of what self do

vals : data send from form

self : ?????

it's a way to query the data from the data base .

​or

​it 's have the context send from ui and if it's the context how can i debug or print this object to navigate throw it's member




@api.model_create_multi
def create(self, vals):
for val in vals:
# get estate_property
estate_property = self.env["estate.property"].browse(val["property_id"])

estate_property.state = "offer_Received"
# get list of estate_property_offers from estate_property
estate_property_offers = estate_property.offer_ids

new_val = val["price"]
max_all_value_before_save = max(estate_property_offers.mapped("price"), default=0.0)

if new_val < max_all_value_before_save:
raise UserError("Price must bigger than the highest offers")

return super().create(vals)
1
Portretas
Atmesti
Kareem
Autorius

thank u  Chathura , your answer help me lot 


In your code, create(self, vals) is a method being decorated with @api.model_create_multi, which means,

  • self is the model class ===> estate.property
  • vals is a list of dictionaries containing the values to create multiple records --> = offer_ids with id == 0 
  • print(vals)


estate_property = self.env["estate.property"].browse(val["property_id"])

so this code working because  estate.property is the model class 

 and i get estate_property_offers from estate.property


self.env["estate.property.type"].browse(val["property_type_id"]) --> throw error 

but this not, so if i want to get to any look up i need deal with model class estate.property  first

is that's right  and if i want to query estate_property_offers  it's have another  method 

@api.model_create_multi


def create(self, vals):
for val in vals:
# get estate_property
estate_property = self.env["estate.property"].browse(val["property_id"])

estate_property.state = "offer_Received"
# get list of estate_property_offers from estate_property
estate_property_offers = estate_property.offer_ids

new_val = val["price"]
max_all_value_before_save = max(estate_property_offers.mapped("price"), default=0.0)

if new_val < max_all_value_before_save:
raise UserError("Price must bigger than the highest offers")

return super().create(vals)



Portretas
Chathura Munasinghe
Best Answer

Hello Kareem,

In Odoo, self represents the current object instance. When you define methods in an Odoo model, self is the first parameter and it refers to,

  1. In a regular method - The recordset (collection of records) you're working with
  2. In the @api.model decorated methods - The model class itself (not a specific record)

In your code, create(self, vals) is a method being decorated with @api.model_create_multi, which means,

  • self is the model class
  • vals is a list of dictionaries containing the values to create multiple records

Hope this helps.

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

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

Registracija
Related Posts Replies Rodiniai Veikla
(((guia-ayuda)))¿Cómo llamar a Latam Chile desde celular?
development debug
Portretas
0
gruod. 25
1
Testing of computed field in Odoo 18 extension dev
development debug
Portretas
1
lapkr. 25
611
How do I correctly create a calculated field to sum two other field values in Odoo Studio (Odoo Online)? Solved
development debug
Portretas
Portretas
2
lapkr. 25
724
How can I make buttons in Odoo 18? Solved
development debug
Portretas
Portretas
Portretas
3
rugs. 25
1730
Problem when creating my first module locally
development debug
Portretas
Portretas
Portretas
Portretas
Portretas
4
rugp. 25
2188
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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