İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Generate report from Python by given user and data range

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
pythonreportingodooV8
1 Cevapla
7026 Görünümler
Avatar
Marcus

I need to generate timesheets report for a given user in a given data range.
I also need to sum the timesheets hours by date so each row in the report has unique date.

I have simple report ready as well as wizard for picking particular user and dates. But I'm having trouble with passing data to the report. When I click the print button on my wizard I get this error:

ProgrammingError: relation "hr_timesheet_karty_wizard" does not exist
LINE 1: INSERT INTO "hr_timesheet_karty_wizard" ("id", "date_from", ...

I'm not really sure what to do with `records`. Should I put them in 'doc_ids' or 'doc_ids'?

I'm also not sure how to sum the records by date.

I'm using Odoo 8.


Here is my python code:

from openerp import api, models, fields
from datetime import datetime

class hr_timesheet_karty_wizard(models.AbstractModel):
    _name = 'hr.timesheet.karty.wizard'
    
    employee_id = fields.Many2one(comodel_name="hr.employee", required=True)
    date_from = fields.Date(default=fields.Datetime.now, required=True)
    date_to = fields.Date(default=fields.Datetime.now, required=True)

    @api.multi
    def print_report(self, data=None):
        
        records = self.env['hr.analytic.timesheet'].search([('employee_id', '=', self.employee_id),('date_from', '>=', self.date_from),('date_to', '<=', self.date_to)])   
        # sum records hours if date is the same (group by date)

        report_obj = self.env['report']
        report = report_obj._get_report_from_name('hr_timesheet_karty.template_hr_timesheet_karty')
        docargs = {
            'doc_ids': self._ids,
            'doc_model': report.model,
            'docs': records,
        }
        return report_obj.render('hr_timesheet_karty.template_hr_timesheet_karty', docargs)



Here is my wizard:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>

    <record id="view_hr_timesheet_karty_wizard" model="ir.ui.view">
        <field name="name">hr.timesheet.karty.wizard.form</field>
        <field name="model">hr.timesheet.karty.wizard</field>
        <field name="arch" type="xml">
        <form string="Leaves by Department">
            <group>
                <field name="employee_id"/>
                <field name="date_from"/>
                <field name="date_to"/>
            </group>
            <footer>
                <button name="print_report" string="Print" type="object" class="oe_highlight"/> or
                <button string="Cancel" special="cancel" class="oe_link"/>
            </footer>
        </form>
        </field>
    </record>

    <record id="action_hr_timesheet_karty_wizard" model="ir.actions.act_window">
        <field name="name">Time sheet report</field>
        <field name="res_model">hr.timesheet.karty.wizard</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_hr_timesheet_karty_wizard"/>
        <field name="target">new</field>
    </record>

    <menuitem id="menu_hr_timesheet_karty_wizard"
        name="Time sheet report"
        parent="hr.menu_hr_reporting_timesheet"
        action="action_hr_timesheet_karty_wizard"
        sequence="1"
        icon="STOCK_PRINT"/>
        
  </data>
</openerp>



And here is my report:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <report
        id="action_hr_timesheet_karty"
        string="Time sheet report"
        model="hr.analytic.timesheet"
        report_type="qweb-pdf"
        name="hr_timesheet_karty.template_report_hr_timesheet_karty"
    />
        
    <template id="template_hr_timesheet_karty">
        <t t-call="report.html_container">
            <t t-call="report.external_layout">
                <div class="page">

                    <table class="table table-condensed">
                        <thead>
                            <tr>
                                <th>User</th>
                                <th>Date</th>
                                <th>Time</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr t-foreach="docs" t-as="o">
                                <td><span t-field="o.user_id.name"/></td>
                                <td><span t-field="o.date"/></td>
                                <td class="text-right"><span t-field="o.unit_amount"/> h</td>
                            </tr>
                        </tbody>
                    </table>

                </div>

            </t>
        </t>
    </template>

  </data>
</openerp>



Please help


0
Avatar
Vazgeç
Avatar
Jainesh Shah(Aktiv Software)
En İyi Yanıt

Hello Andrzej,

In v8 , AbstractModel model define with osv.AbstractModel 

Please find following example of AbstractModel:

class hr_timesheet_karty_wizard(osv.AbstractModel)


For searching timesheet records, 

sheet_obj = self.pool['hr.analytic.timesheet']

sheet_ids = sheet_obj.search(cr, uid,

            [('employee_id', '=', self.employee_id),

            ('date_from', '>=', self.date_from),

           ('date_to', '<=', self.date_to)])

Can you please try above object for found timesheet records ?

Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   ​

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
[8.0]How to confirm an element's state from: action_confirm (MRP_REPAIR)
python odooV8
Avatar
1
May 21
4955
Odoo8 - Custom pdf name when printing
reporting odooV8
Avatar
Avatar
1
Nis 20
4066
How to save data in readonly field in openerp?
python odooV8
Avatar
Avatar
Avatar
Avatar
4
Eki 19
10864
How to multiply sequence by non-int Çözüldü
python odooV8
Avatar
Avatar
1
Oca 18
10294
Employee commission in salary rules
python odooV8
Avatar
Avatar
1
Şub 17
5958
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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