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
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • 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

Code with updating res.users is not working in server but working in local [update 1]

Subscriure's

Get notified when there's activity on this post

This question has been flagged
res.usersodoo16
1 Respondre
2476 Vistes
Avatar
Dimas Aditya Kristianto

I am updating multiple of users when a crm.team or crm.lead is updated. The problem is, it's working in my local but not working in the server


I already make sure I upgrade the right module (more than 5 times) and I already try upgrade it with the terminal. And the code still not working


I show the variable in the view, it looks like the value only update the first time after upgrade because the value is filled but when any change after that, it's not changing


[Update 1]

I pass --dev=xml​ in the service and it works. But I read that we shouldn't pass this argument in production. But if I didn't do it, there will be no change when updating the value


Below is the code



class CrmLead(models.Model):
    _inherit = 'crm.lead'

    def write(self, vals):
        res = super(CrmLead, self).write(vals)

        # user_ids = self.user_id
        user_ids = self.env['res.users'].search([])
        if user_ids:
            self._update_visible_crm_lead_ids(user_ids)
        return res

    def _update_visible_crm_lead_ids(self, users):
        """
        1. Check the user. If the user is leader, get the members user_id. If not, just get user_id
        2. Get all crm_lead that has the user_id that we got from the first step
        3. Replace all visible_crm_lead_ids with the new one
        """
        for user in users:
            crm_team_based_on_leader = self.env['crm.team'].search([('user_id', '=', user.id)])
            all_user_to_get_all_crm_lead = user.ids
            if crm_team_based_on_leader:
                all_user_to_get_all_crm_lead = all_user_to_get_all_crm_lead + crm_team_based_on_leader.member_ids.ids
                all_user_to_get_all_crm_lead = list(set(all_user_to_get_all_crm_lead))
               
            all_crm_lead = self.env['crm.lead'].search([('user_id', 'in', all_user_to_get_all_crm_lead)]).ids

            user.visible_crm_lead_ids = [(6, 0, all_crm_lead)]
0
Avatar
Descartar
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,
May be some code difference or extra apps in the production ? Also ensure your code is working in production by adding some logger in it.

Thanks

0
Avatar
Descartar
Dimas Aditya Kristianto
Autor

I use git to store the code. I check the latest commit in git and the latest pull on the server. Both are the same. I added some loggers to make sure the code is being executed and it is. But I don't know if it is the right data since there are already hundreds of data. I put some logger at first and last of the function to make sure the code is executed thoroughly.

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
Automatic Batch Transfer Solved
odoo16
Avatar
Avatar
1
d’ag. 25
1223
Automatic Batch Transfer
odoo16
Avatar
Avatar
1
de maig 25
2028
How to change value for field custom in res.users
error inherit res.users odoo16
Avatar
Avatar
Avatar
2
de nov. 24
2771
Bank statement import via email
odoo16
Avatar
0
de nov. 24
1996
Display 'total' ( Like in Sale Order) on TOP
odoo16
Avatar
Avatar
2
d’oct. 24
2075
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