Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

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

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
qwebreportingconditionalloopodoov11
1 Відповісти
8401 Переглядів
Аватар
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
Аватар
Відмінити
Аватар
Muhammad Anees
Найкраща відповідь

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
Аватар
Відмінити
Abdullah
Автор

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
Автор

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
Автор

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

Abdullah
Автор

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
Автор

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
Автор

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
Автор

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
Автор

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!

Реєстрація
Related Posts Відповіді Переглядів Дія
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
Аватар
0
лист. 19
4042
Report for Product move list view in inventory module.(Odoo v11) Вирішено
qweb inventory reporting reports odoov11
Аватар
Аватар
Аватар
4
серп. 20
6059
Get values of controller into another controller (odoo v11)
web qweb reporting controllers odoov11
Аватар
0
лист. 19
4086
How can I display all tasks (including completed ones) in a QWeb report in Odoo?
qweb reporting
Аватар
Аватар
2
вер. 24
3219
Loop through a group list with Qweb in Odoo17 Вирішено
qweb loop
Аватар
Аватар
2
бер. 24
2392
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція 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