Sari la conținut
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Property Management
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Suport

Error on Calling function from button

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
functionerrorbuttonsprivate10.0
1 Răspunde
20137 Vizualizări
Imagine profil
Sylwester Zalewski

Hi, 

I receive following error when I try to call my function to update some fields "Private methods (such as _get_coords_from_address) cannot be called remotely."  Any ideas ? Thanks

@api.one
def _get_coords_from_address(self):
if self.full_address != None:
lat_long = geocoder.google(self.full_address)
# self.lat_long = lat_long.latlng
    self.write({'lat_long': lat_long.latlng}) 
<button string="Map Coordinates" type="object" name="_get_coords_from_address"  class="oe_stat_button" />
1
Imagine profil
Abandonează
Imagine profil
Yenthe Van Ginneken (Mainframe Monkey)
Cel mai bun răspuns

Hi Sylwester,

By default Python functions starting with _ are considered private methods. For more information have a look at https://stackoverflow.com/questions/1547145/defining-private-module-functions-in-python
In your case you can simply change the button name from _get_coords_from_address to get_coords_from_address (remove the _). If you do the same on the Python side it will work fine.
By removing the underscore Odoo will no longer see it as a private method, which caused your initial error.
On a sidenote, you're using the @api.one decorator which is pretty much deprecated. It is better to use @api.multi in combination with self.ensure_one. Your code shoud look like this in XML:

<button string="Map Coordinates" type="object" name="get_coords_from_address" class="oe_stat_button"/>

The Python:

@api.multi
def get_coords_from_address(self):
# This will make sure that you have one record instead of multiple (singleton) self.ensure_one()
if self.full_address != None:
lat_long = geocoder.google(self.full_address)
# self.lat_long = lat_long.latlng
    self.write({'lat_long': lat_long.latlng}) 

Regards,
Yenthe

8
Imagine profil
Abandonează
Sylwester Zalewski
Autor

Perfect! Thanks

Yenthe Van Ginneken (Mainframe Monkey)

You're welcome - best of luck!

Îți place discuția? Nu doar citi, alătură-te!

Creează-ți un cont astăzi pentru a beneficia de funcții exclusive și a interacționa cu minunata noastră comunitate!

Înscrie-te
Postări similare Răspunsuri Vizualizări Activitate
[Odoo 17] Call a Function in a Different Model - Server Action Rezolvat
error buttons server_actions
Imagine profil
Imagine profil
1
apr. 24
4359
Create Button not visible in View Form odoo15?
error buttons View
Imagine profil
Imagine profil
2
ian. 23
3916
Why I get this 'str' object is not callable error with my new function field? Rezolvat
function error field
Imagine profil
Imagine profil
2
feb. 17
9205
How to generate values when click a button? Rezolvat
function create buttons
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
oct. 15
11573
Field.function Help
function error item
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
apr. 15
6927
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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