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

How to set filter on a pre-defined field of another model

Suscribirse

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

Se marcó esta pregunta
filteroverridefilter_domainodoo16features
3 Respuestas
3600 Vistas
Avatar
Masood Zarei

Hi friends,

I have a new model that aims to extend 'res.partner' model.

Now, I want to set a filter on the 'country_id' field of 'res.partner' model to show just some countries that their's list is set in Config Params(For this, I've also set a new field in the Config Params that the user can choose some countries, so I want the field of Country in the contact page to show just those selected ids).

How can I do that? What is the best solution?


I've done the following:

widly_used_countries=fields.Many2many(
​string='Widly Used Countries',
​comodel_name="res.country",
​compute="_compute_widly_used_countries",
​store=True
)

def_compute_widly_used_countries(self):
​country_ids=eval(self.env['ir.config_parameter'].sudo().get_param('exchange.widely_used_countries'))
​domain=[('id', 'in', country_ids)]
​self.widly_used_countries=self.env['res.country'].search(domain)

And my soultion is to override country_id field as follow:

country_id=fields.Many2one(

​comodel_name="res.country",

​​domain="[('id', 'in', widly_used_countries)]"

)


And now when I upgrade the module, Odoo raises the error that the 'widly_used_countries' should be presented in the view.

To do so, I've also defined a new view inheriting the 'base.view_partner_form'.

But in each place I put 'widly_used_countries', the Odoo error still remains.

I don't know why?


0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi

The error that you are getting is because the widly_used_countries field is not defined in the view that you are inheriting. To fix this, you need to add the widly_used_countries field to the view.
 You can do this by adding the following code to the view:
 <field name="widly_used_countries" widget="many2many_list" />

Hope it helps

0
Avatar
Descartar
Avatar
CandidRoot Solutions Private Limited
Mejor respuesta

Hello 

i have checked your exising code. i would suggest you to inherit res.partner form view and add domain in view for country_id field as below instead of writing in python code.

domain="[('id', 'in', widly_used_countries)]"

Thanks & Regards,

​

CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat

0
Avatar
Descartar
Avatar
Mehjabin Farsana
Mejor respuesta

Hi,

It looks like the error that you are facing is due to the view inheritance.

please make sure that , you have the widly_used_countries field available in the res.partner model to avoid any issues during view inheritance.


Define a new view in your custom module that inherits the base.view_partner_form view and add your field in this view



Hope this will help you

thanks



0
Avatar
Descartar
Masood Zarei
Autor

As I said, I did what you offered

¿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
Odoo16 CE: add search filter for CRM activity deadline through frontend
filter_domain odoo16features
Avatar
Avatar
1
jul 23
2868
Filter One2many field in res.partner Resuelto
filter one2many odoo16features
Avatar
Avatar
1
ene 24
2606
v16: Domain filter is not working in categ_id ( Product Category )
filter domain odoo16features
Avatar
Avatar
1
oct 23
2569
odoo16: filter with List of distinct Mobile numbers to select
filter activity odoo16features
Avatar
1
sept 23
2520
How to filter records based on a parent field's id Resuelto
many2many filter_domain odoo16features
Avatar
Avatar
2
mar 23
3703
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.

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