Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Update all record

Subscriure's

Get notified when there's activity on this post

This question has been flagged
updaterecords
5 Respostes
14671 Vistes
Avatar
Pamungkas Sugihartoko

Hi all,


i'm new in odoo and python programming. i have a situation. i want to update all record in a table. here's my code

def button_posting(self):

self.write({'state':'active'})

return True

that code only update one record. from 'draft' to 'active' in state field. 

when i clicked a 'Posting' button, i want update all record to 'draft' and only one record become 'active'

how can i do that..?

thanks before.


PS: i'm sorry for my terrible english.. :)


0
Avatar
Descartar
Axel Mendoza

i got this error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\http.py", line 537, in _handle_exception
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\http.py", line 574, in dispatch
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\http.py", line 310, in _call_function
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\service\model.py", line 113, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\http.py", line 307, in checked_call
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\http.py", line 803, in __call__
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\http.py", line 403, in response_wrap
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\addons\web\controllers\main.py", line 948, in call_button
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\api.py", line 241, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\api.py", line 363, in old_api
  File "D:\koulu\mdi_ta\models.py", line 31, in button_posting
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\api.py", line 239, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\api.py", line 463, in new_api
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\models.py", line 1644, in search
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\api.py", line 241, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\models.py", line 4640, in _search
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\api.py", line 241, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\models.py", line 4463, in _where_calc
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\osv\expression.py", line 646, in __init__
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\osv\expression.py", line 749, in parse
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\osv\expression.py", line 532, in __init__
  File "C:\Program Files (x86)\Odoo 8.0-20150723\server\.\openerp\osv\expression.py", line 588, in check_leaf
ValueError: Invalid leaf id

here is my code:

@api.multi

def button_posting(self):

self.search(['id', '!=', self.id]).write({'state':'draft'})

self.write({'state':'active'})

return True


what should i do? i use win 10

thanks.


Axel Mendoza

Solve it?

Avatar
Pamungkas Sugihartoko
Autor Best Answer

un done sir..

i still get error... T__T

0
Avatar
Descartar
Avatar
Axel Mendoza
Best Answer

You can do it like:

@api.multi

def button_posting(self):

self.search([('id', '!=', self.id)]).write({'state':'draft'})

self.write({'state':'active'})

return True

Hope that helps

0
Avatar
Descartar
Axel Mendoza

Sorry I omit some parenthesis on the domain, I update it on the anwer, copy and check it again

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Odoo auto updates for on-premises Enterprise version (cloud/ in-house server) - v10 v11 v12 Solved
update
Avatar
Avatar
Avatar
2
de maig 24
9123
Cannot Update missing Report
accounting update records error_updating
Avatar
Avatar
1
de set. 23
4046
Record rules not working for specific group of users in Odoo 16 - Need an Urgent Resolution
records
Avatar
Avatar
2
d’ag. 23
5708
Count Related Records Solved
records
Avatar
Avatar
1
de gen. 21
6384
odoo module update error Solved
update
Avatar
Avatar
1
de gen. 20
8511
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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