Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to correct a function onchange Odoo Community Version 12

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
functionurgentonchangeodooV12
4 Antworten
5542 Ansichten
Avatar
Ramla

Hi,

1- I want to recover the unit price and the unit of measurement of the product.

2- I want to compute : prix_total = quantite * prix_unitaire

Code py :

class ProductionVente(models.Model):
  _name = 'production.vente'
  _description ="Les ventes"
  _inherit = ['mail.thread']

  name = fields.Char(string='Référence', required=True, track_visibility='always')
  date = fields.Date(string='Date', required=True, track_visibility='onchange')
  client_id = fields.Many2one('res.partner', string='Client', required=True, track_visibility='onchange')
  article_id = fields.Many2one('product.product', string='Aliment', required=True, track_visibility='onchange')
  unite_mesure = fields.Char(string='Unité de mesure', readonly=True, compute='onchange_prix_unitaire_unite_mesure', track_visibility='onchange')
  quantite = fields.Integer(string='Quantité', required=True, track_visibility='onchange')
  prix_unitaire = fields.Float(string='Prix unitaire', readonly=True, compute='onchange_prix_unitaire_unite_mesure', track_visibility='onchange')
  prix_total = fields.Float(string='Prix total', readonly=True, compute='onchange_prix_total', track_visibility='onchange')
  cycle_id = fields.Many2one('production.cycle', string='Cycle', ondelete='cascade', readonly=True, track_visibility='onchange')
  
  _sql_constraints = [
('name_uniq', 'unique (name, date, client_id, article_id, cycle_id)', "La vente existe déjà !"),
]


  @ api.onchange ( 'article_id' )
  def onchange_prix_unitaire_unite_mesure ( self ):
    if self.article_id:
      a = self.env['product.product'].search([])
        self .prix_unitaire = a.lst_price
        self .unite_mesure = a.uom_id
  

  @ api.onchange ( 'quantite', 'prix_unitaire' )
  def onchange_prix_total ( self ):
    if self.quantite or self.prix_unitaire:
      self .prix_total = self.quantite * self.prix_unitaire


Erreur :

Erreur:

Odoo Server Error


Traceback (most recent call last):

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 757, in parse

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 662, in _tag_record

    record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3794, in _load_records

    data['record']._load_records_write(data['values'])

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3732, in _load_records_write

    self.write(values)

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_actions.py", line 66, in write

    res = super(IrActions, self).write(vals)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3269, in write

    self._write(store_vals)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3413, in _write

    self._validate_fields(vals)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 1108, in _validate_fields

    check(self)

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_actions.py", line 141, in _check_model

    raise ValidationError(_('Invalid model name %r in action definition.') % action.res_model)

odoo.exceptions.ValidationError: ("Nom de modèle 'production.vente' non valide dans la définition de l'action.", None)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 654, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 312, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\pycompat.py", line 87, in reraise

    raise value

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 696, in dispatch

    result = self._call_function(**self.params)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 344, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\service\model.py", line 97, in wrapper

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 337, in checked_call

    result = self.endpoint(*a, **kw)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 939, in __call__

    return self.method(*args, **kw)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 517, in response_wrap

    response = f(*args, **kw)

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\web\controllers\main.py", line 966, in call_button

    action = self._call_kw(model, method, args, {})

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\web\controllers\main.py", line 954, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 749, in call_kw

    return _call_kw_multi(method, model, args, kwargs)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 736, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "<decorator-gen-67>", line 2, in button_immediate_upgrade

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_module.py", line 73, in check_and_log

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

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_module.py", line 614, in button_immediate_upgrade

    return self._button_immediate_function(type(self).button_upgrade)

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_module.py", line 553, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\registry.py", line 86, in new

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 417, in load_modules

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 313, in load_marked_modules

    perform_checks=perform_checks, models_to_check=models_to_check

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 222, in load_module_graph

    load_data(cr, idref, mode, kind='data', package=package, report=report)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 68, in load_data

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 801, in convert_file

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 864, in convert_xml_import

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 754, in parse

    self.parse(rec, mode)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 763, in parse

    exc_info[2]

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 757, in parse

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

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 662, in _tag_record

    record = model.with_context(rec_context)._load_records([data], self.mode == 'update')

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3794, in _load_records

    data['record']._load_records_write(data['values'])

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3732, in _load_records_write

    self.write(values)

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_actions.py", line 66, in write

    res = super(IrActions, self).write(vals)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3269, in write

    self._write(store_vals)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3413, in _write

    self._validate_fields(vals)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 1108, in _validate_fields

    check(self)

  File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_actions.py", line 141, in _check_model

    raise ValidationError(_('Invalid model name %r in action definition.') % action.res_model)

