Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How to override the onchange_product_tmpl_id with new api?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
apiinheritonchangeoverride
3 Răspunsuri
7972 Vizualizări
Imagine profil
Stefano Del Gobbo

Hi,

I'm new to Odoo, and I need to override a existing method.

What i need is to insert new lines on Bill Of Material tree, on changing product template id. 

There are just a method on mrp_bom class, called onchange_product_tmpl_id, so according with what i understood, i need to inherit the mrp_bom class in a new class, and override the onchange_product_tmpl_id method with a new one.

How can I override the method with new api (the old super() in OpenERP) and fire the onchange method when ai change the product template id?

Something like that:

class bom_template(models.Model):

    _inherit = 'mrp.bom'

    @api.onchange

    def _populate_bom_lines(self):

        lines =[]

        for val in self.bom_template: #value on a BOM template that cointain products
        line_item = {
                      'attr1': val.name,
                      'attr2': val.a1,
                      ...                             
                }
        lines += [line_item]
    self.update({'line': lines})

0
Imagine profil
Abandonează
Imagine profil
Rihene
Cel mai bun răspuns

Hello my friend;

here is some useful links:

http://odoo-new-api-guide-line.readthedocs.org/en/latest/decorator.html#api-onchange

https://www.odoo.com/documentation/8.0/reference/orm.html

and here is an example:

Python:

def on_change_prix_id(self, cr, uid, ids,list_price, prix_vente_minimum, context=None): 

if list_price < prix_vente_minimum:

My_error_Msg = 'Attention!! Votre Prix de vente est inférieur au prix de vente minimum'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return True 

else:

return True

XML:

<field name="list_price" on_change="on_change_prix_id(list_price, prix_vente_minimum)">

Best Regards.

1
Imagine profil
Abandonează
Imagine profil
Temur
Cel mai bun răspuns

https://www.odoo.com/forum/help-1/question/93941 

0
Imagine profil
Abandonează
Imagine profil
Anton Chepurov
Cel mai bun răspuns

 https://www.odoo.com/forum/help-1/question/solved-inherit-onchange-old-api-vs-new-75299

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Change purchase order lines with @api.onchange()? Rezolvat
many2one api inherit onchange onchange_event
Imagine profil
Imagine profil
Imagine profil
3
iun. 19
8331
How to override onchange old api vs new ? Rezolvat
v7 api onchange override v8.0
Imagine profil
7
ian. 24
15894
API 8.0 onchange() and depends() decorators only work for UI changes and 1 record only?
api onchange
Imagine profil
Imagine profil
1
iun. 15
5927
How to create chained selection fields in Odoo using API data?
api selection onchange
Imagine profil
Imagine profil
1
oct. 25
651
Return multiple domain modification from one onchange()
api onchange domains
Imagine profil
Imagine profil
Imagine profil
2
apr. 25
3739
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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