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
    • Discuss
    • 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

How to groupby related field in a search?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
searchgroup6.1groupby
10580 Tampilan
Avatar
Alejandro Santana

Hi!

I need to add a custom search in v6.1 for a customer (though I believe the same thing will happen in later versions).

I am trying to add a 'groupby' filter by Country, State, Zip and City in Account > Account > Statistic Reports > Invoice analysis (that is, in the account/report/account_invoice_report.py and account/report/account_invoice_report_view.xml)

I add the buttons correctly in the view, but when I try to filter 'groupby' with them, two differnt errors raise.

  • When trying to group_by country_id or state_id, I get:

 2014-05-27 11:26:14,469 6141 ERROR ? openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/osv.py", line 129, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/osv.py", line 195, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/osv.py", line 183, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/orm.py", line 2572, in read_group
    data_ids = self.search(cr, uid, [('id', 'in', alldata.keys())], order=order, context=context)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/orm.py", line 2251, in search
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/orm.py", line 4594, in _search
    order_by = self._generate_order_by(order, query)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/orm.py", line 4551, in _generate_order_by
    inner_clause = self._generate_m2o_order_by(order_field, query)
  File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/orm.py", line 4509, in _generate_m2o_order_by
    m2o_order = dest_model._order
AttributeError: 'NoneType' object has no attribute '_order'
2014-05-27 11:26:14,469 6141 ERROR ? openerp.netsvc: 'NoneType' object has no attribute '_order' 

  • When trying to group by Zip or City, it raises:

    Traceback (most recent call last):
      File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/osv.py", line 129, in wrapper
        return f(self, dbname, *args, **kwargs)
      File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/osv.py", line 195, in execute
        res = self.execute_cr(cr, uid, obj, method, *args, **kw)
      File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/osv.py", line 183, in execute_cr
        return getattr(object, method)(cr, uid, *args, **kw)
      File "/mnt/workZone/openerp/openerp_61_ocb_devel/ocb-server/openerp/osv/orm.py", line 2520, in read_group
        assert groupby_def and groupby_def._classic_write, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True"
    AssertionError: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True
    2014-05-27 11:26:07,990 6141 ERROR ? openerp.netsvc: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True

So... no related fields? Must I add fields (country_id, state_id, zip, city) to invoice object in order to be able to group by them? I don't really like it because it menas duplicate data, create an onchange for the invoice_address and override the create function, if I do not miss anything.

I paste the current code below:

