Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

odoo v11 (Qweb) how to store data in a variable after looping so that you could compare it

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
qwebreportingconditionalloopodoov11
1 Svar
8397 Visninger
Avatar
Abdullah

Here is simple loop which i am using


<t t-foreach="docs" t-as="o">
<td colspan="2">
<span t-field="o.vendor" />
</td>
</t>
As this i a report of tree view i want to check if a vendor name is printed before it must not print again. So how to do that?
0
Avatar
Kassér
Avatar
Muhammad Anees
Bedste svar

See the code. I declared a variable total like t-set="total"

<tr>
  <td class="col-xs-6 bg-light">Total</td> 
<td class="col-xs-6 text-center">  
<t t-set="total" t-value="o.per_diem + o.housing_deduction + o.equivalent_air_ticket + o.airport_parking"/> 
<t t-esc="total" t-options='{"widget": "float", "precision": 2}'/>       
</td> 
</tr>
1
Avatar
Kassér
Abdullah
Forfatter

hello sir thanks for replying you are really a teacher for me :D Just one question how would you check if the value of o.per_diem which you printed in the first line is repeating itself or not

Muhammad Anees

Repeating means? Its in a loop <t t-foreach="docs" t-as="o"> print it in the foreach loop or outside.

Use if like <span t-field="o.per_diem" />

Muhammad Anees

<t t-if="o.per_diem>100">

<span t-field="o.city" />

</t>

Abdullah
Forfatter

Sir i have tree view as you know i select lines and print them and it shows me the comparison of different prices quoted by the vendor for different products. But for each product vendor name prints itself again. I want to see in the selected lines that if vendor's name is same as before then it must not print again

Muhammad Anees

You need group by vendor.. here is an example

https://www.odoo.com/forum/help-1/question/how-to-group-by-product-category-in-qweb-report-102920

Abdullah
Forfatter

Thank you sir i will try and let you know in a moment. You are always a big help

Abdullah
Forfatter

sir this is giving me this error " 'str' object has no attribute 'vendor'"

i am using following code as you have suggested

<t t-set="vendor_list" t-value="[]"/>

<t t-foreach="docs" t-as="o">

<t t-set="vendor_list" t-value="vendor_list+[o.vendor]"/>

</t>

<t t-foreach="set(vendor_list)" t-as="category">

<div><strong t-esc="category.vendor"/></div>

<t t-foreach="docs" t-as="o">

<t t-if="category.vendor==o.vendor">

<div><span t-field="o.vendor"/></div>

</t>

</t>

</t>

Please dont get irritated as i am bothering you again and again but kindly help me for this last time

Muhammad Anees

Share your custom model code here...what fields it has. What is relation with res_partner?

Abdullah
Forfatter

i am fetching data from the data base so i have made partner too as a Char field

class PostgresReport(models.Model):

_name = 'purchase.comp'

_auto = False

name = fields.Char(string = 'Purchase Order')

origin = fields.Char(string ='Purchase Agreement')

date_order = fields.Datetime('Order Date', index=True, copy=False)

state = fields.Selection([

('draft', 'RFQ'),

('sent', 'RFQ Sent'),

('to approve', 'To Approve'),

('purchase', 'Purchase Order'),

('done', 'Locked'),

('cancel', 'Cancelled')

], string='Status', readonly=True, index=True, copy=False, default='draft', track_visibility='onchange')

requisition_id = fields.Char(string='requisition_id')

product_id = fields.Char(string='Product')

product_qty = fields.Float(string='Quantity')

price_unit = fields.Float(string='Unit Price')

price_subtotal = fields.Float(string='Subtotal')

vendor = fields.Char(string='Vendor')

currency_id = fields.Char('Currency')

@api.model_cr

def init(self, _logger=None):

""" Event Question main report """

query = []

tools.drop_view_if_exists(self._cr, 'purchase_comp')

view = self._cr.execute(""" CREATE VIEW purchase_comp AS (

SELECT

b.id as id,

a.name as "name",

a.origin as "origin",

a.requisition_id as "requisition_id",

a.date_order as "date_order",

a.state as "state",

b.name as "product_id",

b.order_id as "order_id",

b.product_qty as "product_qty",

b.price_unit as "price_unit",

b.price_subtotal as "price_subtotal",

c.display_name as "vendor",

d.name as "currency_id"

FROM public.purchase_order as a

inner join

public.purchase_order_line as b

on a.id = b.order_id

inner join

public.res_partner as c

on a.partner_id = c.id

inner join

public.res_currency as d

on d.id = b.currency_id

WHERE a.origin != ''

order by a.name

)""")

Muhammad Anees

The code you shared is for Odoo Business Intelligence where you select measures and analyze data, like lot of odoo standard reports. But the report that you are trying to develop is a simple PDF report.

Abdullah
Forfatter

so i cannot group it by vendor in qweb? Not possible?

Muhammad Anees

Try to group by in your above sql query like order by vendor.... Test your sql query in postgresql to get your required results.

Abdullah
Forfatter

sir i have tried that all and i am able to remove duplicates from the report by using this

<t t-set="product_names" t-value="[]"/>

<t t-foreach="docs" t-as="o">

<t t-set="product_names" t-value="product_names+[o.product_id]"/>

</t>

<t t-foreach="set(product_names)" t-as="bat">

<tr class="row2">

<td>

<span t-field="bat.id" />

<span t-field="bat.name" />

</td>

</tr>

</t>

But this code works for Many2one field only and i have float fields as well so m at a dead end now.

Abdullah
Forfatter

sir can you tell what this means?

sale_order_id = request.session.get('sale_last_order_id')

i found this is website_sale module in controller.

I also have a report made from controller which opens in website. If i somehow able to download it in pdf my work will be done. if you know any work around for downloading pdf from website

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

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
odoo (v11) how to start a loop and put a condition in it to check if a variable is repeating and it is repeating then it must not print
qweb reporting conditional loop odoov11
Avatar
0
nov. 19
4037
Report for Product move list view in inventory module.(Odoo v11) Løst
qweb inventory reporting reports odoov11
Avatar
Avatar
Avatar
4
aug. 20
6057
Get values of controller into another controller (odoo v11)
web qweb reporting controllers odoov11
Avatar
0
nov. 19
4084
How can I display all tasks (including completed ones) in a QWeb report in Odoo?
qweb reporting
Avatar
Avatar
2
sep. 24
3218
Loop through a group list with Qweb in Odoo17 Løst
qweb loop
Avatar
Avatar
2
mar. 24
2388
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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