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

Change the value of Many2one field based on another Many2one field

Iscriviti

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

La domanda è stata contrassegnata
many2onerelatedv14
3 Risposte
6702 Visualizzazioni
Avatar
Mohamad Ali Chamas

In the sales order model when changing the salesperson field in the other info tab, I need it to change also in the account.move model (In the invoices under the other info tab) to be the same value (same salesperson I chose). Any help or ideas please?

0
Avatar
Abbandona
Avatar
Savan Changela
Risposta migliore

Try this one 

class SaleOrder(models.Model):
_inherit = "sale.order"

@api.onchange('user_id')
def _custom_onchange_user_id(self):
moves = self.env['account.move'].browse(self.invoice_ids.ids)
moves.sudo().write({'invoice_user_id': self.user_id.id})

1
Avatar
Abbandona
Mohamad Ali Chamas
Autore

That worked, thank you so much

Savan Changela

If it's working then please don't forgot to mark answer right.

Mohamad Ali Chamas
Autore

Sure its done

Mohamad Ali Chamas
Autore

I have one more question, what query can be done in order to update the sales person on sales and automatically be updated on invoice? I am using this on odoo shell: update account_move set invoice_user_id='X'; I am getting an error right now and I am still trying, can you help me please?

Savan Changela

Try
update account_move set invoice_user_id="user id here" where id="move id here"

Mohamad Ali Chamas
Autore

Yes this worked on 1 line level, is there a way to update it on different lines? The function I implemented earlier is 100% correct, but now I need to update old invoices sale person field. So I have 10 invoices with sales person different than the ones in sales order. I need a query that links these two fields together and always put a condition that the sales person field should be compatible in both models. Appreciate your help

Mohamad Ali Chamas
Autore

I created a server action and upon choosing the invoices I want to update the sales person field to be compatible with the sales person field inside sale.order. This is my code: <?xml version="1.0" encoding="UTF-8"?>

<odoo>

<record model="ir.actions.server" id="action_change_sales_person">
<field name="name">Adjust Sales Person Field</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="account.model_account_move"/>
<field name="binding_model_id" ref="account.model_account_move"/>
<field name="state">code</field>
<field name="binding_view_types">list,form</field>
<field name="code">
for record in records:
if record.invoice_user_id != record.user_id:
record._custom_onchange_user_id()
</field>
</record>
</odoo>

Appreciate your support

Avatar
Siddharth Tarpada
Risposta migliore

You have to override onchange function of 'user_id' named 'onchange_user_id' in sale.order and find linked record of account.move to set same record in salesperson field of invoice(invoice_user_id) from sale order.

0
Avatar
Abbandona
Avatar
Mohamad Ali Chamas
Autore Risposta migliore

I am using this function:

from odoo import api,fields,models,_

class SOInherit(models.Model):

_inherit = 'sale.order'

@api.onchange('user_id')
def _onchange_user_id(self):
for rec in self:
if rec.user_id:
rec.invoice_user_id = rec.user_id

but there is a link missing between the user_id and the invoice_user_id, can you help me find it?

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à
Hide some possible choices in a Many2one field
many2one v14
Avatar
Avatar
Avatar
2
apr 23
3569
Odoo 14: How i can set Domain filter on Many2one type field Risolto
many2one v14
Avatar
Avatar
Avatar
2
feb 25
41868
hide many2one record when changing condition
many2one v14
Avatar
Avatar
Avatar
2
nov 22
3516
Odoo 14: set filter of Many2one field onchange of another Many2one field
many2one v14
Avatar
Avatar
1
feb 22
8501
Many2one field is not showing record name on Saving form Risolto
many2one v14
Avatar
Avatar
2
dic 21
4930
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