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 pub
    • 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
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • 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
    Explorar todos los sectores
  • 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
    • Servicios para 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

v13 : Tree/Many2one add dynamic domain according value in parent.field

Suscribirse

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

Se marcó esta pregunta
3 Respuestas
4015 Vistas
Avatar
"Vincent DUBREIL"

Hello,

Here is my problem

In account.move form, there is an invisible field Type wich can take values (in_invoice, out_invoice,...)

In the one2many field invoie_line_ids, there is a column "analytic_account_id"

I need to change the domain of this column according i'm in an in_invoice type or out_invoice type.


I tried with a syntax like ('parent.type', '=', 'in_invoice') but it seems that parent can be used only on the right of the '='


How can i do that?

0
Avatar
Descartar
Avatar
Malay Khamar (Serpent Consulting Services Pvt. Ltd.)
Mejor respuesta

Hi Vincent DUBREIL,

Can you please share your full requirement. Because yes in the domain, you can not use parent in the left side of the domain arguments, but in the attrs yes you can use. You can try the below two options that might be work for you.

If you are going specific to the domain then you can try the Many2one field (move_id) of your One2many field (invoie_line_ids) just like ('move_id.type', '=', 'in_invoice'). 

Another one is the related field. You can create the related field of the parent type field in the invoie_line_ids model and try with that related field insted of the parent type : ('related_field_type', '=', 'in_invoice').

Hope it will help you.

Updated Answer:
Ok as per your requirement, you can add this domain on the analytic account field in invoice lines tree view: 

              domain="context.get('default_move_type') in ('out_invoice', 'out_refund', 'out_receipt') and [('name', 'ilike', 'FCT_')]"


Hope it will help you.

2
Avatar
Descartar
"Vincent DUBREIL"
Autor

Hi Malay,
could you, please, give me more informations according my last answer because i still haven't found the solution!

Malay Khamar (Serpent Consulting Services Pvt. Ltd.)

Hi Vincent DUBREIL,

Ok as per Your requirement, you can add this domain into the analytic account field in invoice lines tree view.

domain="context.get('default_move_type') in ('out_invoice', 'out_refund', 'out_receipt') and [('name', 'ilike', "FCT_")]"

"Vincent DUBREIL"
Autor

Hi Malay,

Sorry for the delay
I tried your solution but it doesn't works
error : TypeError: CreateListFromArrayLike called on non-object

Are you sure of this syntax because every similar examples i found, context.get is always on the right side of the domain arguments.
Like : domain="[('id', 'in', context.get('product_ids', []))]"

"Vincent DUBREIL"
Autor

Find part of the problem.
I'm always on version 13 of Odoo and the field is type, not move_type.
But the error is always the same.

I tried to change the syntax like that :
[(context.get('default_type'), 'in', ['in_invoice', 'in_refund', 'in_receipt'])]

But i've got the following error :
ValueError: Invalid field 'in_invoice' in leaf "<osv.ExtendedLeaf: ('in_invoice', 'in', ['in_invoice', 'in_refund', 'in_receipt']) on account_analytic_account (ctx: )>"

Malay Khamar (Serpent Consulting Services Pvt. Ltd.)

Hi Vincent DUBREIL,

Ok, As i see, you have added the condition in the list of tuple , Please try with direct condition as we use it in the domain like this instead of the list of tuple :

domain="context.get('default_type') in ('in_invoice', 'in_refund', 'in_receipt')"

Yes you can add the domain list of tuples after the conditions like:

domain="context.get('default_type') in ('in_invoice', 'in_refund', 'in_receipt') and [('name', 'ilike', 'FCT_')]"

If you pass the domain with list and tuple type, then yes you need the field exist in the domain field model. But you can also add the condition and the domain combination as well .

For reference please check this:

(field name="product_id"
domain="context.get('default_type') in ('out_invoice', 'out_refund', 'out_receipt')
and [('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]
or [('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]
"/)

Hope it will help you.

Avatar
Adil Akbar
Mejor respuesta

You can follow this: https://youtu.be/XGqXEL2qQmE

Hope it helps,

Thanks

0
Avatar
Descartar
Avatar
"Vincent DUBREIL"
Autor Mejor respuesta

Hi Malay,

thank you for your answer.

Here is my full requirement :

In the view, account.view_move_form, there is the field "invoice_line_ids" with the many2one column "account_analytic_id" linked to the model account.account.

This view is the same used for customer invoices or vendors bills (and refund, receipt,...)

But i need, according the type of the account.move record, to fill this m2o 'account_analytic_id" with differents values.

for types in ("out_invoice","out_refund","out_receipt"), fill with account.account start with "FCT_"

for all other types, fill with all others account_account (except "FCT_")


Hope it is clear enough.

0
Avatar
Descartar
"Vincent DUBREIL"
Autor

Finally i found a solution with a dynamic domain return by python function with @onchange like :

@api.onchange('product_id')
def onchange_product_id(self):
if self.move_id.type in ('in_invoice','in_refund','in_receipt'):
res = {
'domain' : {
'analytic_account_id' : [('name', 'ilike', "FCT_")],
}
}
else:
res = {}

return res

Malay Khamar (Serpent Consulting Services Pvt. Ltd.)

Hi Vincent DUBREIL,
Please check the updated andwer to add domain.

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

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

Inscribirse
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 empresariales de código abierto que cubre 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