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 while trying to create new field for sale subscription

S'inscrire

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

Cette question a été signalée
moduleserrorfieldssubscriptionconstraints
2 Réponses
5123 Vues
Avatar
arthur

Hello, 

I am trying to add a new field to the subscription module, to then display it on the subscription form view. However, I am getting an error while trying to update my module in order to insert the new field.

Here is my model code:

class SaleSubscription(models.Model):
    _inherit = 'sale.subscription'
    actual_next_delivery_date= fields.Date(string='Data da próxima entrega', default=fields.Date.today, help="Data da próxima entrega.")


And here is the .xml file:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="raizs_subscription_additional" model="sale.subscription">
            <field name="name">actual_next_delivery_date</field>
        </record>
    </data>
</odoo>


The error thrown is the following:

2019-01-07 19:36:21,496 9183 ERROR RaizsOdoo werkzeug: Error on request:

Traceback (most recent call last):

  File "/home/arthur/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 177, in run_wsgi

    execute(self.server.app)

  File "/home/arthur/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 165, in execute

    application_iter = app(environ, start_response)

  File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 260, in app

    return self.app(e, s)

  File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 166, in application

    return application_unproxied(environ, start_response)

  File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 154, in application_unproxied

    result = handler(environ, start_response)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 1318, in __call__

    return self.dispatch(environ, start_response)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 1292, in __call__

    return self.app(environ, start_wrapped)

  File "/home/arthur/.local/lib/python3.5/site-packages/werkzeug/wsgi.py", line 588, in __call__

    return self.app(environ, start_response)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 1473, in dispatch

    odoo.registry(db).check_signaling()

  File "/usr/lib/python3/dist-packages/odoo/__init__.py", line 76, in registry

    return modules.registry.Registry(database_name)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 61, in __new__

    return cls.new(db_name)

  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 85, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 376, in load_modules

    force, status, report, loaded_modules, update_module, models_to_check)

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 274, in load_marked_modules

    perform_checks=perform_checks, models_to_check=models_to_check

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 181, in load_module_graph

    _load_data(cr, module_name, idref, mode, kind='data')

  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 95, in _load_data

    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 791, in convert_file

    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 852, in convert_xml_import

    obj.parse(doc.getroot(), mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 741, in parse

    self.parse(rec, mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 751, in parse

    exc_info[2]

  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 744, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 654, in _tag_record

    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)

  File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_model.py", line 1488, in _update

    record = record.create(values)

  File "/usr/lib/python3/dist-packages/odoo/addons/sale_subscription/models/sale_subscription.py", line 208, in create

    subscription = super(SaleSubscription, self).create(vals)

  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 236, in create

    thread = super(MailThread, self).create(values)

  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3372, in create

    record = self.browse(self._create(old_vals))

  File "/usr/lib/python3/dist-packages/odoo/models.py", line 3465, in _create

    cr.execute(query, tuple(u[2] for u in updates if len(u) > 2))

  File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 155, in wrapper

    return f(self, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 232, in execute

    res = self._obj.execute(query, params)

odoo.tools.convert.ParseError: "null value in column "partner_id" violates not-null constraint

DETAIL:  Failing row contains (253, actual_next_delivery_date, SUB253, draft, null, 1, null, 2019-01-07, null, null, 2019-01-07, null, null, null, null, null, null, null, null, 96e542d3-9c15-42d4-8895-511d1549cfb8, null, null, null, 1, 2019-01-07 19:36:21.228204, 1, 2019-01-07 19:36:21.228204, null, null, null, null, null, null, null, null, null, 2019-01-07).

" while parsing /home/arthur/theVelopment/raizs/raizs/vtex_subscription/views/subscriptions_fields.xml:4, near

<record id="raizs_subscription_additional" model="sale.subscription">

<field name="name">actual_next_delivery_date</field>

</record>


Any idea on what I am missing here?

Thanks in advance!


0
Avatar
Ignorer
Avatar
Ray Carnes (ray)
Meilleure réponse

Your XML file is actually trying to create a new sale.subscription record and failing because you need another value, the partner_id.  You are telling Odoo that the name of the subscription is actual_next_delivery_date because that's the value you are sending to the name field.

Once you have added the field to the model (via Python) you need to add it to a VIEW via View Inheritance.

Your record tag needs to modify an existing ir.ui.view record rather than add a new sale.subscription record.

Take a look at the documentation, or some existing modules, to learn how to do this.

https://www.odoo.com/documentation/12.0/howtos/backend.html#view-inheritance

3
Avatar
Ignorer
Avatar
arthur
Auteur Meilleure réponse

I missed the first part of the error, which is:

RaizsOdoo odoo.sql_db: bad query: b'INSERT INTO "sale_subscription" ("id", "uuid", "actual_next_delivery_date", "recurring_next_date", "date_start", "name", "state", "code", "company_id", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval(\'sale_subscription_id_seq\'), \'76e9f278-657e-44dd-b77a-46644b0df9bc\', \'2019-01-07\', \'2019-01-07\', \'2019-01-07\', \'actual_next_delivery_date\', \'draft\', \'SUB252\', 1, 1, 1, (now() at time zone \'UTC\'), (now() at time zone \'UTC\')) RETURNING id'

ERROR: null value in column "partner_id" violates not-null constraint

DETAIL:  Failing row contains (252, actual_next_delivery_date, SUB252, draft, null, 1, null, 2019-01-07, null, null, 2019-01-07, null, null, null, null, null, null, null, null, 76e9f278-657e-44dd-b77a-46644b0df9bc, null, null, null, 1, 2019-01-07 19:36:20.214084, 1, 2019-01-07 19:36:20.214084, null, null, null, null, null, null, null, null, null, 2019-01-07).


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é
Field does not exist error on inherited view Résolu
modules error fields inherit
Avatar
Avatar
Avatar
Avatar
8
juin 18
49758
odoo custom modul update problem Résolu
modules error fields install odoo10
Avatar
Avatar
Avatar
7
oct. 18
11676
I cannot create a new database after paying subscription
error subscription
Avatar
Avatar
1
déc. 23
2974
No module named pooler Résolu
modules error
Avatar
Avatar
Avatar
Avatar
Avatar
5
déc. 23
20327
invalid module names, ignored: invreport Résolu
modules error importing
Avatar
Avatar
1
avr. 25
2084
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