콘텐츠로 건너뛰기
Odoo 메뉴
  • 로그인
  • 무료 체험하기
  • 앱
    재무 관리
    • 회계
    • 청구서 관리
    • 비용 관리
    • 스프레드시트 (BI)
    • 문서
    • 전자 서명
    판매
    • CRM
    • 판매
    • POS 스토어
    • POS 레스토랑
    • 구독
    • 렌탈
    웹사이트
    • 웹사이트 빌더
    • 이커머스
    • 블로그
    • 포럼
    • 실시간 채팅
    • 온라인 학습 관리
    공급망
    • 재고 관리
    • 제조 관리
    • 제품 수명주기 관리 (PLM)
    • 매입
    • 유지관리
    • 품질
    인적자원 관리
    • 직원
    • 채용
    • 휴가 관리
    • 인사 평가
    • 인재 추천
    • 차량 관리
    마케팅
    • 소셜 마케팅
    • 이메일 마케팅
    • SMS 마케팅
    • 행사
    • 마케팅 자동화
    • 설문 조사
    서비스
    • 프로젝트
    • 작업 기록
    • 현장 서비스
    • 헬프데스크
    • 일정 관리
    • 일정 예약
    생산성
    • 메일 및 채팅
    • 전자 결재
    • IoT
    • VoIP
    • 지식 센터
    • WhatsApp
    타사 앱 Odoo 스튜디오 Odoo 클라우드 플랫폼
  • 인더스트리
    리테일
    • 서점
    • 의류 매장
    • 가구점
    • 식료품점
    • 철물점
    • 장난감 가게
    식음료 & 숙박업
    • 바 & 펍
    • 레스토랑
    • 패스트푸드
    • 게스트 하우스
    • 음료 유통업체
    • 호텔
    부동산
    • 부동산 중개업체
    • 건축 회사
    • 건설
    • 부동산 관리
    • 가드닝
    • 부동산 소유자 협회
    컨설팅
    • 회계 법인
    • Odoo 파트너
    • 마케팅 대행사
    • 법률 사무소
    • 인재 영입
    • 감사 및 인증
    제조 관리
    • 텍스타일
    • 메탈
    • 가구
    • 푸드
    • 양조장
    • 기업용 선물
    건강 & 피트니스
    • 스포츠 클럽
    • 안경점
    • 피트니스 센터
    • 웰니스 전문가
    • 약국
    • 미용실
    사업
    • 핸디맨
    • IT 하드웨어 및 지원 서비스
    • 태양 에너지 시스템
    • 제화업체
    • 클리닝 서비스
    • HVAC 서비스
    기타
    • 비영리 단체
    • 환경 에이전시
    • 광고판 임대
    • 사진
    • 자전거 임대
    • 소프트웨어 리셀러
    전체 인더스트리 찾아보기
  • 커뮤니티
    학습
    • 튜토리얼
    • 문서
    • 인증
    • 훈련
    • 블로그
    • 팟캐스트
    교육 역량 강화
    • 교육 프로그램
    • Scale-Up! 경영관리 게임
    • Odoo에 방문해보세요
    소프트웨어 신청
    • 다운로드
    • 버전 살펴보기
    • 릴리즈 내역
    협업
    • Github
    • 포럼
    • 행사
    • 번역
    • 파트너 등록
    • 파트너 대상 서비스
    • 회계 법인 정보 등록
    서비스 신청
    • 파트너 검색
    • 회계사 검색
    • 전문 상담 예약
    • 구현 서비스
    • 고객 정보
    • 고객 지원
    • 업그레이드
    Github 유튜브 트위터 링크드인 인스타그램 페이스북 스포티파이
    +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
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
모든 게시물 사용자 배지
태그 (모두 보기)
odoo accounting v14 pos v15
게시판 정보
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
모든 게시물 사용자 배지
태그 (모두 보기)
odoo accounting v14 pos v15
게시판 정보
도움말

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

구독

이 게시물에 활동이 있으면 알림 받기

신고된 질문입니다
xmljsodoo16
2 답글
3698 화면
아바타
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
아바타
취소
아바타
Dương Nguyễn
베스트 답변

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
아바타
취소
Muhammad Ihza Putra Handayani
작성자

<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
작성자

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

아바타
Muhammad Ihza Putra Handayani
작성자 베스트 답변


0
아바타
취소
토론이 재미있으신가요? 직접 참여해보세요!

지금 바로 가입하여 독점 서비스를 이용해보고 특별한 커뮤니티와 소통하세요!

가입
관련 게시물 답글 화면 활동
compatibility problem with qweb report
xml report odoo16
아바타
아바타
1
11월 25
1715
How to hide "section-financials" from the ProductInfoPopup in POS Screen 해결 완료
javascript xml odoo16
아바타
아바타
2
7월 24
2001
How to extend class js FloatField in odoo 16 해결 완료
js OWL odoo16
아바타
아바타
2
5월 24
3334
Call variable in a template to have a dynamic url
xml templates js
아바타
0
12월 23
2599
How to export xlsx in Odoo14 Web
xml js v14
아바타
아바타
1
8월 23
4561
커뮤니티
  • 튜토리얼
  • 문서
  • 포럼
오픈 소스
  • 다운로드
  • 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, 이커머스, 회계, 재고, POS, 프로젝트 관리 등 기업의 모든 요구 사항을 충족하도록 설계된 오픈 소스 기반의 통합 비즈니스 앱 제품군입니다.

Odoo의 간편한 UI와 완벽하게 통합된 기능을 직접 확인해 보세요.

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