class account_invoice_report(orm.Model):
    _inherit = "account.invoice.report"
    _columns = {
        'country_id': fields.many2one('res.partner.address.country_id', 'Country', readonly=True),
        'state_id': fields.many2one('res.partner.address.state_id', 'State', readonly=True),
        'zip': fields.many2one('res.partner.address.zip', 'Zip', readonly=True),
        'city': fields.many2one('res.partner.address.city', 'City', readonly=True),
#         'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
#         'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True),
#         'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True),
#         'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True),
    }
    _order = 'date desc'
    def init(self, cr):
        super(account_invoice_report, self).init(cr)

        tools.drop_view_if_exists(cr, 'account_invoice_report')
        cr.execute("""
            create or replace view account_invoice_report as (
                 select min(ail.id) as id,
                    ai.date_invoice as date,
                    to_char(ai.date_invoice, 'YYYY') as year,
                    to_char(ai.date_invoice, 'MM') as month,
                    to_char(ai.date_invoice, 'YYYY-MM-DD') as day,
                    ail.product_id,
                    ai.partner_id as partner_id,
                    ai.payment_term as payment_term,
                    ai.period_id as period_id,
                    (case when u.uom_type not in ('reference') then
                        (select name from product_uom where uom_type='reference' and active and category_id=u.category_id LIMIT 1)
                    else
                        u.name
                    end) as uom_name,
                    ai.currency_id as currency_id,
                    ai.journal_id as journal_id,
                    ai.fiscal_position as fiscal_position,
                    ai.user_id as user_id,
                    ai.company_id as company_id,
                    count(ail.*) as nbr,
                    ai.type as type,
                    ai.state,
                    pt.categ_id,
                    ai.date_due as date_due,
                    ai.address_contact_id as address_contact_id,
                    ai.address_invoice_id as address_invoice_id,
                    (select country_id from res_partner_address where id=address_invoice_id) as country_id,
                    (select state_id from res_partner_address where id=address_invoice_id) as state_id,
                    (select zip from res_partner_address where id=address_invoice_id) as zip,
                    (select city from res_partner_address where id=address_invoice_id) as city,
                    ai.account_id as account_id,
                    ail.account_id as account_line_id,
                    ai.partner_bank_id as partner_bank_id,
                    sum(case when ai.type in ('out_refund','in_invoice') then
                         -ail.quantity / u.factor
                        else
                         ail.quantity / u.factor
                        end) as product_qty,

                    sum(case when ai.type in ('out_refund','in_invoice') then
                         -ail.price_subtotal
                        else
                          ail.price_subtotal
                        end) / cr.rate as price_total,

                    (case when ai.type in ('out_refund','in_invoice') then
                      sum(-ail.price_subtotal)
                    else
                      sum(ail.price_subtotal)
                    end) / (CASE WHEN sum(ail.quantity/u.factor) <> 0
                       THEN
                         (case when ai.type in ('out_refund','in_invoice')
                          then sum(-ail.quantity/u.factor)
                          else sum(ail.quantity/u.factor) end)
                       ELSE 1
                       END)
                     / cr.rate as price_average,

                    cr.rate as currency_rate,
                    sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',ail.create_date)))/(24*60*60)::decimal(16,2)
                        from account_move_line as aml
                        WHERE ai.move_id=aml.move_id AND ail.product_id=aml.product_id AND ai.partner_id=aml.partner_id
                        )) as delay_to_pay,
                    (select extract(epoch from avg(date_trunc('day',ai.date_due)-date_trunc('day',ai.date_invoice)))/(24*60*60)::decimal(16,2)) as due_delay,
                    (case when ai.type in ('out_refund','in_invoice') then
                      -ai.residual
                    else
                      ai.residual
                    end)/ (CASE WHEN
                        (select count(l.id) from account_invoice_line as l
                         left join account_invoice as a ON (a.id=l.invoice_id)
                         where a.id=ai.id) <> 0
                       THEN
                        (select count(l.id) from account_invoice_line as l
                         left join account_invoice as a ON (a.id=l.invoice_id)
                         where a.id=ai.id)
                       ELSE 1
                       END) / cr.rate as residual
                from account_invoice_line as ail
                left join account_invoice as ai ON (ai.id=ail.invoice_id)
                left join product_product pr on (pr.id=ail.product_id)
                left join product_template pt on (pt.id=pr.product_tmpl_id)
                left join product_uom u on (u.id=ail.uos_id),
                res_currency_rate cr
                where cr.id in (select id from res_currency_rate cr2  where (cr2.currency_id = ai.currency_id)
                and ((ai.date_invoice is not null and cr.name <= ai.date_invoice) or (ai.date_invoice is null and cr.name <= NOW())) limit 1)
                group by ail.product_id,
                    ai.date_invoice,
                    ai.id,
                    cr.rate,
                    to_char(ai.date_invoice, 'YYYY'),
                    to_char(ai.date_invoice, 'MM'),
                    to_char(ai.date_invoice, 'YYYY-MM-DD'),
                    ai.partner_id,
                    ai.payment_term,
                    ai.period_id,
                    u.name,
                    ai.currency_id,
                    ai.journal_id,
                    ai.fiscal_position,
                    ai.user_id,
                    ai.company_id,
                    ai.type,
                    ai.state,
                    pt.categ_id,
                    ai.date_due,
                    ai.address_contact_id,
                    ai.address_invoice_id,
                    country_id,
                    state_id,
                    zip,
                    city,
                    ai.account_id,
                    ail.account_id,
                    ai.partner_bank_id,
                    ai.residual,
                    ai.amount_total,
                    u.uom_type,
                    u.category_id
            )
        """)

account_invoice_report()

0
Avatar
Buang
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
[V10] custom Group by Diselesaikan
treeview search group groupby search_view
Avatar
Avatar
Avatar
2
Mei 17
8811
[V10] custom Group related field
search group tree_view related_fields
Avatar
Avatar
3
Mei 17
4900
How to hide the Search View Custom Filters, Advanced Search, and Add to Dashboard for a user group
search group groups openerp7 searchview
Avatar
0
Mar 25
6803
How to hide the search view for a user group?
views user search hide group
Avatar
0
Mei 15
6277
Customize by views inheritance Stock.picking.out search view v7 Diselesaikan
filter views v7 search groupby
Avatar
Avatar
1
Mar 15
5977
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