Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

I try to inherit function and it fails odoo8

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
timesheetbuttonsattachementodoo8.0
4 Replies
5855 Tampilan
Avatar
wizardz

I try to inherit this button in hr.timesheet.sheet.form:

<button  class="oe_inline oe_stat_button" name="attachment_tree_view"  type="object" icon="fa-files-o">
<field string="Documents" name="doc_count" widget="statinfo"/>
</button>

On my python I have this:

class project(osv.osv):
_inherit = "project.project"
def test(self, cr, uid, vals, context=None):
return super(project.project, self)._get_attached_docs(cr, uid, vals, context=context)
_columns = {
'doc_count': fields.function(
test, string="Number of documents attached", type='integer'
)
}

Now I get all time an error. What am I making wrong with the import of the function get_attached_docs ? How can I import this simple function to my field? and then put it on the button?


I want this 2 buttons from project.project on the hr.timesheet.sheet form with the same links behind that in project:



0
Avatar
Buang
Avatar
Juan Vicente Pascual
Jawaban Terbai

In your .py file you have to define the function that is called by the button "attachment_tree_view"

EDITED:

class project(osv.osv):
 _inherit = "project.project"

 def test(self, cr, uid, vals, context=None):
return super(project.project, self)._get_attached_docs(cr, uid, vals, context=context)

def attachment_tree_view(self,cr,uid,ids,context):
tasks_ids = self.pool.get(project.task).search(cr,uid,[('project_id','in',ids)])
domain = ['|','&',('res_model','=','project.project'),('res_id','in', ids),
'&',('res_model','=','project.project'),('res_id','in', task_ids)]
res_id = ids and ids[0] or False
return {
'name':_('Attachments'),
'domain': domain,
'res_model', 'ir.attachment',
'type': 'ir.actions-act_window',
'view_id': False,
'view_mode': 'kanban,tree,form',
'view_type': 'form',
'limit': 80,
'context': "{'default_res_model':'%s','default_res_id':%d}" % (self._name, res_id)
}
 _columns = {
 'doc_count': fields.function(test, string="Number of documents attached",type='integer')
 }

...


With this you inherit original function, now just modify as you need (remember to set super if you modify before or after the original functions returns the values).


Kind regards.

1
Avatar
Buang
wizardz
Penulis

How can I inherit this function from project.project - project.py to my module ?

Juan Vicente Pascual

I've modified my answer. see if this fits your needs.

wizardz
Penulis

How Can I display that in the hr.timesheet.sheet view? I want the button there, not in project.project. :)

Avatar
wizardz
Penulis Jawaban Terbai

I try to make this 2 buttons on the hr.timesheet.sheet view. 

My hr_timesheet.py looks like this:

# -*- coding: utf-8 -*- import openerp from openerp.osv import fields, osv

class hr_timesheet_sheet(osv.osv): _inherit = ["hr_timesheet_sheet.sheet"] _columns = { 'testfield1': fields.char(''), 'project_field': fields.many2one('project.project', 'name'), }

class project(osv.osv): _inherit = "project.project" def test(self, cr, uid, vals, context=None): return super(project.project, self)._get_attached_docs(cr, uid, vals, context=context) def attachment_tree_view(self, cr, uid, ids, context): task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)]) domain = [ '|', '&', ('res_model', '=', 'project.project'), ('res_id', 'in', ids), '&', ('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)] res_id = ids and ids[0] or False return { 'name': _('Attachments'), 'domain': domain, 'res_model': 'ir.attachment', 'type': 'ir.actions.act_window', 'view_id': False, 'view_mode': 'kanban,tree,form', 'view_type': 'form', 'limit': 80, 'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id) }

_columns = { 'doc_count': fields.function(test, string="Number of documents attached",type='integer') }

My XML file like this: hr_timesheet_view_test.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>         <record id="hr_timesheet_sheet_tree_test_buttons" model="ir.ui.view"> <field name="name">hr.test.button.tree</field> <field name="model">hr_timesheet_sheet.sheet</field> <field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/> <!-- "hr_presence.hr_timesheet_sheet_form_presence" --> <field name="arch" type="xml"> <xpath expr="//notebook" position="before"> <button class="oe_inline oe_stat_button" name="attachment_tree_view" type="object" icon="fa-files-o"> <field string="Documents" name="doc_count" widget="statinfo"/>                        </button>                     </xpath>             </field>         </record>     </data> </openerp>


This is not working , I get the error that the field : doc_count does not exist.

0
Avatar
Buang
Juan Vicente Pascual

in your py file, you define field doc_count for model 'project.project'

in ypur view you have set model hr_timesheet_sheet.sheet

Kind regards.

wizardz
Penulis

now when I try to install that I get this error: attendance_count does not exist.

I don't have a field like that.

If I change the model in view to project.project it give me this error. I want this button in the timesheet view.

Juan Vicente Pascual

in py.file remove 'project.project' inherited class and define doc_count and the functions in hr_timesheet_sheet class.

the modify functions to match your requeriments.

kind regards.

wizardz
Penulis

I have made that but it's not working . I don't understand how I can use this buttons in an other model view.

Juan Vicente Pascual

you have to redefine, the views and py files in your model.

wizardz
Penulis

make the hr_timesheet.py to project.py ?

and make the hr_timesheet_view_test.xml to project_view.xml?

wizardz
Penulis

please can you give me the right example that this works...

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Sending an email with the employee's timesheet by clicking button 'confirm'
email timesheet odoo8.0
Avatar
0
Sep 19
5164
How to make timesheet creation monthly in odoo 8 Diselesaikan
hr timesheet odoo8.0
Avatar
Avatar
1
Nov 16
4271
How can I hide a <button ?
hide buttons odoo8.0
Avatar
Avatar
2
Jul 16
5398
_inherits questions
timesheet inherits odoo8.0
Avatar
Avatar
1
Jun 16
3856
_inherits = "hr_timesheet_sheet" question , how to import in a new navigation button at the top bar.
timesheet inherits odoo8.0
Avatar
0
Jun 16
4320
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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