Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

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

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
one2manyapiv13
2 Replies
11351 Rodiniai
Portretas
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
Portretas
Atmesti
Mostafa Barmshory

Did you fix this error?

Portretas
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
Portretas
Atmesti
Jan Krähling
Autorius

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

Portretas
Muneeb Alalfi
Best Answer

Any Idea guys ?!!
Please

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Odoo API UID not working v13
api v13
Portretas
0
saus. 20
4673
one2many update() vs self.env[]
one2many create api
Portretas
0
liep. 21
4545
Hide field from the create view of one2many
one2many popup v13
Portretas
Portretas
1
rugs. 20
3622
How can I get a recordset with the records from a one2many relationship? v13
one2many recordset v13
Portretas
Portretas
1
gruod. 19
5674
fetch related models via web API
one2many api xmlrpc
Portretas
0
rugp. 16
4680
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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