Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

KeyNotFoundError: Cannot find key "distribution_location_partner_form_view" in the "views" registry

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
jsPOSOdoov18
369 Vizualizări
Imagine profil
Walter

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

    <data>

        <record id="res_partner_form_view_inherit" model="ir.ui.view">

            <field name="name">res.partner.form.view.inherit</field>

            <field name="model">res.partner</field>

            <field name="inherit_id" ref="base.view_partner_form" />

            <field name="arch" type="xml">

                <xpath expr="//form" position="attributes">

                    <attribute name="js_class">distribution_location_partner_form_view</attribute>

                </xpath>

            </field>

        </record>

    </data>

</odoo>



/** @odoo-module */


import { rpc } from '@web/core/network/rpc'

import { registry } from "@web/core/registry"

import { useService } from "@web/core/utils/hooks"

import { FormController } from "@web/views/form/form_controller"

import { formView } from "@web/views/form/form_view"


class ResPartnerFormController extends FormController {

    setup() {

        super.setup()

        this.notification = useService("notification")

    }


    // 📸 Existing feature: location + photo upload

    async onLocationClick() {

        const currentRecord = this.model.root.data

        const partnerName = currentRecord.name


        if (navigator.geolocation) {

            navigator.geolocation.getCurrentPosition(

                async (position) => {

                    const lat = position.coords.latitude

                    const lon = position.coords.longitude


                    const fileInput = document.createElement("input")

                    fileInput.type = "file"

                    fileInput.accept = "image/*"


                    fileInput.onchange = async (event) => {

                        const file = event.target.files[0]

                        if (!file) {

                            this.notification.add("Photo is required!", {

                                title: "Error",

                                type: "danger",

                            })

                            return

                        }


                        const reader = new FileReader()

                        reader.onload = async () => {

                            const photoBase64 = reader.result.split(",")[1]


                            const result = await rpc("/partner/checkin", {

                                partner_name: partnerName,

                                lat: lat,

                                lon: lon,

                                photo: photoBase64,

                            })


                            if (result.success) {

                                this.notification.add(result.message, {

                                    title: "Success",

                                    type: "success",

                                })

                            } else {

                                this.notification.add(result.message, {

                                    title: "Error",

                                    type: "danger",

                                })

                            }

                        }

                        reader.readAsDataURL(file)

                    }

                    fileInput.click()

                },

                () => {

                    this.notification.add("Location retrieval failed", {

                        title: "Error",

                        type: "danger",

                    })

                }

            )

        }

    }


    // 📍 New feature: only save location to partner fields

    async onSaveLocationClick() {

        const currentRecord = this.model.root.data

        const partnerId = this.model.root.resId  // Use resId instead of data.id

        const partnerName = currentRecord.name


        console.log("Debug - Partner ID:", partnerId, "Partner Name:", partnerName)


        // Check if record is saved

        if (!partnerId || partnerId === false) {

            this.notification.add("Please save the partner record first before capturing location", {

                title: "Warning",

                type: "warning",

            })

            return

        }


        if (!navigator.geolocation) {

            this.notification.add("Geolocation is not supported by your browser", {

                title: "Error",

                type: "danger",

            })

            return

        }


        navigator.geolocation.getCurrentPosition(

            async (position) => {

                const lat = position.coords.latitude

                const lon = position.coords.longitude


                try {

                    const result = await rpc("/partner/save_location", {

                        partner_id: partnerId,

                        lat: lat,

                        lon: lon,

                    })


                    if (result.success) {

                        this.notification.add(result.message, {

                            title: "Success",

                            type: "success",

                        })

                        await this.model.root.load() // refresh form to show updated values

                    } else {

                        this.notification.add(result.message, {

                            title: "Error",

                            type: "danger",

                        })

                    }

                } catch (error) {

                    console.error("RPC Error:", error)

                    this.notification.add("Failed to save location: " + error.message, {

                        title: "Error",

                        type: "danger",

                    })

                }

            },

            (error) => {

                let errorMsg = "Failed to get location"

                switch (error.code) {

                    case error.PERMISSION_DENIED:

                        errorMsg = "Location permission denied. Please enable location access."

                        break

                    case error.POSITION_UNAVAILABLE:

                        errorMsg = "Location information unavailable."

                        break

                    case error.TIMEOUT:

                        errorMsg = "Location request timed out."

                        break

                }

                this.notification.add(errorMsg, {

                    title: "Error",

                    type: "danger",

                })

            }

        )

    }

}


ResPartnerFormController.template = "distribution_location.ResPartnerFormView"


export const resPartnerFormView = {

    ...formView,

    Controller: ResPartnerFormController,

}


registry.category("views").add(

    "distribution_location_partner_form_view",

    resPartnerFormView,

)

It works fine on the Contacts page, but when I try to add a new customer from the POS page, I get an error


0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Can concepts be predefined for Cash In/Out?
POS
Imagine profil
Imagine profil
2
sept. 25
769
Prevent display of form view from list view of v18 when row was clicked
Odoov18
Imagine profil
Imagine profil
2
oct. 24
3258
how to using dataavailable in js
js
Imagine profil
Imagine profil
1
iun. 23
2719
Can not open wizard from PivotRenderer
js
Imagine profil
Imagine profil
1
mai 23
2656
odoo 15 js this.do_notify
js
Imagine profil
Imagine profil
1
oct. 22
4859
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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