Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Problems saving context after passing a value through popup

Odoberať

Get notified when there's activity on this post

This question has been flagged
contextpython2.7odooV9
1 Odpoveď
6475 Zobrazenia
Avatar
Nicolás Mena

I'm passing value from model A to model view trough context parameter in the xml view, but when I save the record created on model B the value passed through context isn't saved, here's my code:


Model A view.xml [extract]

<notebook>
    <page string="Etiquetas">
        <field name="tag_ids" context="{'feature_id':feature_id}"/>
    </page>
</notebook>

Model A 

from openerp import models,fields,api
from openerp.exceptions import ValidationError
class version(models.Model):
        _name           =   "version"
        _rec_name       =   "description"
        description     =   fields.Char(size=4,string="Descripción")
        feature_id      =   fields.Many2one('feature', string="Característica")
        father_feature_id   =   fields.Many2one(related="feature_id.father_id",store=True)
        tag_ids         =   fields.One2many('tag','version_id',string="Etiquetas", ondelete="cascade")


Model B

from openerp import models,fields,api
from openerp.osv.fields import related
class tag(models.Model):
        _name           =   "tag"
        _rec_name       =   "label"
        _order          =   "sequence"
        
        label           =   fields.Char(required=True,size=50,string="Etiqueta")
        version_id      =   fields.Many2one('version',required=True,string="Versión")
        feature_id      =   fields.Many2one('feature',string="Característica",store=True)
        alternative_id  =   fields.Many2one('alternative',required=True,string="Alternativa",domain="[('feature_id','=',feature_id)]")
        father_feature_rel     =   fields.Many2one(related="feature_id.father_id")
        father_id       =   fields.Many2one('tag',string="Padre",domain="[('feature_id','=',father_feature_rel)]")
        sequence        =   fields.Integer(default=0,string="Secuencia")

        

I've tried to filter using a related field in Model B but doesn't work because the context passed isn't saved into model.

0
Avatar
Zrušiť
Avatar
Nicolás Mena
Autor Best Answer

Solved my problem using this on form

<notebook>
    <page string="Etiquetas">
        <field name="tag_ids" context="{'default_feature_id':feature_id}"/>
    </page>
</notebook>

And removing the store attribute on the modelB.feature_id field because isn't a computed field, and will be stored and not recomputed when the field gets a value, in this case obtained by context.

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to add fixed tax automatically in invoice
python2.7 odooV9
Avatar
Avatar
Avatar
2
júl 22
6616
how to create a access rule to limit product creation for sale managers?
python2.7 odooV9
Avatar
Avatar
Avatar
2
júl 21
7016
How can I setup Tax so that I can charge on the TOTAL Invoice amount, then on the Products, then a Stamp Tax.
python2.7 odooV9
Avatar
0
júl 18
3485
how to resolve errorhow to resolve this error " 'product.template' has no attribute 'generate_ean13' ?? Solved
python2.7 odooV9
Avatar
Avatar
1
máj 18
10169
AttributeError: 'int' object has no attribute 'id' on odoo 9
python2.7 odooV9
Avatar
Avatar
1
júl 17
11212
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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