Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

t-foreach not working on POS template screen

Odebírat

Get notified when there's activity on this post

This question has been flagged
javascriptposxmltemplateowl
2 Odpovědi
4178 Zobrazení
Avatar
Panos Anagnostakis

I have created a button in POS product screen, to display a new screen. 

The js file for the button is : 

odoo.define('cdc_pos.ProductTotalSalesButton', function (require) {
    'use strict';
    const PosComponent=require('point_of_sale.PosComponent');
    const ProductScreen=require('point_of_sale.ProductScreen');
    const { useListener } =require("@web/core/utils/hooks");
    const Registries=require('point_of_sale.Registries');
    class ProductTotalSalesButton extends PosComponent {
    ​ ​setup() {
          ​ ​super.setup();
          ​​useListener('click', this.onClick);
        ​}
​​async onClick() {
                this.showScreen('ProductTotalSalesScreen')
        ​}                  
    }
    ProductTotalSalesButton.template='ProductTotalSalesButton';
   ProductScreen.addControlButton({
       component:ProductTotalSalesButton,
       condition:function() {
           returntrue;       },
    });
   Registries.Component.add(ProductTotalSalesButton);
   return ProductTotalSalesButton;
});

The button is added correctly and it is used to show a new screen called ProductTotalSalesScreen using the showScreen function.

The js and xml files for the new screen are:

odoo.define('cdc_pos.ProductTotalSalesScreen', function(require) {
    'use strict';
    const PosComponent=require('point_of_sale.PosComponent');
   const Registries=require('point_of_sale.Registries');
   class ProductTotalSalesScreen extends PosComponent {
        setup(){
            super.setup();
       }
        back() {
            this.showScreen('ProductScreen');
        }
    };
    ProductTotalSalesScreen.template='ProductTotalSalesScreen';
    Registries.Component.add(ProductTotalSalesScreen);
    return ProductTotalSalesScreen;
});

xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="ProductTotalSalesScreen" owl="1">
        <div class="top-content">
            <div class="button back" t-on-click="back">
                Back
            div>
        div>
        <t t-foreach="[1, 2, 3]" t-as="i">
            <p><t t-out="i"/>p>
        t>
    t>
templates> ​
When I click the show ProductTotalSalesScreen, there is an error in the browser console which just says "undefined"

If I comment out the t-foreach loop then the screen is displayed.

Is there any reason why the t-foreach loop part causes the undefined error?
I can't make t-foreach work for this new screen template...
0
Avatar
Zrušit
Avatar
Juan Jose Carballo Samayoa
Nejlepší odpověď

<tt-set="cp"t-value="env.pos.componente_activo"/>

<tt-foreach="cp"t-as="componente"t-key="componente.id"> 

<td style="width: 30%"class="text-center">

<tt-esc="componente.name"/>

td>  

 

0
Avatar
Zrušit
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

Hi,

In this provided code there is an syntax mistake , update your code like this

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="ProductTotalSalesScreen" owl="1">
        <div class="top-content">
            <div class="button back" t-on-click="back">
                Back
            </div>
        </div>
        <t t-foreach="[1, 2, 3]" t-as="i">
            <p><t t-out="i"/></p>
        </t>
    </t>
</templates>


Regards

0
Avatar
Zrušit
Panos Anagnostakis
Autor

Hi! Thanks for the answer!

My code is exactly as yours (The missing "</" parts were removed by the forum engine when I posted).

The problem is that the template works if I omit the t-foreach loop, displaying a page with only the Back button visible. As soon as I include the foreach part, then I get an 'undefined' error in my console. I've used the most simplified qweb t-foreach loop. It doesn't work. Neither does any other t-foreach loop (in the specific xml file). I have used many times t-foreach loops in my xml files without any problem. I can't understand why it throws an error now.

I actually followed a tutorial from your blog: https://www.cybrosys.com/blog/how-to-add-custom-screens-in-the-odoo-16-pos

The example I present here is a simplified version, just to present the problem I'm facing.

Panos Anagnostakis
Autor

I just realized I can't use t-foreach, anywhere in POS xmls. It works in q-web reports, but not in POS screens or POS screen elements.

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
I trying to acess the model record in Java script in odoo 17 Vyřešeno
javascript pos owl v17
Avatar
Avatar
Avatar
Avatar
3
bře 25
9389
Select Customer before creating order pos odoo 16
javascript pos owl odoo16features
Avatar
0
led 24
2373
How can I inherit or extend a OWL class and add a new function or override a function on it? Vyřešeno
javascript pos owl v15
Avatar
Avatar
2
zář 23
10764
Max allowed quantity in pos
javascript pos xml odoo10.0
Avatar
0
zář 20
38
How to hide/show custom button based on condition in odoo10 Point of sale ? Vyřešeno
javascript pos xml odoo10.0
Avatar
Avatar
Avatar
4
kvě 18
13874
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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