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č

Limit the pivot report between 2 dates with wizard

Naroči se

Get notified when there's activity on this post

This question has been flagged
wizardreportpivotodoo12
3658 Prikazi
Avatar
Jakub Parcheta

Hi, 

It takes too long to generate the report because there are to many data.


I created a wizard with start_date and finish_date and I would like to know how to limit the report between both dates.


Wizard .py:

class GetDatesWizard(models.TransientModel):

    _name = 'get.dates.wizard'


    start_date = fields.Date("Start date")

    stop_date = fields.Date("Stop date")


    def create_report(self):

        return {

            'name': 'generate report',

            'type': 'ir.actions.act_window',

            'res_model': 'irco.nutri.report.costeplatos',

            'view_mode': 'pivot',

        }


Wizard .xml:

    <record id="view_get_dates_wizard" model="ir.ui.view">

        <field name="name">view.get.dates.wizard</field>

        <field name="model">get.dates.wizard</field>

        <field name="arch" type="xml">

            <form>

                <group>

                    <field name="start_date"/>

                    <field name="stop_date"/>

                </group>

                <footer>

                    <button name="create_report" type="object" string="Create" class="oe_highlight"/>

                    <button name="cancel" string="Cancel" special="cancel" class="oe_link"/>

                </footer>

            </form>

        </field>

    </record>


Report .py:

class CostPlateReport(models.Model):

    _name = "cost.plate.report"

    _order = 'date desc'


    partner = fields.Many2one('res.partner','Client')

    date = fields.Date('Date')

    plate = fields.Char('Plato')

    cost = fields.Float('Cost')


    def _query(self, with_clause='', fields={}, groupby='', from_clause=''):

        with_ = ("WITH %s" % with_clause) if with_clause else ""


        select_ = """

            min(m.id) as id,

            m.date as date,

            m.partner as partner,

            pt.name as plate,

            pc.cost as cost

        """  

        for field in fields.values(): 

            select_ += field


        from_ = """

                irco_menu m

                    join irco_menu_plates p on (p.plate_menu_id=m.id)

                        join res_partner r on (r.id=p.partner)

                        join product_template pt on (p.plate_ids=pt.id)

                            join irco_plate_cost pc on (pc.product_template_id=pt.id)

                            join product_product pp on (pp.product_tmpl_id=pt.id)

                %s

        """ % from_clause


        groupby_ = """

            m.id,

            m.date,

            m.partner,

            pt.name,

            pc.cost

            %s

        """ % (groupby)


        return "%s (SELECT %s FROM %s WHERE m.state = 'done' GROUP BY %s)" % (with_, select_, from_, groupby_)


    @api.model_cr

    def init(self):

        tools.drop_view_if_exists(self.env.cr, self._table)

        self.env.cr.execute("""CREATE or REPLACE VIEW %s as (%s)""" % (self._table, self._query()))


Report .xml:

    <record id="view_cost_plate_report" model="ir.ui.view">

         <field name="name">view.cost.plate.report</field>

         <field name="model">cost.plate.report</field>

         <field name="arch" type="xml">

             <pivot string="Cost Analysis" disable_linking="True">

                 <field name="date" interval="month" type="row"/>

                <field name="cost" type="measure"/>

             </pivot>

         </field>

    </record>

0
Avatar
Opusti
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
Limit the report between 2 dates with wizard
wizard report pivot odoo12
Avatar
0
jan. 21
42
How to pass wizard data to report.py?
wizard pivot odoo12
Avatar
0
jan. 21
4009
Change PDF report name on wizard
wizard report
Avatar
Avatar
2
jul. 24
4102
Blank report PDF from Wizard Solved
wizard report
Avatar
Avatar
2
apr. 24
3629
Change string in <report/>
report odoo12
Avatar
Avatar
Avatar
Avatar
3
dec. 20
3824
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