odoo.tools.convert.ParseError: "Nom de modèle 'production.vente' non valide dans la définition de l'action.

None" while parsing file:/c:/program files (x86)/odoo 12.0/server/odoo/addons/production/views/cycle_views.xml:230, near

<record model="ir.actions.act_window" id="production_vente_list_action">

      <field name="name">Les ventes</field>

      <field name="context">{'default_cycle_id': active_id}</field>

      <field name="domain">[('cycle_id', '=', active_id)]</field>

      <field name="res_model">production.vente</field>

    </record>

-1
Avatar
Verwerfen
Ramla
Autor

class ProductionVente(models.Model):

_name = 'production.vente'

_description ="Les ventes"

_inherit = ['mail.thread']

name = fields.Char(string='Référence', required=True, track_visibility='always')

date = fields.Date(string='Date', required=True, track_visibility='onchange')

client_id = fields.Many2one('res.partner', string='Client', required=True, track_visibility='onchange')

article_id = fields.Many2one('product.product', string='Article', required=True, track_visibility='onchange')

#unite_mesure = fields.Char(string='Unité de mesure', store=True, related='article_id.uom_name', track_visibility='onchange')

quantite = fields.Integer(string='Quantité', required=True, track_visibility='onchange')

prix_unitaire = fields.Float(string='Prix unitaire', store=True, related='article_id.lst_price', track_visibility='onchange')

prix_total = fields.Float(string='Prix total', readonly=True, compute='onchange_prix_total', track_visibility='onchange')

cycle_id = fields.Many2one('production.cycle', string='Cycle', ondelete='cascade', readonly=True, track_visibility='onchange')

_sql_constraints = [

('name_uniq', 'unique (name, cycle_id)', "La référence de la vente existe déjà !"),

]

#Calculer le prix_total = quantite * prix_unitaire

@ api.onchange ( 'quantite', 'prix_unitaire' )

def onchange_prix_total ( self ):

if self.quantite or self.prix_unitaire:

self .prix_total = self.quantite * self.prix_unitaire

Avatar
Ramla
Autor Beste Antwort
class ProductionVente(models.Model):
  _name = 'production.vente'
  _description ="Les ventes"
  _inherit = ['mail.thread']

  name = fields.Char(string='Référence', required=True, track_visibility='always')
  date = fields.Date(string='Date', required=True, track_visibility='onchange')
  client_id = fields.Many2one('res.partner', string='Client', required=True, track_visibility='onchange')
  article_id = fields.Many2one('product.product', string='Article', required=True, track_visibility='onchange')
  #unite_mesure = fields.Char(string='Unité de mesure', store=True, related='article_id.uom_name', track_visibility='onchange')
  quantite = fields.Integer(string='Quantité', required=True, track_visibility='onchange')
  prix_unitaire = fields.Float(string='Prix unitaire', store=True, related='article_id.lst_price', track_visibility='onchange')
  prix_total = fields.Float(string='Prix total', readonly=True, compute='onchange_prix_total', track_visibility='onchange')
  cycle_id = fields.Many2one('production.cycle', string='Cycle', ondelete='cascade', readonly=True, track_visibility='onchange')
  
  _sql_constraints = [
('name_uniq', 'unique (name, cycle_id)', "La référence de la vente existe déjà !"),
]
  
  #Calculer le prix_total = quantite * prix_unitaire
  @ api.onchange ( 'quantite', 'prix_unitaire' )
  def onchange_prix_total ( self ):
    if self.quantite or self.prix_unitaire:
      self .prix_total = self.quantite * self.prix_unitaire
0
Avatar
Verwerfen
Avatar
Hilar Andikkadavath
Beste Antwort

Please restart your server or check your init file where the model is added or not. The error says the corresponding model is not found or loaded. Possibly it's not updated in your DB.

0
Avatar
Verwerfen
Avatar
SLIFE AFRICA
Beste Antwort

Hello,

1. Be sure to have imported your model python file in __.init__.py file

2.  If the import is done, make sure to don't have bad indentation in your model python file

Hoping that it can help you

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
How to correct the function onchange : compute age Odoo Community 12
function urgent onchange odooV12
Avatar
Avatar
Avatar
2
Mai 19
4422
How to correct a function onchange Odoo Community Version 12 Gelöst
function urgent onchange odooV12
Avatar
Avatar
Avatar
2
Apr. 19
4918
How to compute the sum of the values Odoo Community 12 ?
function urgent onchange compute odooV12
Avatar
Avatar
1
Apr. 19
5632
Function Onchange Odoo Community Version 12
function python urgent onchange odooV12
Avatar
0
Apr. 19
4431
How to create a function onchange Odoo Community Version 12 Gelöst
function python urgent odooV12
Avatar
Avatar
1
Apr. 19
9955
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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