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
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • 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
    Procházet všechna odvětví
  • 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
    • Služby pro partnery
    • 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

View error context: '-no context-', Invalid attribute custom_gross_economic for element field, Element tree has extra content: field

Odebírat

Get notified when there's activity on this post

This question has been flagged
xmljsodoo16
2 Odpovědi
3750 Zobrazení
Avatar
Muhammad Ihza Putra Handayani

im adding a new func in js but its variable is can not be used
below is my js code


/** @odoo-module **/
var rpc = require('web.rpc');
import { patch } from "@web/core/utils/patch";
import { browser } from "@web/core/browser/browser";
import { CheckBox } from "@web/core/checkbox/checkbox";
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { getActiveHotkey } from "@web/core/hotkeys/hotkey_service";
import { Pager } from "@web/core/pager/pager";
import { evaluateExpr } from "@web/core/py_js/py";
import { registry } from "@web/core/registry";
import { useBus, useService } from "@web/core/utils/hooks";
import { useSortable } from "@web/core/utils/sortable";
import { getTabableElements } from "@web/core/utils/ui";
import { Field } from "@web/views/fields/field";
import { getTooltipInfo } from "@web/views/fields/field_tooltip";
import { evalDomain, getClassNameFromDecoration } from "@web/views/utils";
import { ViewButton } from "@web/views/view_button/view_button";
import { useBounceButton } from "@web/views/view_hook";
import { Widget } from "@web/views/widgets/widget";
import { localization } from "@web/core/l10n/localization";
import { ListRenderer } from "@web/views/list/list_renderer";

const formatters = registry.category("formatters");

