Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • 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:

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

odoo 8 qweb foreach array

Subscribe

Get notified when there's activity on this post

This question has been flagged
odoo8
4 Replies
9295 Views
Avatar
Nischal

using the below code, i want to display unique packages and not duplicate them. But still i have one package gets duplicated if result_package_id is same for first and last iteration of pack_operation_ids. Is there a way to save all the result_package_id in a array and then match it in every loop of pack_operation_ids

            <?xml version="1.0"?>

            <t t-name="stock.report_picking_packaging">

            <t t-call="report.html_container">

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

            <t t-set="prev" t-value="0" />

            <p> <t t-esc="prev"/><b>Prev: </b></p>

              <tr t-foreach="o.pack_operation_ids" t-as="n">

              <t t-set="new" t-value="n.result_package_id" />

                 <p><t t-esc="new"/><b>new: </b></p>

                 <p t-if="new != prev"><b>Package name: </b><span t-field="n.result_package_id"/></p>

                 <t t-set="prev" t-value="n.result_package_id" />

                <p> <t t-esc="prev"/><b>Prev: </b></p>

           <br/>

            </tr>

           </t>

          </t>

           </t>


below is the display

0Prev:

stock.quant.package(21,)new:

Package name: BOX0018

stock.quant.package(21,)Prev:

stock.quant.package(20,)new:

Package name: BOX0017

stock.quant.package(20,)Prev:

stock.quant.package(20,)new:

stock.quant.package(20,)Prev:

stock.quant.package(19,)new:

Package name: BOX0016

stock.quant.package(19,)Prev:

stock.quant.package(19,)new:

stock.quant.package(19,)Prev:

stock.quant.package(21,)new:

Package name: BOX0018

stock.quant.package(21,)Prev:




 Working code, help from Jaydeep Barot.

                   <t t-name="stock.report_picking_packaging">

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

                  <t t-call="report.html_container">

                 <h1>PACKAGES</h1>

                     <table class="table table-condensed" t-if="o.pack_operation_ids">

                     <thead>

                       <tr>

                       <th><strong>Package Name</strong></th>

                        </tr>

                       </thead>

                      <tbody>

                      <t t-set="package" t-value="list(set([ pack.result_package_id for pack in o.pack_operation_ids if                      pack.result_package_id]))"/>

                         <tr t-foreach="package" t-as="p">

                         <td><span t-esc="p.name"/>

                               <p><b>Package size (LXWXH): </b><span t-field="p.length"/><b>X</b><span t-field="p.width"/><b>X</b><span t-field="p.height"/></p>

                                 <p><b>Package net_weight: </b><span t-field="p.total_estim_weight_net"/><b>Package gross_weight: </b>                                    <span t-field="p.total_estim_weight"/></p>

                                      </td>

                                   <tr t-foreach="p.quant_ids" t-as="q">

                                    <td><p><b>Product Inside: </b><span t-field="q.product_id"/><b>Product Qty: </b><span t-field="q.qty"/>                                      </p></td>

                                     </tr>

                                       </tr>

                                     </tbody>

                                      </table>

                              </t>

                              </t>

                               </t>

0
Avatar
Discard
Nischal
Author

with help from Jaydeep Barot, i got below code to work, which might help others looking for help

PACKAGES

Package Name

Package size (LXWXH): XX

Package net_weight: Package gross_weight:

Product Inside: Product Qty:

Nischal
Author

PACKAGES

Package Name

Package size (LXWXH): XX

Package net_weight: Package gross_weight:

Product Inside: Product Qty:

Avatar
Jaydeep Barot (jar)
Best Answer

Hello Nischal,

Using this code :

<?xml version="1.0"?>

<t t-name="stock.report_picking_packaging">

<t t-call="report.html_container">

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

<t t-set="prev" t-value="0" />

<p> <t t-esc="prev"/><b>Prev: </b></p>

