Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Change the value of Many2one field based on another Many2one field

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
many2onerelatedv14
3 Odpowiedzi
6721 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Savan Changela
Najlepsza odpowiedź

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
Awatar
Odrzuć
Mohamad Ali Chamas
Autor

That worked, thank you so much

Savan Changela

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

Mohamad Ali Chamas
Autor

Sure its done

Mohamad Ali Chamas
Autor

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
Autor

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
Autor

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

Awatar
Siddharth Tarpada
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Mohamad Ali Chamas
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Hide some possible choices in a Many2one field
many2one v14
Awatar
Awatar
Awatar
2
kwi 23
3583
Odoo 14: How i can set Domain filter on Many2one type field Rozwiązane
many2one v14
Awatar
Awatar
Awatar
2
lut 25
41902
hide many2one record when changing condition
many2one v14
Awatar
Awatar
Awatar
2
lis 22
3522
Odoo 14: set filter of Many2one field onchange of another Many2one field
many2one v14
Awatar
Awatar
1
lut 22
8508
Many2one field is not showing record name on Saving form Rozwiązane
many2one v14
Awatar
Awatar
2
gru 21
4940
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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