patch(ListRenderer.prototype, 'ListRenderer_custom', {
    get aggregates() {
        function checkCharNumberThreeFromEnd(inputString) {
            // Check if the inputString is a string and has at least 3 characters
            if (typeof inputString === 'string' && inputString.length >= 3) {
                // Get the character at the third position from the end
                const char = inputString.charAt(inputString.length - 3);
                if (char === ','){
                    inputString = inputString.replace(/\s/g, '');
                    inputString = inputString.replace(/,/g, '.');
                }
                else if(char === '.'){
                    inputString = inputString.replace(/,/g, '');
                }
                return parseFloat(inputString)
            }
        }


        let values;
        if (this.props.list.selection && this.props.list.selection.length) {
            values = this.props.list.selection.map((r) => r.data);
        } else if (this.props.list.isGrouped) {
            values = this.props.list.groups.map((g) => g.aggregates);
        } else {
            values = this.props.list.records.map((r) => r.data);
        }
        const aggregates = {};
        for (const fieldName in this.props.list.activeFields) {
            const field = this.fields[fieldName];
            const fieldValues = values.map((v) => v[fieldName]).filter((v) => v || v === 0);
            if (!fieldValues.length) {
                continue;
            }
            const type = field.type;
            if (type !== "integer" && type !== "float" && type !== "monetary") {
                if (field.name !== "margin" && field.name !== "cost_discount_percent" && field.name !== "sale_discount_percent" && field.name !== "gross_margin_percentage"){
                    continue;
                }
            }
            const { rawAttrs, widget } = this.props.list.activeFields[fieldName];
            let currencyId;
            if (type === "monetary" || widget === "monetary") {
                const currencyField =
                    this.props.list.activeFields[fieldName].options.currency_field ||
                    this.fields[fieldName].currency_field ||
                    "currency_id";
                currencyId =
                    currencyField in this.props.list.activeFields &&
                    values[0][currencyField] &&
                    values[0][currencyField][0];
                if (currencyId) {
                    const sameCurrency = values.every(
                        (value) => currencyId === value[currencyField][0]
                    );
                    if (!sameCurrency) {
                        aggregates[fieldName] = {
                            help: _t("Different currencies cannot be aggregated"),
                            value: "—",
                        };
                        continue;
                    }
                }
            }
            const func =
                (rawAttrs.sum && "sum") ||
                (rawAttrs.avg && "avg") ||
                (rawAttrs.max && "max") ||
                (rawAttrs.min && "min") ||
                (rawAttrs.custom_margin && "custom_margin") ||
                (rawAttrs.custom_cost_economic && "custom_cost_economic") ||
                (rawAttrs.custom_sale_economic && "custom_sale_economic") ||
                (rawAttrs.custom_gross_economic && "custom_gross_economic");
            if (func) {
                let aggregateValue = 0;
                if (func === "max") {
                    aggregateValue = Math.max(-Infinity, ...fieldValues);
                } else if (func === "min") {
                    aggregateValue = Math.min(Infinity, ...fieldValues);
                } else if (func === "avg") {
                    aggregateValue =
                        fieldValues.reduce((acc, val) => acc + val) / fieldValues.length;
                } else if (func === "sum") {
                    aggregateValue = fieldValues.reduce((acc, val) => acc + val);
                } else if (func === "custom_margin") {
                    var margin_value = checkCharNumberThreeFromEnd(aggregates['margin_integer']['value']);
                    var cost_final_value = checkCharNumberThreeFromEnd(aggregates['cost_final']['value']);
                    if (cost_final_value === 0){
                        aggregateValue = 0 + " %";
                    }
                    else{
                        var margin = (margin_value / cost_final_value) * 100
                        margin = margin.toFixed(2) + " %";
                        aggregateValue = margin;
                    }
                    aggregates[fieldName] = {
                        help: rawAttrs[func],
                        value: aggregateValue,
                    };
                    continue
                } else if (func === "custom_cost_economic") {
                    var cost_value = checkCharNumberThreeFromEnd(aggregates['cost_price']['value']);
                    var cost_discount_value = checkCharNumberThreeFromEnd(aggregates['cost_discount']['value']);
                    if (cost_value === 0){
                        aggregateValue = 0 + " %";
                    }
                    else{
                        var margin = (cost_discount_value / cost_value) * 100
                        margin = margin.toFixed(2) + " %";
                        aggregateValue = margin;
                    }
                    aggregates[fieldName] = {
                        help: rawAttrs[func],
                        value: aggregateValue,
                    };
                    continue
                } else if (func === "custom_sale_economic") {
                    var sale_value = checkCharNumberThreeFromEnd(aggregates['sale_price']['value']);
                    var sale_discount = checkCharNumberThreeFromEnd(aggregates['sale_discount']['value']);
                    if (sale_value === 0){
                        aggregateValue = 0 + " %";
                    }
                    else{
                        var margin = (sale_discount / sale_value) * 100
                        margin = margin.toFixed(2) + " %";
                        aggregateValue = margin;
                    }
                    aggregates[fieldName] = {
                        help: rawAttrs[func],
                        value: aggregateValue,
                    };
                    continue
                } else if (func === "custom_gross_economic") {
                    var saleFinalValue = checkCharNumberThreeFromEnd(aggregates['sale_final_no_tax']['value']);
                    var grossDiscount = checkCharNumberThreeFromEnd(aggregates['sale_final_tax']['value']);
                    if (saleFinalValue === 0) {
                        aggregateValue = "0 %";
                    } else {
                        var margin = (grossDiscount / saleFinalValue) * 100;
                        margin = margin.toFixed(2) + " %";
                        aggregateValue = margin;
                    }
                    aggregates[fieldName] = {
                        help: rawAttrs[func],
                        value: aggregateValue,
                    };
                    continue;
                }
                const formatter = formatters.get(widget, false) || formatters.get(type, false);
                const formatOptions = {
                    digits: rawAttrs.digits ? JSON.parse(rawAttrs.digits) : undefined,
                    escape: true,
                };
                if (currencyId) {
                    formatOptions.currencyId = currencyId;
                }
                aggregates[fieldName] = {
                    help: rawAttrs[func],
                    value: formatter ? formatter(aggregateValue, formatOptions) : aggregateValue,
                };
            }
        }
        return aggregates;
    }
});


below is my xml



        Tree Vehicles Database Month
        vdl.vehicles_database
       
           
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
           
       
   


and it shows below eror


