Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profit organisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

OnChange Create bad query

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
errorone2manycreateonchange10
6040 Weergaven
Avatar
Sylwester Zalewski

Hi,

I'm trying to create entries from template, for example when user choose template from the list the list below (One2Many) should be crated from the template lines, but I have bad query error plus when the method update the list I can see its not correct, the product and equipment is missing, here's my code:

class cmms_accessory(models.Model):
_name = 'cmms.accessory'
_description = 'Equipment Accessory'

name = fields.Char(related='product.name')
equipment_id = fields.Many2one('cmms.equipment', 'Serial Number', required=True)
product = fields.Many2one('product.product', 'Product', required=True)
photo = fields.Binary(string="Image", related="product.image")
revision_number = fields.Char(string='Revision Number', help='E.g 2.0')
revision_description = fields.Char(string='Revision Description', help='E.g Chogori/ Black Remote')
state = fields.Selection([('ok', 'OK'), ('in_transit', 'In Transit'), ('replaced', 'Replaced'), ('fault', 'Fault'),
('returned', 'Returned')], string='Status', default='ok')
serial = fields.Char(string='Serial Number')
additional_info = fields.Char(string='Additional Information')
Here's the error :
odoo.sql_db: bad query: INSERT INTO "cmms_accessory" ("id", "product", "revision_description", "equipment_id", "state", "revision_number", "serial", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('cmms_accessory_id_seq'), NULL, NULL, 1, '
ok', '1', NULL, 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
and here's my onchange method in different class
@api.onchange('template_id')
def _add_accessories(self):
if not self.template_id:
return

template = self.template_id.accessory_template
accessories_lines = []

for line in template:
aa = line.accessory_template
data = {
'product.id': aa.product.id, # M2O
'revision_description': aa.revision_description, # Char
'equipment_id': self.id, #M2O
'state': 'ok', # Selection
'revision_number': aa.revision_number, # Char
'serial': None, # Char
'photo': aa.photo,#Binary
'additional_info': None,#Char
}

accessories_lines.append((0, 0, data))
self.accessory = accessories_lines;
0
Avatar
Annuleer
Sylwester Zalewski
Auteur

Fixed.. missed product(.id) and used self.updated. Closed!

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
TypeError: pop() takes at most 1 argument (2 given)
error one2many create v7
Avatar
Avatar
1
mrt. 15
19688
AttributeError: ondelete Odoo 9
error one2many create attributeerror odoo9
Avatar
0
feb. 19
3993
How to store the readonly field with in a One2Many(onchange appplied)? Opgelost
one2many create readonly onchange odoo10
Avatar
Avatar
1
jun. 17
5706
How to create sale order line in onchange one2many?
one2many create sale.order.line onchange 6.1
Avatar
0
mrt. 15
8511
How to update two levels o2m fileds relation
one2many onchange
Avatar
0
sep. 20
3723
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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