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

Write to Record in Related Field of Many2One Relationship

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
many2onerelated_fields
7247 Weergaven
Avatar
Michael Thomas

I have an object that, when it completes it's workflow, needs to update the state for a different class, specifically manufacturing orders. I have tried everything I can think of to try to update that field. Code is thus:

class mrp_partsorder(osv.Model):
...

_columns = {
'sourceorder_id': fields.many2one('mrp.production', string='Manufacturing Order'
'primarystate': fields.selection ( [..states...], related='sourceorder_id.state'
}

def partsorder_complete(self, cr, uid, ids, context=None):
prod_obj = self.pool.get('mrp.production')
prod_ids = [self.sourceorder_id]
prods = prod_obj.search(cr, uid, prod_ids, context=context)
proc_obj.action_fitting(cr, uid, prods, context=context)
res = self.write(cr, uid, ids, {'state': 'complete'}, context=context)

class mrp_production(osv.osv)
def action_fitting(self, cr, uid, ids, context=None):
res = self.write(cr, uid, ids, {'state': 'fitting'}, context=context) return res
 


At the moment I'm getting the following error:

ValueError: "'mrp.partsorder' object has no attribute '_ids'" while evaluating
u'partsorder_complete()

This is not the only error I've seen, as I've tried quite a few different ideas of solving this problem. Basically, i just want to update the value in the related field (primarystate), but if I write to that field it updates the mrp.partsorder table but not the mrp.production table. So, I figured I needed to use self.pool.get to get the singleton instance of mrp.production and then use the the write method for mrp.production or use the action_fitting() method for mrp.production. 

What is the best way to solve this problem?

Edit: After further consideration I realized that I need to use the function on mrp.production to change the state, rather than just writing to it. I want to do this because of all the functionality built into the manufacturing order. All I need now is to figure out how to call the function from my mrp.partsorder.partsorder_complete() function. 

0
Avatar
Annuleer
Michael Thomas
Auteur

So I have now tried doing something like: mrp_order = self.pool.get('mrp.production') order_ids = self.sourceorder_id for order in mrp_order.browse(cr, uid, order_ids): order.action_fitting() I think that fixes some syntax issues I have, but I'm still getting the same error. The worst part is it is saying mrp.partsorder has no attribute _ids, which is odd since the function I'm calling is from the mrp.production object.

Michael Thomas
Auteur

As a follow up, mrp.partsorder shouldn't be called until the end of the partsorder_complete() function. So, the should be no problem running the action_fitting() function, unless the error is happening when I try to pass the sourceorder_ids (the m2o relationship between mrp.partsorders and mrp.production) to prod_ids.

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
Send a value from context one2many
many2one related_fields odoo15
Avatar
0
mei 24
1783
Related field not found while trying to set up a One2many field. Opgelost
many2one one2many related_fields
Avatar
Avatar
Avatar
2
okt. 23
3098
Product variant is also product (odoo 14) Opgelost
product many2one related_fields
Avatar
Avatar
1
mrt. 21
2786
v17: Module upgrade fails due to Many2one-related field Opgelost
many2one upgrade related_fields v17
Avatar
Avatar
1
okt. 25
478
value not pass from many2one field to form
many2one
Avatar
Avatar
Avatar
Avatar
3
sep. 25
2297
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