Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Write to Record in Related Field of Many2One Relationship

Odebírat

Get notified when there's activity on this post

This question has been flagged
many2onerelated_fields
7244 Zobrazení
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
Zrušit
Michael Thomas
Autor

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
Autor

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.

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Send a value from context one2many
many2one related_fields odoo15
Avatar
0
kvě 24
1782
Related field not found while trying to set up a One2many field. Vyřešeno
many2one one2many related_fields
Avatar
Avatar
Avatar
2
říj 23
3098
Product variant is also product (odoo 14) Vyřešeno
product many2one related_fields
Avatar
Avatar
1
bře 21
2786
v17: Module upgrade fails due to Many2one-related field Vyřešeno
many2one upgrade related_fields v17
Avatar
Avatar
1
říj 25
477
value not pass from many2one field to form
many2one
Avatar
Avatar
Avatar
Avatar
3
zář 25
2297
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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