Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Retrieving all records from a table with mako templates

Subscribe

Get notified when there's activity on this post

This question has been flagged
webkitmakoreports
5061 Views
Avatar
Santiago J. Said

Hi folks, I want to know how can i get all records of a table from my openerp 7 with mako templates(to show it in my report). As far I know, in my mako template i have an iterable called objects which is a browse_record(suri.flete.items_recorrida, 1).

My question is how can i get all the records of the table "suri.flete.items_recorrida", and then only show in the report the items which values en_recorrida and finalizado are False.

In my mako template(flete_rep_webkit.mako):

    %for item in objects:
        <tr>
            <td>${item.descripcion}</td>
            <td>${item.origen.nombre}(${item.origen.direccion},${item.origen.localidad})</td>
            <td>${item.destino.nombre}, (${item.destino.direccion},${item.destino.localidad})</td>
        </tr>
    %endfor

In my parser .py file(flete_webkit.py)

import time
from report import report_sxw
from osv import osv

class flete_webkit(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(flete_webkit, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'cr':cr,
            'uid': uid,
        })        

report_sxw.report_sxw('report.webkit.flete_items_recorrida',
                           'suri.flete.items_recorrida', 
                           '/suri/flete/report/flete_rep_webkit.mako',
                           parser=flete_webkit)

In my view

<report auto="False" id="flete_webkit" model="suri.flete.items_recorrida" name="webkit.flete"  file="suri/flete/report/flete_rep_webkit.mako" string="Reporte prueba" report_type="webkit" />

In my .py file (flete.py)

class items_recorrida(osv.osv):        
    _name = "suri.flete.items_recorrida"
    _columns = {
        'name' : fields.related('descripcion', 'name', type="many2one", relation="suri.flete.items_recorrida", string='Descripcion',context="{'form_view_ref' : 'suri.flete.formulario_flete_items_recorrida', 'tree_view_ref' : 'suri.flete.arbol_flete_items_recorrida'}"),
        'estado' : fields.boolean('Estado', required=True),
        'descripcion' : fields.char('Descripcion', size=128, required = True),
        'documentacion' : fields.char('Documentacion', size=128, required = False),
        'origen': fields.many2one('res.partner.sedes','Origen', required=True),#FK->res.partner.sedes
        'destino': fields.many2one('res.partner.sedes','Destino', required=True),#FK->res.partner.sedes
        'pedido_por': fields.many2one('res.users','Pedido por', required=True),#FK->res.users
        'id_flete': fields.many2one('suri.flete.recorrida','Numero de flete',required=False),#FK->suri.flete.recorrida        
        'nota': fields.char('Nota',size=128,required=False),
        'proyecto': fields.many2one('suri.proyectos.proyecto','Proyecto',required=False),#FK->suri.proyectos.proyecto
        'dimension': fields.char('Dimension Estimada', size=128, required = False),
        'peso': fields.char('Peso Estimado', size=128, required = False),
        'fragil': fields.boolean('Es fragil?', required=False),
        'urgente': fields.boolean('Es urgente?', required=False),
        'en_recorrida': fields.boolean('Esta en recorrida?', required=False,),
        'finalizado': fields.boolean('Esta finalizado?', required=False,) 
    }

    _defaults = {
    'en_recorrida' : False,
    'finalizado' : False,      
    }

    _rec_name = 'descripcion'

Thanks in advance.

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

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

Sign up
Related Posts Replies Views Activity
Missing headers in webkit/mako report PDFs Solved
webkit mako reports
Avatar
Avatar
Avatar
Avatar
3
Mar 15
12147
Images in webkit / mako pdf reports Solved
webkit mako
Avatar
Avatar
Avatar
Avatar
4
Sep 16
9090
how to use dynamic file name for webkit report?
webkit reports
Avatar
0
Mar 15
4626
How do I limit an iteration in Mako?
webkit mako
Avatar
Avatar
1
Mar 15
5877
how to use dynamic file name for webkit report?
webkit reports
Avatar
0
Mar 15
3913
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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