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

Inherit partner_id from account.payment with different domain. How to do it?

Suscribirse

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

Se marcó esta pregunta
inheritancepaymentsodoo12.0
2 Respuestas
6773 Vistas
Avatar
Paulo Matos

Hello everyone,

I am working with Odoo 12 and having a problem on setting a domain on a form view for the account.payments model.

What I need to do is to show only users (partner_id) that has the field "parent_id" = False under partner_id field.

I have successfully tried on the account.invoice and changed the xml for the form view to:

       <record id="mymodule_form_view_account_invoice" model="ir.ui.view">
           <field name="name">Account Invoice Hide Children Partners</field>
           <field name="model">account.invoice</field>
           <field name="inherit_id" ref="account.invoice_form"/>
           <field name="arch" type="xml">
                <xpath expr="//field[@name='partner_id']" position="replace">
                       <field string="Customer" name="partner_id" widget="res_partner_many2one" context="{'search_default_customer':1, 'show_address': 1, 'default_is_company': True, 'show_vat': True}" options="{"always_reload": True, "no_quick_create": True}" domain="[('customer', '=', True),('parent_id', '=', False)]" required="1"/>
                </xpath>
          </field>
      </record>

I was able to hide partners with "parent_id" using the domain:

       domain="[('customer', '=', True),('parent_id', '=', False)]" required="1"

Tried to do the same for the account.payment model and was unable to achieve what I want.

I can see that on the account.payment form view there's a "partner_id" field and tried to:

       <field name="partner_id" domain="[('parent_id', '=', False)]" attrs="{'required': [('state', '=', 'draft'), ('payment_type', 'in', ('inbound', 'outbound'))], 'invisible': [('payment_type', 'not in', ('inbound', 'outbound'))], 'readonly': [('state', '!=', 'draft')]}" context="{'default_is_company': True, 'default_supplier': payment_type == 'outbound', 'default_customer': payment_type == 'inbound'}"/>

...and it does not work.

Using debug mode with mouse over the field, I can see that the domain is applied but it simple does not work.

Then, I have noticed that, in fact there is no "partner_id" on the account.payment form. This field in on the "account.abstract.payment" abstract model that is shared among models which allows to register payments.

Since I cannot find any related xml id for this model for changing the partner_id default values, I have tried to directly (for testing purposes) change the field definition to:

      _name = "account.abstract.payment"
      ....
      ....
      partner_id = fields.Many2one('res.partner', string='Partner', domain=lambda self: [("parent_id", "=", "False")])

Even adding the domain above on the field definition, I am unable to achieve what I need.

Can anyone help me please?

Thank you all in advance

Best regards

PM

0
Avatar
Descartar
Avatar
Avinash Nk
Mejor respuesta

Hello Paulo Matos,

Like the way you expected, this problem is not because of that

This is happening because there is an onchange function in account.payment model that returns the domain of the partner_id.

So even if you put some domains in XML, it overrides by that function.

This onchange function is work when you change the partner_type field. so it will always execute when you create a new record.

So better you have to override that function.

Like this.


@api.onchange('partner_type')
def _onchange_partner_type(self):
self.ensure_one()
# Set partner_id domain
if self.partner_type:
return {'domain': {'partner_id': [(self.partner_type, '=', True), ('parent_id', '=', False)]}}



Code is not tested. I hope it will work.

Anyway, I think you get some idea about this.


Edited Part:

----

This code is for inheriting the function instead of the override.

@api.onchange('partner_type')
def _onchange_partner_type(self):
res = super(YourClass, self)._onchange_partner_type()
if 'domain' in res:
if 'partner_id' in res['domain']:
res['domain']['partner_id'].append(('parent_id', '=', False))
else:
res['domain']['partner_id'] = [('parent_id', '=', False)]
return res
else:
return {'domain': {'partner_id': [('parent_id', '=', False)]}}


-----

Thanks & Regards

Avinash N K


1
Avatar
Descartar
Paulo Matos
Autor

@Avinash,

Thank you very much for your help and time.

The code itself did not work but with your help I get an idea of what the problem is.

Thank you very very much

Best regards

PM

Avinash Nk

Hi EuroGold,

I update some code for you. check if it helps you.

Thanks

Paulo Matos
Autor

@Avinash,,

Thank you once again.

Your code worked exactly as expected.

Thank you very much once again

Best regards

PM

Avatar
Arturo Velázquez
Mejor respuesta

Hello Avinash & Paulo.

I'm facing the same issue, I am unable to change the domain of partner_id field on account.payments model.  I see Avinash posted the solution to this problem, but I don't know how and where to put the code for inherit the onchange function.  Can someone put me in the right direction?  Best regards

0
Avatar
Descartar
¿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
Inherit a method without copy/paste full original code Resuelto
inheritance odoo12.0
Avatar
Avatar
1
sept 19
4501
How to inherit view and add widget in Odoo 12CE ? Resuelto
form inheritance odoo12.0
Avatar
1
ago 23
6621
how to use model inheritance on the existing Product model to add some field for my new module ? Resuelto
inheritance product.product Module odoo12.0
Avatar
Avatar
Avatar
4
abr 19
9271
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
Avatar
Avatar
Avatar
2
oct 25
1969
When registering payment, i get "can't create a new payment without an outstanding payments/receipts account set"
payments
Avatar
Avatar
1
abr 25
2967
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