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
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • 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
  • Help

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

Error: ("Invalid field %r on model %r" % (e.args[0], self._name)), adding existing one2many field to another view.

Odoberať

Get notified when there's activity on this post

This question has been flagged
one2manyapiv13
2 Replies
11353 Zobrazenia
Avatar
Jan Krähling

Hello,

I'm using Odoo 13 Community Edition.


In my case I need a routing for every product.

So to assign every routing to a product I created this field in my custom module for product.template:


class ProductTemplate(models.Model):

    _inherit = ['product.template']

 

    routing_id = fields.Many2one(

        'mrp.routing', 'Arbeitsplan', compute='_compute_routing_id')


    @api.depends('routing_id')

    def _compute_routing_id(self):

        for product in self:

            product.routing_id = self.env['mrp.routing'].search([('product_id','=',product.id)])




And in mrp.routing:


class MrpRouting(models.Model):

    _inherit = ['mrp.routing']


    product_id = fields.Many2one(

        'product.template', 'Produkt', required=True)


    @api.onchange('product_id')    

    def _onchange_product_id_name(self):

        self.name = self.product_id.name


(The onchange method because I made the name field invisible in the form view.)




Now I thought I could show the operation_ids field directly in the product.template form view.


So I also added the field to product.template in my custom module like the routing_id:

class ProductTemplate(models.Model):

    _inherit = ['product.template']

 

    operation_ids = fields.One2many(

        'mrp.routing.workcenter', 'routing_id', 'Operations',

        copy=True)


And in the form view:

        <record id="product_template_only_form_view_mgtec" model="ir.ui.view">

            <field name="name">product.template.product.form.mgtec</field>

            <field name="model">product.template</field>

            <field name="inherit_id" ref="product.product_template_only_form_view"/>

<field name="priority" eval="100"/>

            <field name="arch" type="xml">

<xpath expr="//page[@name='variants']" position="before">

<page string="Vorgänge" name="vorgaenge">

                        <field name="operation_ids" context="{'default_routing_id': routing_id}"/>

</page>

</xpath>

</field>

</record>




But when I want to change the operations in the product view and it opens the pop up form view from mrp.routing.workcenter to change the operations in the routing, I get an error and its like a never ending story like it needs every field from product.template/product.product in mrp.routing.


I searched for a method that could cause the errors, but i dont find any solution.


Thanks in advance.


The full error code:


Odoo Server Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5089, in _update_cache
    field_values = [(fields[name], value) for name, value in values.items()]
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5089, in <listcomp>
    field_values = [(fields[name], value) for name, value in values.items()]
KeyError: 'sale_delay'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 619, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 309, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\pycompat.py", line 14, in reraise
    raise value
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 664, in dispatch
    result = self._call_function(**self.params)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 345, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\service\model.py", line 93, in wrapper
    return f(dbname, *args, **kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 338, in checked_call
    result = self.endpoint(*a, **kw)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 909, in __call__
    return self.method(*args, **kw)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 510, in response_wrap
    response = f(*args, **kw)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1320, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1312, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 395, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 382, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 6030, in onchange
    record._update_cache(changed_values, validate=False)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5095, in _update_cache
    cache.set(self, field, field.convert_to_cache(value, self, validate))
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\fields.py", line 2393, in convert_to_cache
    id_ = record.env[self.comodel_name].new(value).id
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5432, in new
    record._update_cache(values, validate=False)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5091, in _update_cache
    raise ValueError("Invalid field %r on model %r" % (e.args[0], self._name))
ValueError: Invalid field 'sale_delay' on model 'mrp.routing'





0
Avatar
Zrušiť
Mostafa Barmshory

Did you fix this error?

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

Try to create inline tree/form view for operation_ids field:

<field name="operation_ids" context="{'default_routing_id': routing_id}">
<tree>
<field name=""/>
</tree>
<form>
<field name=""/>
</form>
</field>


2
Avatar
Zrušiť
Jan Krähling
Autor

Did not work, I'm still getting the same errors.

Avatar
Muneeb Alalfi
Best Answer

Any Idea guys ?!!
Please

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
Odoo API UID not working v13
api v13
Avatar
0
jan 20
4678
one2many update() vs self.env[]
one2many create api
Avatar
0
júl 21
4547
Hide field from the create view of one2many
one2many popup v13
Avatar
Avatar
1
sep 20
3626
How can I get a recordset with the records from a one2many relationship? v13
one2many recordset v13
Avatar
Avatar
1
dec 19
5677
fetch related models via web API
one2many api xmlrpc
Avatar
0
aug 16
4681
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