Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

[V14] commit and write lock to controller

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
stock_pickingcursorshippingthreadingcontrollers
3062 Visualizzazioni
Avatar
Angel

Hi everyone,


I'm having trouble saving some data to a stock picking model. When I press the validate button and later I press the button "Create Backorder".  Enter a "send_shipping" method in "delivery.carrier" due to the creation of a carrier created by me.


Within this method,  called a custom controller via requests,  in this way, to be able to save the picking data before it is finished. In this way, if there was an error, the information that I saved could be used again without the need to call the api again.  Because I'm having problems that the method called twice and created two expeditions to the carrier.


The problem is when I try to execute the write method on the stock picking in  the  Controller.  I don't know how but it gets lock.  And the program does not continue.


This is the part of the controller call in the delivery carrier in the method "send_shipping":

base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
save_picking_data_url = base_url + '/hello_world/delivery_carrier/save_data_send_shipping'

response = requests.post(
    save_picking_data_url,
    data=json.dumps({
        'params': {
            'stock_picking_id': picking.id,
            'tracking_number': tracking_number,
            'label_data': label_data
        }
    }),
    headers={'Content-Type': 'application/json'},
    cookies={'session_id': http.request.session.sid }
)


And these is the controller method to save the data:

# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import route, request

class Controllers(http.Controller):
    @route('/hello_world/delivery_carrier/save_data_send_shipping', auth='user', type='json', methods=['POST'])
    def save_data_send_shipping(self):
        user = request.env['res.users'].browse([request.uid])
        stock_picking_id = request.params.get('stock_picking_id')
        tracking_number = request.params.get('tracking_number')
        label_data = request.params.get('label_data')

        # Check that the user is in the group
        if not user.has_group('stock.group_stock_user'):
            return {'error_message': 'Error. You don\'t have permissions in the stock'}
        elif not stock_picking_id or not tracking_number or not label_data:
            return {'error_message': 'Error. Missing parameters (stock_picking_id, tracking_number, label_data)'}
        
        stock_picking = request.env['stock.picking'].browse([stock_picking_id])
        stock_picking.write({
            'tracking_number_response': tracking_number,
            'label_data_response': label_data
        })

return {'error_message': False}


Someone can know why it happens or do you need more information about the problem?


Greetings and thank you very much!

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to invoke model and cursor inside controller? Openerp Version 7 Risolto
models cursor controllers version7
Avatar
Avatar
Avatar
4
lug 19
8290
Controller giving 404 Error
controllers
Avatar
Avatar
Avatar
2
ago 25
3593
Odoo Default Shipping - Change to rate for Volume
shipping
Avatar
Avatar
1
ago 25
1318
Does anyone know if it's possible to make adding a shipping method/price mandatory?
shipping
Avatar
Avatar
1
lug 25
2086
Shipping GET RATE
shipping
Avatar
Avatar
1
lug 25
2271
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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