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

How can I solve this AttributeError?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
objectattributeerror
6467 Widoki
Awatar
Barry Achterberg

Hello, I am editing the 'hr_timesheet_sheet' model and I am trying to create a method that changes the state of the workflow 'hr_timesheet_sheet'. When I click the button button_cancel, I want to call the method button_cancel, but it seems like it can't find my method however I defined it in hr_timesheet_sheet.py

When I click the button it says: AttributeError: 'hr_timesheet_sheet.sheet' object has no attribute 'button_cancel'.

I dont know what I am doing wrong since the button type="object" and the method is defined in hr_timesheet_sheet.py here is my code, maybe someone else can see why my method button_cancel isn't found or that my method is wrong defined. I Appreciate any help!

hr_timesheet_sheet_view.xml

<form string="Timesheet" version="7.0">
            <header>
                <button name="button_confirm" states="draft" string="Submit to Manager" type="object" class="oe_highlight"/>
                <button name="done" states="confirm" string="Approve" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
                <button name="action_set_to_draft" states="done" string="Set to Draft" type="object" class="oe_highlight"/>
                <button name="button_cancel" states="confirm" string="Refuse" type="object" class="oe_highlight"/>
                <field name="state" widget="statusbar" statusbar_visible="new,confirm,done"/>

hr_timesheet_sheet.py

def button_confirm(self, cr, uid, ids, context=None):
    for sheet in self.browse(cr, uid, ids, context=context):
        if sheet.employee_id and sheet.employee_id.parent_id and sheet.employee_id.parent_id.user_id:
            self.message_subscribe_users(cr, uid, [sheet.id], user_ids=[sheet.employee_id.parent_id.user_id.id], context=context)
        self.check_employee_attendance_state(cr, uid, sheet.id, context=context)
        di = sheet.user_id.company_id.timesheet_max_difference
        if (abs(sheet.total_difference) < di) or not di:
            wf_service = netsvc.LocalService("workflow")
            wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'confirm', cr)
        else:
            raise osv.except_osv(_('Warning!'), _('Please verify that the total difference of the sheet is lower than %.2f.') %(di,))
    return True

def button_cancel(self, cr, uid, ids):
    self.write(cr, uid, ids, {'state': 'draft'})
    return True

hr_timesheet_workflow.xml

<record id="wkf_timesheet" model="workflow">
        <field name="name">hr_timesheet_sheet.sheet</field>
        <field name="osv">hr_timesheet_sheet.sheet</field>
        <field name="on_create">True</field>
    </record>

    <record id="act_new" model="workflow.activity">
        <field name="wkf_id" ref="wkf_timesheet"/>
        <field name="name">new</field>
        <field name="kind">function</field>
        <field name="action">write({'state':'new'})</field>
        <field name="flow_start">True</field>
    </record>
    <record id="act_draft" model="workflow.activity">
        <field name="wkf_id" ref="wkf_timesheet"/>
        <field name="name">draft</field>
        <field name="kind">function</field>
        <field name="action">write({'state':'draft'})</field>
    </record>
    <record id="act_confirm" model="workflow.activity">
        <field name="wkf_id" ref="wkf_timesheet"/>
        <field name="name">confirm</field>
        <field name="kind">function</field>
        <field name="action">write({'state':'confirm'})</field>
    </record>
    <record id="act_done" model="workflow.activity">
        <field name="wkf_id" ref="wkf_timesheet"/>
        <field name="name">done</field>
        <field name="kind">function</field>
        <field name="action">write({'state':'done'})</field>
        <field name="flow_stop">True</field>
    </record>

    <record id="t0" model="workflow.transition">
        <field name="act_from" ref="act_new"/>
        <field name="act_to" ref="act_draft"/>
        <field name="group_id" ref="base.group_user"/>
    </record>
    <record id="t1" model="workflow.transition">
        <field name="act_from" ref="act_draft"/>
        <field name="act_to" ref="act_confirm"/>
        <field name="signal">confirm</field>
        <field name="group_id" ref="base.group_user"/>
    </record>
    <record id="t2" model="workflow.transition">
        <field name="act_from" ref="act_confirm"/>
        <field name="act_to" ref="act_done"/>
        <field name="signal">done</field>
        <field name="group_id" ref="base.group_user"/>
    </record>
    <record id="t3" model="workflow.transition">
        <field name="act_from" ref="act_confirm"/>
        <field name="act_to" ref="act_draft"/>
        <field name="signal">cancel</field>
        <field name="group_id" ref="base.group_user"/>
    </record>
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ść
[SOLVED] AttributeError: 'ir.model.fields' object has no attribute '_get_id' Rozwiązane
attributeerror
Awatar
Awatar
1
lut 23
13173
Odoo-v14.0 | AttributeError: 'super' object has no attribute 'home'
object attributeerror home customer_portal
Awatar
Awatar
1
maj 21
11413
How to solve "AttributeError: 'sale.order.line' object has no attribute 'product'" Rozwiązane
object attributeerror odoo9.0 v9.0
Awatar
2
mar 16
7577
AttributeError: 'int' object has no attribute 'id'
attributeerror
Awatar
0
gru 15
7203
How to find objects of a particular module?
object
Awatar
Awatar
Awatar
Awatar
3
mar 15
6951
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