<tr t-foreach="o.pack_operation_ids" t-as="n">

<t t-set="new" t-value="n.result_package_id.id" />

<p><t t-esc="new"/><b>new: </b></p>

<p t-if="new != prev"><b>Package name: </b><span t-field="n.result_package_id"/></p>

<t t-set="prev" t-value="n.result_package_id.id" />

<p> <t t-esc="prev"/><b>Prev: </b></p>

<br/>

</tr>

</t>

</t>

</t>


It's display below: 

==============

0Prev:

21 new:

Package name: BOX0018

21 Prev:

20 new:

Package name: BOX0017

20 Prev:

19 new:

Package name: BOX0016

19 Prev:

21 new:

Package name: BOX0018

21 Prev:



=========================================

Here is remove duplicate packages.

=========================================

<h1>PACKAGES</h1>

<table class="table table-condensed" t-if="o.pack_operation_ids">

<thead>

<tr>

<th><strong>Package Name</strong></th>

</tr>

</thead>

<tbody>

<t t-set="package" t-value="list(set([ pack.result_package_id for pack in o.pack_operation_ids if pack.result_package_id]))"/>

<tr t-foreach="package" t-as="p">

<td><span t-esc="p.name"/></td>

</tr>

</tbody>

</table>

2
Avatar
Discard
Nischal
Author

Dear jaydeep, I dont want to display the same package twice, for e.g BOX0018. the system does that because of the multiple operations performed with the same package(BOX) and reports it in sequence as performed. While reporting i want it to display the package once but the content inside should be shown below the BOX.

Nischal
Author

Thanks Jaydeep, using the your updated code i was able to achieve what i was looking for. comment updated

Avatar
Zbik
Best Answer

Try like this:

<t t-set="FOO" t-value="[1, 2, 3, 1, 2, 5, 1, 5, 6, 7, 8]"/>
<t t-foreach="o.loop_ids" t-as="n">
...
<t t-esc="FOO.append(n.id)"/>
</t>
Result without duplicates: <t t-esc="list(set(FOO))"/>

UPDATED:

<t t-set="FOOX" t-value="list(set(FOO))"/>
<t t-foreach="FOOX" t-as="x">
<t t-esc="x"/>
</t>


If appended ids 328,329, result = [1, 2, 3, 5, 6, 7, 8, 328, 329]


0
Avatar
Discard
Nischal
Author

Thanks Zbik, I tried the code below but it gives me same result Box0018 gets duplicated. Did i do something wrong. or should i use the output resulting id's in next iteration(but how) Also if you can please explain me the t-value used in this solution

Prev:

ops_ids:

new:

Package name:

Prev:


Result without duplicates:
Zbik

t-value is only for example. In the real solution you should use t-value="[]" and FOO ids in next iteration.

Nischal
Author

Thanks Zbik, But how to use the FOO ids as o.pack_operation_ids in next iteration? it gives me error if i use FOO insted of o.pack_operation_ids.

Zbik

Answer updated with example

Nischal
Author

Dear Zbik, I still fail to understand how to use the appended ids available(my apologies as i am not a developer).. The pack_operation_ids gives me value like "stock.pack.operation(id,)" but is just a number(i.e the id). i am not able to use it in the next iteration.

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

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

Sign up
Related Posts Replies Views Activity
Selecting items for one2many relation Solved
odoo8
Avatar
Avatar
Avatar
2
दिस॰ 22
15780
How to upload files automatically on attachments on button click ?
odoo8
Avatar
Avatar
1
नव॰ 21
5877
Field company_registry missing in partner table
odoo8
Avatar
0
जन॰ 21
3042
How I disable Import Button for certain model in odoo8? Solved
odoo8
Avatar
Avatar
Avatar
Avatar
Avatar
8
मई 20
8841
why blank page with top menu only visible after login? odoo 8
odoo8
Avatar
0
दिस॰ 23
3598
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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