Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

I try to inherit function and it fails odoo8

Naroči se

Get notified when there's activity on this post

This question has been flagged
timesheetbuttonsattachementodoo8.0
4 Odgovori
5854 Prikazi
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
Opusti
Avatar
Juan Vicente Pascual
Best Answer

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
Opusti
wizardz
Avtor

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
Avtor

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

Avatar
wizardz
Avtor Best Answer

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
Opusti
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
Avtor

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
Avtor

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
Avtor

make the hr_timesheet.py to project.py ?

and make the hr_timesheet_view_test.xml to project_view.xml?

wizardz
Avtor

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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Sending an email with the employee's timesheet by clicking button 'confirm'
email timesheet odoo8.0
Avatar
0
sep. 19
5162
How to make timesheet creation monthly in odoo 8 Solved
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
5397
_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
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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