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

How to create selection that shows all incoming e-mail titles?

Suscribirse

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

Se marcó esta pregunta
1 Responder
4425 Vistas
Avatar
Yenthe Van Ginneken (Mainframe Monkey)

Hi guys

I would love to be able to get all e-mails that are sent to Odoo (so incoming on Odoo) in a dropdown in the project view. I then want to create a dropdown where the user can see every title of an email, choose one and save it on a project. The idea is that the user can also directly click on the item and that it opens up the correct e-mail.

Is this possible and how should I do it?
I assume it is possible since you have the model 'mail.mail' which contains all e-mails and you can fetch them in the view?

What I tried so far is to add a new field on the form from project_view.xml (<record id="edit_project" model="ir.ui.view">) by doing so:

<group col="4">
                            <field name="user_id" string="Project Manager"
                                    attrs="{'readonly':[('state','in',['close', 'cancelled'])]}"
                                    context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_manager']}"/>
                            <newline/>
                            <field name="partner_id" on_change="onchange_partner_id(partner_id)" string="Customer"/>
                <newline/>
               <field name="email_id" on_change="onchange_email_id(email_id)" string="Emails"/>
                        </group>

I then created the new field email_id in project.py in the columns = {} under the class project like this:

fields = {
//Lots of irrelevant code

'state': fields.selection([('template', 'Template'),
                                   ('draft','New'),
                                   ('open','In Progress'),
                                   ('cancelled', 'Cancelled'),
                                   ('pending','Pending'),
                                   ('close','Closed')],
                                  'Status', required=True, copy=False),
        'doc_count': fields.function(
            _get_attached_docs, string="Number of documents attached", type='integer'
        ),
        'email_id': fields.many2one(
            'mail.mail', '??', help='This holds all e-mails that you recieved.'),

     }

And finally in project.py I created an on_change function like this:

    def onchange_email_id(self, cr, uid, ids, part=False, context=None):
        email_obj = self.pool.get('mail.mail')
        return {'value': email_obj}

Everything looks pretty good but I get one more error when I want to create / modify a project:

 

So what am I doing wrong or am I missing?
Yenthe

1
Avatar
Descartar
Avatar
Ivan
Mejor respuesta

Why don't you use many2one field instead?  With the proper domain I believe it can achieve what you need.
Your many2one should look like this:

'email_id': fields.many2one(
            'mail.mail', '--', help='This holds all e-mails that you recieved.'),

Your XML like this (with a domain that filters on received e-mails):

<field name="email_id" on_change="onchange_email_id(email_id)" string="Emails" domain="[('state','=','Received')]"/>

1
Avatar
Descartar
Yenthe Van Ginneken (Mainframe Monkey)
Autor

Hmm good idea Ivan! I actually created a many2one field, like you suggested. 'email_id': fields.many2one( 'mail.mail', '??', help="This holds all e-mails that you recieved.'), so how can I filter this to only show e-mails that are recieved in Odoo and not sent? If I have that I'm almost done..

Ivan

mail.mail has a state field that can be ('outgoing', 'Outgoing'), ('sent', 'Sent'), ('received', 'Received'), ('exception', 'Delivery Failed'), ('cancel', 'Cancelled'). Maybe you can use that to filter incoming mails?

Yenthe Van Ginneken (Mainframe Monkey)
Autor

So how can I apply this in a domain / filter? I honestly haven't ever used them..

Ivan

You have 2 options, AFAIK, put the domain in the field definition, something like: 'email_id': fields.many2one('mail.mail', 'ee', domain=[('state', 'in', [list of the states])], required=True, copy=False). Or you can put it in the view: <field name="email_id" domain="[('state', 'in', [list of the states])]" string="Emails"/>

Yenthe Van Ginneken (Mainframe Monkey)
Autor

domain="[('state','=','received')]" seems to do the job perfect. I only have one error remaining,. I'll update my question for this, could you have a look at this in a few minutes please? I'll accept your answer afterwards.

Ivan

You seemed to inherit from model.Models but code using the old API way. Try to inherit from orm.Model instead?

Ivan

Is that (inheriting model.Models) it?

Yenthe Van Ginneken (Mainframe Monkey)
Autor

@Ivan I tried importing both at the top and this gives me the error from openerp import model.Models ^ SyntaxError: invalid syntax But I'm not sure how this would be related to this error? :s How could I alternatively fix this or do this in V8 code?

Yenthe Van Ginneken (Mainframe Monkey)
Autor

I had another fields.many2one which was screwing things up, so my bad! Its working perfect now. Is it okay that I update your answer with the final result? Then its a honest 'accepted' answer. I don't know who accepted it yet so :)

Ivan

No, it does not. You should be importing models instead: from openerp import models, fields, api, _. Usually you just inherit the class from models.Model not from the Model itself. I'm not well versed in v8 API. Sorry, I also missed that you used fields instead of _column. fields is a keyword in OpenERP. Maybe that is the cause.

Ivan

Yup. Go ahead.

Yenthe Van Ginneken (Mainframe Monkey)
Autor

Added my code in your answer. Alright thanks for the help Ivan! Upvoted & accepted.

Ivan

Pleasure to help.

¿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 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