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

Where are the 'vals' coming from?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
pythonparameters
1 Odpowiedz
7541 Widoki
Awatar
Yakito

Hello,

OK I really must post a disclaimer before asking because this is a really basic question but as I am learning python and OpenERP I can't seem to figure it out and its taking me forever.

I am trying to understand some custom code I requested from a developer. Basically what I need is to add some values to a variable called vals, but I look and I look and I can't find where is vals initially created or where it is getting its contents from.

Here is the code of the class I am working with:

class guest_amenities_vals(osv.osv):
    _name = "sim.guest_amenities_vals"
    _description = "GuestAmenitiesVals"
    _columns = {

        'name': fields.char('Name',required=True),
        'cols': fields.many2one('sim.resumen_wizard','Order Reference', required=True, ondelete='cascade', select=True),
        'price': fields.float('Price'),
        'period': fields.float('Period')
    }
    _defaults = {
        'price' : 0,
    }

    def create(self, cr, uid, vals, context=None):
        print vals
        print "------------"
        if 'cols' in vals and 'name' in vals:
            existing_recs = self.search(cr, uid, ['&',('cols','=',vals['cols']),('name','=',vals['name'])], context=context)
        if not existing_recs:
            return super(guest_amenities_vals, self).create(cr, uid, vals, context=context)
        else:
            ids = existing_recs[0]
            if ids:
                super(guest_amenities_vals, self).write(cr, uid,[ids], vals, context=context)
                print vals
                return ids

guest_amenities_vals()

From what I could debug the code gets executed when the user clicks on a 'Print' button from a wizard.

Vals has something like this {'price': 3000, 'name': 'b', 'cols': 116L}

What I am trying to do is also add the Period to vals so I can insert it into de DB

So the question is how would you look for were vals is initialized so I can pass the value of period to this class and insert it into the DB like the rest of the fields?

Please again excuse me if this is super basic. I spent a lot of time digging into the code and can't find it so any clue on where to look or what to look for will be deeply appreciated.

0
Awatar
Odrzuć
Prakash

Hi, vals is dictionary its contains Key and Value. Here Key is the field name of the table. Vals value coming from the form entered Field value. You can pass the value of period For example, vals['period'] = Your_value

Yakito
Autor

Oh! thats why I couldn't find it! (sorry, super new with python). So basically if I enter more fields in the form the values will appear in vals, right?

Prakash

Yes In the create methods vals contains table column name and value. If more fields added in shows in the vals

Awatar
aharoen
Najlepsza odpowiedź

You must inherit related view in your xml file that refer to "sim.guest_amenities_vals" model and add period field.

...
<field name="period"/>
...

Please read article(s) about inheriting openerp view for more explanation.

0
Awatar
Odrzuć
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ść
ValueError: SQL query parameters should be a tuple, list or dict
function python parameters
Awatar
0
mar 15
12391
new python env
python
Awatar
0
mar 25
2369
What means "Too many values to unpack" message? Rozwiązane
python
Awatar
Awatar
Awatar
Awatar
Awatar
4
kwi 24
175861
have no data in screen. read data in my own module from different model
python
Awatar
0
gru 23
2966
How to insert value to a one2many field in table with create method? Rozwiązane
python
Awatar
Awatar
Awatar
Awatar
Awatar
5
lip 25
232210
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