Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

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

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
one2manyapiv13
2 Réponses
11350 Vues
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
Ignorer
Mostafa Barmshory

Did you fix this error?

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Meilleure réponse

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
Ignorer
Jan Krähling
Auteur

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

Avatar
Muneeb Alalfi
Meilleure réponse

Any Idea guys ?!!
Please

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo API UID not working v13
api v13
Avatar
0
janv. 20
4673
one2many update() vs self.env[]
one2many create api
Avatar
0
juil. 21
4543
Hide field from the create view of one2many
one2many popup v13
Avatar
Avatar
1
sept. 20
3621
How can I get a recordset with the records from a one2many relationship? v13
one2many recordset v13
Avatar
Avatar
1
déc. 19
5674
fetch related models via web API
one2many api xmlrpc
Avatar
0
août 16
4679
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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