Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

onchange method not working

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
v7sale.order.formonchange
3 Odpowiedzi
15060 Widoki
Awatar
Sam path

Hi all,

I've created a masters for a terms and conditions. My-module.py

class tc_name(osv.osv): _name = 'tc.name'

def name_get(self, cr, uid, ids, context=None):
  res = []
  for code_obj in self.browse(cr, uid, ids, context=context):
      tc_name = code_obj.tc_name
      res.append((code_obj.id, tc_name))
  return res

_columns = {
            'tc_name': fields.char('Terms & Condition', size=150),
            'tc_desc': fields.text('Description')
            }

tc_name()

my_module.xml

<record id="view_tc_name_form" model="ir.ui.view">
    <field name="name">view.tc.name.form</field>
    <field name="model">tc.name</field>
    <field name="arch" type="xml">
        <form string="Terms and Conditions" version="7.0">
            <sheet>
                <group>
                    <group>
                        <field name="tc_name" strin="Terms and Condition" required="True"/>
                        <field name="tc_desc" required="True"/>
                    </group>
                </group>
            </sheet>
        </form>
    </field>
</record>

<record id="view_tc_name_tree" model="ir.ui.view">
    <field name="name">view.tc.name.tree</field>
    <field name="model">tc.name</field>
    <field name="arch" type="xml">
        <tree string="Terms and Conditions" version="7.0">
            <field name="tc_name" string="Terms and conditions"/>
        </tree>
    </field>
</record>

<record id="action_tc_name" model="ir.actions.act_window">
    <field name="name">Terms and Conditions</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">tc.name</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="view_id" ref="view_tc_name_tree"/>
</record>

<menuitem id="menu_tc_name_config" action="action_tc_name" name="Terms and Conditions" parent="base.menu_base_config" sequence="6"/>

this is working fine.

  • my_module.py

class extra_fields(osv.osv):

_inherit = "sale.order"
_columns = {
    'tc_name': fields.many2one('tc.name','Terms and Condition'),
    'tc_desc': fields.text('Description')
    }

def onchange_tc_name(self, cr, uid, ids, tc_name):
    v={}
    if tc_name:
        tc = self.pool.get('tc.name').browse(cr, uid, tc_name)
        v['tc_desc'] = tc.tc_desc
        return{'value':v}

my_module.xml

<record model="ir.ui.view" id="extra_fields_sale_order">
    <field name="name">sale.order.form</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form" />
    <field name="arch" type="xml">
        <group name='sale_total' position='after'>
            <group string="Terms and Conditions">
                <field name="tc_name" string="T & C" widget="selection" onchange="onchange_tc_name(tc_name, tc_desc, context)"/>
                <field name="tc_desc" string="Description"/>
            </group>
        </group>
    </field>
</record>

The master wosks fine and even it pull downs in sale order view but the onchange method does'nt work. I need the description of the terms and condition master to populate one the description field in sale order on change of terms and condition selected. Can anyone help me out?

0
Awatar
Odrzuć
Sam path
Autor

Sorry i forgot to mention another thing can I edit the description field on sale order view after the onchange method executes

Awatar
René Schuster
Najlepsza odpowiedź

In your .xml file use on_change="..." attribute instead of onchange="...".

Also, follow the advise of senthil and double check your function parameters.

Regards.

post scriptum: Yes, you can change the description field. But whenever you change tc_name the on_change method will be triggered and replace the description.

3
Awatar
Odrzuć
Sam path
Autor

Thanks a lot Rene it worked for me..!

Sam path
Autor

Hi Rene, I have an another issue can you please help me out in that. The link is http://help.openerp.com/question/51091/filter-on-many2many-fields

Awatar
Jagdish Panchal
Najlepsza odpowiedź

HI,

Try this code

def onchange_tc_name(self, cr, uid, ids, tc_name):
    v={}
    if tc_name:
        tc_name_id = self.pool.get('tc.name').search(cr, uid,[('tc_name','=',tc_name)])
        for tc_name_data in self.pool.get('tc.name').browse(cr, uid, c_name_id):
            v = { 'tc_desc': tc_name_data.tc_desc}

    return{'value':v}
1
Awatar
Odrzuć
Senthilnathan

i think both v['tc_desc'] = tc.tc_desc & v = { 'tc_desc': tc.tc_desc}

Sam path
Autor

It doesn't work i tried both your answer but the data doesn't fetches.

Jagdish Panchal

I have update answer pls try it.

Awatar
Senthilnathan
Najlepsza odpowiedź

I think parameter problem

def onchange_tc_name(self, cr, uid, ids, tc_name):

See you have only one paramter in the py file

and try to pass three parameters

<field name="tc_name" string="T & C" widget="selection" on_change="onchange_tc_name(tc_name, tc_desc, context)"/>

Change it like this and check

<field name="tc_name" string="T & C" widget="selection" on_change="onchange_tc_name(tc_name)"/>

If there is problem again check ur server log post it here

1
Awatar
Odrzuć
Sam path
Autor

this doesn't work but there is no error displayed

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Preventing On change recursion
v7 onchange
Awatar
1
mar 15
6259
In the onchange function the readonly fields are not working
v7 readonly onchange
Awatar
Awatar
1
mar 15
8897
on_change inside linked one2many class
one2many v7 onchange
Awatar
Awatar
1
mar 15
5266
How to trigger function on object write? Rozwiązane
addon v7 orm onchange
Awatar
Awatar
Awatar
Awatar
4
cze 20
27992
How to edit sales.order.form to work with inline editing in the product grid?
product v7 sale.order.form grid
Awatar
Awatar
1
maj 17
10581
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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