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

Accessing child field from many2many_tags in picking view

Odebírat

Get notified when there's activity on this post

This question has been flagged
pickingserial_numbercolorsmany2many_tagschildclass
2 Odpovědi
189 Zobrazení
Avatar
Benjamin ROCHE

Hi,

I created a new Many2one field called grade on the stock.lot model. The grade model contains several fields, one of which is a color field:

color = fields.Integer(string="Color")

My goal is to display serial numbers with different colors in the picking view.

I tried to modify the many2many_tags widget in stock.view_picking_form using XPath to add a color_field option:

<xpath expr="//field[@name='lot_ids']" position="attributes"> <attribute name="options"> {'create': [('parent.use_create_lots', '=', True)], 'color_field': 'product_grade_id.color'} </attribute> </xpath>

However, it seems many2many_tags cannot access a child field (product_grade_id.color) directly.

As a workaround I added a related field on stock.lot that copies the grade color:

grade_color = fields.Integer( related="product_grade_id.color", string="Grade color", readonly=True, )

This works, but feels like a workaround. Is there a way to make many2many_tags use the child field directly, or a better pattern to achieve colored serial numbers in the picking view?

Thanks in advance for any suggestions.

0
Avatar
Zrušit
Codesphere Tech

Hello,
The many2many_tags widget can only use fields that exist directly on the same model. It seems adding a related field is the correct solution.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

Hi,


The many2many_tags widget in Odoo expects the color_field option to reference a direct field of the target model (in this case, stock.lot).

It cannot traverse relations like product_grade_id.color because the widget operates client-side in the web view and doesn’t perform nested record fetching, it just uses what’s directly in the record’s dataset.


Try the following,


Python


class StockLot(models.Model):

    _inherit = "stock.lot"


    product_grade_id = fields.Many2one('product.grade', string="Grade")

    grade_color = fields.Integer(

        related="product_grade_id.color",

        string="Grade color",

        store=True,  

        readonly=True,

    )


XML


<xpath expr="//field[@name='lot_ids']" position="attributes">

    <attribute name="options">

        {'create': [('parent.use_create_lots', '=', True)], 'color_field': 'grade_color'}

    </attribute>

</xpath>


Hope it helps


1
Avatar
Zrušit
Avatar
Benjamin ROCHE
Autor Nejlepší odpověď

Thank you for your answers, I understand the workaround I have implemented is the way to do with the current limitation of the many2many_tags

0
Avatar
Zrušit
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
Picking process with serial numbers
picking serial_number
Avatar
Avatar
Avatar
Avatar
3
kvě 24
4456
How can I specify unique serial numbers for the same product during incoming shipment registration in v8 Vyřešeno
v8 picking unique serial_number
Avatar
Avatar
2
bře 15
5256
Inventory transactions - select only available Lots
inventory lot picking serial_number delivery_order
Avatar
0
lis 18
5011
Disable auto-assign of Serial Numbers to Sales Order Operations
serial_number
Avatar
Avatar
Avatar
3
čvn 25
2463
order picking form doesn't aggregate order lines
picking
Avatar
Avatar
Avatar
3
lis 23
3096
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