Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to override correctly point_of_sale.report_salelines?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
1 Odpowiedz
4657 Widoki
Awatar
Pascal Tremblay

Hello guy,

Trying to override the original point_of_sale.report_saleslines' to include a new docargs paperformat in my qweb report. 

The paperformat works in my qweb report.

But impossible to process lines like         <t t-esc="total_quantity(o)"/>   in my qweb report (because of o).

I'm pretty sure that I have a trouble with wrapped_report_class. But I don't understand how to manage it.

Here is my override :

class report_saleslines_pt(osv.AbstractModel):
    _name = 'report.point_of_sale.report_saleslines'
    _template = 'point_of_sale.report_saleslines'
    _inherit = 'report.abstract_report'
    _wrapped_report_class = None

    def render_html(self, cr, uid, ids, data=None, context=None):

        context = dict(context or {})

        paperformat_obj = context.get('chosenPaper')  #works well
        
        # If the key 'landscape' is present in data['form'], passing it into the context
        if data and data.get('form', {}).get('landscape'):
            context['landscape'] = True
        

        if context and context.get('active_ids'):

            # Browse the selected objects via their reference in context
            model = context.get('active_model') or context.get('model')
            objects_model = self.pool[model]
            objects = objects_model.browse(cr, uid, context['active_ids'], context=context)
        else:

            # If no context is set (for instance, during test execution), build one

            model = self.pool['report']._get_report_from_name(cr, uid, self._template).model

            objects_model = self.pool[model]
            objects = objects_model.browse(cr, uid, ids, context=context)
            context['active_model'] = model
            context['active_ids'] = ids
            
        # Generate the old style report
        
        wrapped_report = self._wrapped_report_class(cr, uid, '',  context=context)
        _logger.error('LAPAGEPT_CLASSES :: RENDER_HTML() %s %s', 'WRAPPED_REPORT :: ', wrapped_report)
        wrapped_report.set_context(objects, data, context['active_ids'])

        # Rendering self._template with the wrapped report instance localcontext as

        # rendering environment
        docargs = wrapped_report.localcontext
        docargs['docs'] = docargs.get('objects')

        # Used in template translation (see translate_doc method from report model)
        docargs['doc_ids'] = context['active_ids']
        docargs['doc_model'] = model
        docargs['paperformat'] = paperformat_obj

        return self.pool['report'].render(cr, uid, [], self._template, docargs, context=context)
    
report_saleslines_pt()

Here is the error. 

Traceback (most recent call last): File "/home/odoo-test/addons/report/controllers/main.py", line 122, in report_download response = self.report_routes(reportname, docids=docids, converter='pdf') File "/home/odoo-test/openerp/http.py", line 395, in response_wrap response = f(*args, **kw) File "/home/odoo-test/addons/report/controllers/main.py", line 65, in report_routes pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=options_data, context=context) File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report_lapagept/models/report_lapagept.py", line 134, in get_pdf html = self.get_html(cr, uid, ids, report_name, data=data, context=context) File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report_lapagept/models/report_lapagept.py", line 112, in get_html return particularreport_obj.render_html(cr, uid, ids, data=data, context=context) File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report_lapagept/lapagept_classes.py", line 80, in render_html wrapped_report = self._wrapped_report_class(cr, uid, '', context=context) TypeError: 'NoneType' object is not callable

0
Awatar
Odrzuć
Pascal Tremblay
Autor

should I also create a new parser class?

Pascal Tremblay
Autor

And if I would want to use the same wrapped_report_class than the original AbstractReport class (i.e. openerp.addons.point_of_sale.report.pos_lines.pos_lines)?

Awatar
Pascal Tremblay
Autor Najlepsza odpowiedź

It was not the good way to proceed.

Here is what we finally needed : An override of 'report.point_of_sale.report_saleslines'.

class pos_lines_pt(report_sxw.rml_parse):

    def __init__(self, cr, uid, name, context):
        super(pos_lines_pt, self).__init__(cr, uid, name, context=context)
        self.total = 0.0
        paperformat_obj = context.get('chosenPaper') #chosenPaper is defined by us somewhere else.

        self.localcontext.update({
            'time': time,
            'total_quantity': self.__total_quantity__,
            'taxes':self.__taxes__,
            'paperformat': paperformat_obj

        })
   

    def __total_quantity__(self, obj):
        tot = 0
        for line in obj.lines:
            tot += line.qty
        self.total = tot
        return self.total

    def __taxes__(self, obj):
        self.cr.execute ( " Select acct.name from pos_order as po " \
                              " LEFT JOIN pos_order_line as pol ON po.id = pol.order_id " \
                              " LEFT JOIN product_taxes_rel as ptr ON pol.product_id = ptr.prod_id " \
                              " LEFT JOIN account_tax as acct ON acct.id = ptr.tax_id " \
                              " WHERE pol.id = %s", (obj.id,))
        res=self.cr.fetchone()[0]
        return res


class report_pos_lines_pt(osv.AbstractModel):
    _name = 'report.point_of_sale.report_saleslines'
    _inherit = 'report.abstract_report'
    _template = 'point_of_sale.report_saleslines'
    _wrapped_report_class = pos_lines_pt

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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