Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

How can I solve this AttributeError?

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
objectattributeerror
6464 Lượt xem
Ảnh đại diện
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
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
[SOLVED] AttributeError: 'ir.model.fields' object has no attribute '_get_id' Đã xử lý
attributeerror
Ảnh đại diện
Ảnh đại diện
1
thg 2 23
13172
Odoo-v14.0 | AttributeError: 'super' object has no attribute 'home'
object attributeerror home customer_portal
Ảnh đại diện
Ảnh đại diện
1
thg 5 21
11412
How to solve "AttributeError: 'sale.order.line' object has no attribute 'product'" Đã xử lý
object attributeerror odoo9.0 v9.0
Ảnh đại diện
2
thg 3 16
7577
AttributeError: 'int' object has no attribute 'id'
attributeerror
Ảnh đại diện
0
thg 12 15
7203
How to find objects of a particular module?
object
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
3
thg 3 15
6949
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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