2024-05-28 03:37:45,367 11469 ERROR ihzacappassion odoo.tools.view_validation: :17:0:ERROR:RELAXNGV:RELAXNG_ERR_NOELEM: Expecting an element data, got nothing 2024-05-28 03:37:45,367 11469 ERROR ihzacappassion odoo.tools.view_validation: :17:0:ERROR:RELAXNGV:RELAXNG_ERR_INVALIDATTR: Invalid attribute custom_gross_economic for element field 2024-05-28 03:37:45,367 11469 ERROR ihzacappassion odoo.tools.view_validation: :3:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element tree has extra content: field 2024-05-28 03:37:45,367 11469 ERROR ihzacappassion odoo.tools.view_validation: Invalid XML: Get RNG validator and validate RNG file. 2024-05-28 03:37:45,368 11469 DEBUG ihzacappassion odoo.tools.translate: translation went wrong for "'Invalid view %(name)s definition in %(file)s'", skipped 

raise ParseError(msg) from None # Restart with "--log-handler odoo.tools.convert:DEBUG" for complete traceback odoo.tools.convert.ParseError: while parsing /opt/odoo/Odoo16_VDL/catalog/views/vehicles_database_month_view.xml:41 Invalid view Tree Vehicles Database Month (catalog.tree_vehicles_database_month) definition in catalog/views/vehicles_database_month_view.xml View error context: '-no context-'

0
Avatar
Zrušit
Avatar
Dương Nguyễn
Nejlepší odpověď

I think u should create a widget call 'custom_gross_economic' instead of using it as an attribute because odoo will not understand it

0
Avatar
Zrušit
Muhammad Ihza Putra Handayani
Autor

<xpath expr="//notebook" position="inside">
<page string='Economic sheet' attrs="{'invisible': [('vdl_check', '=', False)]}">
<field name="economy_id">
<tree editable="bottom">
<field name="product_id" string="Name"/>
<field name="cost_price" string="Cost (No Tax)" sum="TOTAL"/>
<field name="cost_discount" string="Discount" sum="TOTAL"/>
<field name="cost_discount_percent" nolabel='1' custom_cost_economic='custom_cost_economic'/>
<field name="cost_final" string="Final Cost (No Tax)" sum="TOTAL" readonly='1' />
<field name="sale_price" string="Sales Price (No Tax)" sum="TOTAL"/>
<field name="sale_price_tax" string="Sale Price (Tax)" sum="TOTAL"/>
<field name="sale_discount" string="Discount" sum="TOTAL"/>
<field name="sale_discount_percent" nolabel='1' custom_sale_economic='custom_sale_economic'/>
<field name="sale_final" string="Final Sale Price (No Tax)" sum="TOTAL" readonly='1' />
<field name="margin_integer" string="Margin" readonly='1' sum="TOTAL"/>
<field name="margin" nolabel="1" readonly='1' custom_margin="custom_margin"/>
</tree>
</field>
</page>
</xpath>

but it works in other file

Dương Nguyễn

OK so it load ok but does it work as you expected (the js code is what i'm taking about) ?

Muhammad Ihza Putra Handayani
Autor

yes but only the custom_gross_economic that doesnt work, im clueless

Dương Nguyễn

so when u debugging , js code run into to your code right, it just get error when load view that have 'custom_gross_economic'.
In that case, i can only think to option to create a widget, because widget is a valid xml attribute in odoo

Avatar
Muhammad Ihza Putra Handayani
Autor Nejlepší odpověď


0
Avatar
Zrušit
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
compatibility problem with qweb report
xml report odoo16
Avatar
Avatar
1
lis 25
1734
How to hide "section-financials" from the ProductInfoPopup in POS Screen Vyřešeno
javascript xml odoo16
Avatar
Avatar
2
čvc 24
2059
How to extend class js FloatField in odoo 16 Vyřešeno
js OWL odoo16
Avatar
Avatar
2
kvě 24
3387
Call variable in a template to have a dynamic url
xml templates js
Avatar
0
pro 23
2645
How to export xlsx in Odoo14 Web
xml js v14
Avatar
Avatar
1
srp 23
4645
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