Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

Use Model Method in context fields in odoo XML Record

Suscribirse

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

Se marcó esta pregunta
xmlcontextmethodeodoo17
1 Responder
4286 Vistas
Avatar
Mohammad Ali Ben Hmida

I create a methode in claim model that return the current user 
@api.model def get_current_user_parent_partner_id(self): 

​current_user = self.env.user

​parent_partner_id = current_user.partner_id.parent_id.id  

​return parent_partner_id


and this the XMl code that I Write it 

 
  

I List Of Claims 

claim 

[('create_uid.partner_id.parent_id.id', '=', context.get('parent_partner_id'))]

I had Errors when I call the method 
how can I well call this method


I use odoo 17 

0
Avatar
Descartar
Mohammad Ali Ben Hmida
Autor

This is the Full code

@api.model
def get_current_user_parent_partner_id(self): 

​current_user = self.env.user

​parent_partner_id = current_user.partner_id.parent_id.id  

​return parent_partner_id

- XMl code that I Write it 

<record id="ca_claim_action" model="ir.actions.act_window"> 

<field name= "name">I List Of Claims</field> 

<field name= "res_model">claim</field> 

<{"parent_partner_id": get_current_user_parent_partner_id()}</field>

<field name="domain">[('create_uid.partner_id.parent_id.id', '=', context.get('parent_partner_id'))]</field> </record>

Avatar
Shajahan
Mejor respuesta

It seems like you're trying to pass the result of the get_current_user_parent_partner_id method as a value for the context variable in your XML code. However, the way you're trying to do it is not correct. Here's the corrected version:

    List Of Claims

    claim

    {

        'default_parent_partner_id': get_current_user_parent_partner_id()

    }

    [('create_uid.partner_id.parent_id.id', '=', default_parent_partner_id)]





   
 




In the above XML code:
  • We're using the context field to pass values to the context dictionary.
  • We're setting the key 'default_parent_partner_id' in the context dictionary to the result of the get_current_user_parent_partner_id method.
  • In the domain field, we're using default_parent_partner_id to filter claims based on the current user's parent partner ID.

Make sure your get_current_user_parent_partner_id method is properly defined in your Python code, and the method should be accessible from the XML context. With this setup, when you open the list of claims, it will filter the claims based on the parent partner ID of the current user.

0
Avatar
Descartar
Shajahan

<record id="ca_claim_action" model="ir.actions.act_window">
<field name="name">List Of Claims</field>
<field name="res_model">claim</field>
<field name="context">{
'default_parent_partner_id': get_current_user_parent_partner_id()
}</field>
<field name="domain">[('create_uid.partner_id.parent_id.id', '=', default_parent_partner_id)]</field>
</record>

Mohammad Ali Ben Hmida
Autor

I use your code logic
and I also well define the function but it show me that error
EvalError: Can not evaluate python expression: ({
'default_parent_partner_id': get_current_user_parent_partner_id()
})
Error: Name 'get_current_user_parent_partner_id' is not defined

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How to put a domain on context XML ? Odoo 8 Resuelto
xml context
Avatar
Avatar
Avatar
2
mar 19
13848
Why required attr used on field in xml doesn't work in V17? Resuelto
xml Technical odoo17
Avatar
Avatar
Avatar
2
jun 25
5663
Issues with Populating Odoo's Customer Statements Report and Sending via Email Using XML Template
xml attachments odoo17
Avatar
1
ago 24
2415
Odoo 17 generating blank QWeb.
xml qweb odoo17
Avatar
0
ago 24
2691
readonly to a group and when the stage is in 2, 3, 4
xml studio odoo17
Avatar
Avatar
1
jun 24
2365
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar totalmente integrado.

Sitio web hecho con

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