Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to define onchange method ? odooV8

Subscriure's

Get notified when there's activity on this post

This question has been flagged
invoicemethodonchange
2 Respostes
6271 Vistes
Avatar
Ajeng Shilvie

How can i make it ?

i make a custome module , the fields are :

many2one invoice_id(refer to customer invoice number), 

many2one order_line (refer to account.invoice.line, the invoice number same as selected invoice_id)

many2one customer_id(refer to partner_id in customer invoice that has the same number as selected item in invoice_id field),and

address field(refer to customer's address in selected invoice_id too)

here's the code :

class faktur(osv.osv):
    _name = 'permohonan.faktur'
    _columns = {

        ''invoice_id': fields.many2one('account.invoice',string='Invoice',domain=[('state','=','paid'),('type','=','out_invoice')],required=True),

        'order_line': fields.many2one('account.invoice.line', string='Order Line', required=True),
        'customer_id': fields.many2one('res.partner', string='Customer',required=True),
        'address': fields.char('Address',23),
    }

here is xml code :

record model="ir.ui.view" id="permohonan_faktur_form_view">
    <field name="name">permohonan.faktur.form</field>
    <field name="model">permohonan.faktur</field>
    <field name="arch" type="xml">
        <form string="Form Permohonan Faktur STNK" version="7.0">
        <group col="2" string="Permohonan Faktur STNK">
            <group >
                <field name="invoice_id" context="{'form_view_ref':'account.invoice_form'}"/>
                <field name="order_line" />
                <field name="customer_id"/>
                <field name="address"/>
              </group>
           </group>
        </form>
    </field>
</record>

i want address and customer_id field onchange when i select invoice_id , i want order_line value defend on selected invoice number..

1
Avatar
Descartar
Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

@Ajeng

You can try the following for onchange method in odoov8

To use the following way.. you need import the following and inherit it

from openerp import models,fields,api

class faktur (models.Model)

@api.onchange('invoice_id')
def onchange_invoice_id(self):
    if self.invoice_id:
    """Your code goes here"""
    """finally"""
    self.customer_id = <some partner id based on your code>
    self.address= <some address id based on your code>

Note: I don't understand why are you using "many2one" for "order_line", because there could be more than one invoice line against an invoice.

But in case you want to load only those invoice line based on the selected invoice_id than you can apply the following domain in your view:

<field name="order_line" domain="[('invoice_id','=',invoice_id)]" />

1
Avatar
Descartar
Avatar
Ajeng Shilvie
Autor Best Answer

@Emipro

the domain for "order_line" it worked, thank you.

but i am sorry, i am new in odoo.. i don't understand using @api, do i have to use class faktur (models.Model) instead class faktur(osv.osv) ??

 

0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
How to run this query on form loading?
invoice onchange
Avatar
Avatar
Avatar
2
de març 15
4458
Tax update from backend (code) in invoice. onchanges doesnt work. calculations doesnt refresh Solved
invoice onchange Odoo13.0
Avatar
Avatar
2
de febr. 23
5211
Odoo 14 @api.onchange from a field of another class Solved
invoice onchange invoice.line
Avatar
Avatar
1
de gen. 22
4894
Override Onchange Method : onchange_partner_id on account_voucher [v7]
v7 method onchange override
Avatar
Avatar
Avatar
5
d’abr. 17
8327
Error on argument list when extend onchange method
method onchange override account.invoice.line
Avatar
Avatar
1
de març 15
6424
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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