Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

domain_force need to be upgrade everytime there is a change

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
ir.ruleodoo16
1551 Vistas
Avatar
Dimas Aditya Kristianto

I'm trying to change an ir.rule that is from odoo base crm module. Specifically in odoo-server/addons/crm/security/crm_security.xml. The ir.rule is registered as no_update then I find this thread "How to inherit and change the domain of standard rules in odoo 8.0?". It work. The ir.rule is changed. 


My goal is to change the domain_force so that when the user's "Sales" access right was set to "User: Own document only", it will see the user status in "Sales Team" (crm.team). If he is a leader, he can see the member's opportunity and his opportunity when opening the CRM menu




I add new many2many field in res.partner to store all crm.lead that a user can be viewed 


The problem is when I open CRM menu, the data is not updated when I change the leader in "Sales Team". But it change when I upgrade the module OR set the argument --dev=xml​ when running the service





class CrmLead(models.Model):

    _inherit = 'crm.lead'

    def write(self, vals):

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

        _logger.info("Editing in crm.lead")


        # user_ids = self.user_id

        partner_ids = self.env['res.users'].search([]).partner_id.ids

        if partner_ids:

            self._update_visible_crm_lead_ids(partner_ids)

        _logger.info("Finish editing in crm.lead")

        return res


    visible_res_users_ids = fields.Many2many('res.partner', string='Leads')

    def _update_visible_crm_lead_ids(self, partner_ids):

        """

        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


        """

        _logger.info("Entering update_visible_crm_lead with users: %s", partner_ids)

        partners = self.env['res.partner'].sudo().search([('id', 'in', partner_ids)])

        for partner in partners:

            res_user = self.env['res.users'].search([('partner_id', '=', res_user.id)])

            all_user_to_get_all_crm_lead = res_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

            _logger.debug("partner display name: %s", partner.display_name)

            _logger.debug("res users: %s", res_user.display_name)

            _logger.debug("all_crm_lead: %s", all_crm_lead)

            partner.visible_crm_lead_ids = [(6, 0, all_crm_lead)]



class ResPartner(models.Model):

    _inherit = "res.partner"

    visible_crm_lead_ids = fields.Many2many('crm.lead', string='Leads')


class CrmTeam(models.Model):

    _inherit = 'crm.team'


    def write(self, vals):

        res = super(CrmTeam, self).write(vals)

        self.create_depart_users_write()

        # self.update_res_partner()

        _logger.info("Editing in crm.team")

        crm_lead = self.env['crm.lead'].search([], limit=1)

        if crm_lead:

            partner_ids = self.env['res.users'].search([]).partner_id.ids

            crm_lead._update_visible_crm_lead_ids(partner_ids)


        _logger.info("Finish editing in crm.team")

        return res

  



<?xml version="1.0" encoding="utf-8"?>

<odoo>


    <!--Find the corresponding "to be inherited record" with noupdate="1" -->

    <function name="write" model="ir.model.data">

        <function model="ir.model.data" name="search">

            <value eval="[('module', '=', 'crm'), ('name', '=', 'crm_rule_personal_lead')]" />

        </function>

        <value eval="{'noupdate': False}"/>

    </function>


    <!--Finish the job, i.e. inheriting/modifying some fields-->

    <record id="crm.crm_rule_personal_lead" model="ir.rule">            

        <field name="domain_force">[('id', 'in', user.partner_id.visible_crm_lead_ids.ids)]</field>        

    </record>


    <!--Optional, if you want to set noupdate to True again-->

    

    <function name="write" model="ir.model.data">

        <function model="ir.model.data" name="search">

            <value eval="[('module', '=', 'crm'), ('name', '=', 'crm_rule_personal_lead')]" />

        </function>

        <value eval="{'noupdate': True}"/>

    </function>


</odoo>







0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Automatic Batch Transfer Resuelto
odoo16
Avatar
Avatar
1
ago 25
1386
Automatic Batch Transfer
odoo16
Avatar
Avatar
1
may 25
2201
Bank statement import via email
odoo16
Avatar
0
nov 24
2126
Display 'total' ( Like in Sale Order) on TOP
odoo16
Avatar
Avatar
2
oct 24
2166
I have a manufacturing type product that comes out with 0 stock despite having materials.
odoo16
Avatar
0
ago 24
1661
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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