Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
qwebreportingconditionalloopodoov11
1 Odpoveď
8400 Zobrazenia
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
Zrušiť
Avatar
Muhammad Anees
Best Answer

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
Zrušiť
Abdullah
Autor

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
Autor

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
Autor

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

Abdullah
Autor

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
Autor

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
Autor

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
Autor

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
Autor

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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
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
4040
Report for Product move list view in inventory module.(Odoo v11) Solved
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 Solved
qweb loop
Avatar
Avatar
2
mar 24
2389
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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