Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Trying to get data from Odoo using PHP/Laravel-9 using XMLRPC need help and guidance

Subscriure's

Get notified when there's activity on this post

This question has been flagged
xmlrpcodooXML-RPCPHP
1 Respondre
2948 Vistes
Avatar
Osama Ahmed Momin

I am able to authenticate but when trying to get data its giving me error

call to member function serialize() on string

This is the error I am getting

Is there anyone who can help me to resolve this issue quickly please.

I am using Laravel version 9.46, check using via php artisan -v

I am using "phpxmlrpc/phpxmlrpc": "^4.10" package

Can anyone help me get authenticate and get the tickets and tasks data from odoo


send($request);

        //var_dump($response);



        //var_dump($response);

        if ($response->faultCode()) {
            $this->error('Error: ' . $response->faultString());
            return;
        }

        // Retrieve the user ID from the response
        $user_id = $response->value()->scalarval();

        if ($user_id) {
            $this->info("Authenticated successfully. User ID: $user_id");
        } else {
            $this->error("Authentication failed.");
            return;
        }

        // Function to call Odoo methods
        function callOdooMethod($client, $method, $params) {
            var_dump($method);
            var_dump($params);
            var_dump($client);
            
            $msg = new Request($method, array(new Value($params, 'array')));

            var_dump($msg);

            $resp = $client->send($msg);
            
            var_dump($resp);

            if ($resp->faultCode()) {
                return 'Error: ' . $resp->faultString();
            }
            return $resp->value();
        }

        // Fetch last sync time for a model
        function getLastSyncTime($model_name) {
            return DB::table('last_sync')->where('model_name', $model_name)->value('last_update');
        }

        // Update last sync time for a model
        function updateLastSyncTime($model_name) {
            DB::table('last_sync')->updateOrInsert(
                ['model_name' => $model_name],
                ['last_update' => now()]
            );
        }

        // Fetch data from Odoo
        function fetchData($models, $db, $user_id, $password, $model_name, $fields, $last_sync_time=0) {
            //$domain = $last_sync_time ? [['write_date', '>', $last_sync_time]] : [];
            $params = array(
                new Value($db, 'string'),
                new Value($user_id, 'int'),
                new Value($password, 'string'),
                new Value($model_name, 'string'),
                new Value('search_read', 'string'),
                new Value(array(
                    //new Value($domain, 'array'), // Domain filter
                    new Value($fields, 'array'), // Fields to retrieve
                ), 'array')
            );

            return callOdooMethod($models, 'execute_kw', $params);
        }

        // Update local database with fetched data
        function updateLocalDatabase($model_name, $data) {
            foreach ($data as $record) {

            }
        }

        // Create a client instance for object services
        $models = new Client($object_url);

        var_dump($models);

        // Define fields to retrieve for each model
        $project_fields = array('name', 'user_id', 'date_start', 'date_end', 'tasks');
        $task_fields = array('name', 'user_id', 'date_deadline', 'stage_id', 'description');
        $ticket_fields = array('name', 'stage_id', 'user_id', 'priority', 'description');
        $incident_fields = array('name', 'stage_id', 'user_id', 'priority', 'description'); // Replace with actual fields

        // Define models
        $models_to_fetch = array(
            'project.project' => $project_fields,
            'project.task' => $task_fields,
            'helpdesk.ticket' => $ticket_fields
        );

        /*,
            'your_incident_model_name' => $incident_fields // Replace with actual model name */

        foreach ($models_to_fetch as $model_name => $fields) {
            //$last_sync_time = getLastSyncTime($model_name);
            $data = fetchData($models, $db, $user_id, $password, $model_name, $fields); //, $last_sync_time

            if (is_string($data)) {
                $this->error("Error fetching $model_name: " . $data);
            } else {
                $this->info(ucfirst(str_replace('.', ' ', $model_name)) . " Data:\n");
                print_r($data);
                updateLocalDatabase($model_name, $data);
                updateLastSyncTime($model_name);
            }
        }
    }
}


0
Avatar
Descartar
Avatar
Adil Akbar
Best Answer

Hi, please check this: https://youtu.be/Cmbo2iGuTBY 
Hope it helps.

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
PhpXmlRpc - Error when insert Purchase order in multi company instance
xmlrpc XML-RPC XmlHttpRequestError PHP
Avatar
0
de nov. 23
2044
Connecting Odoo 12 error via xmlrpc library
xmlrpc odoo XML-RPC odoo12
Avatar
Avatar
1
de set. 19
10026
Update server timeout settings in Odoo? Solved
odoo PHP
Avatar
Avatar
Avatar
Avatar
Avatar
4
d’ag. 24
18160
XMLRPC call method with parameter as recordset
xmlrpc XML-RPC
Avatar
Avatar
1
de nov. 22
5135
Create custom field via XMLRPC
xmlrpc odoo
Avatar
Avatar
3
de juny 20
5468
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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