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
    • eLearning
    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
    • Información
    • 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 taberna
    • 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
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • 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
    Browse all Industries
  • 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
    • Services for 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 override sale.report the right way?

Suscribirse

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

Se marcó esta pregunta
saleinheritodoo10
1 Responder
6617 Vistas
Avatar
Samo Arko

I've got a big problem, I overridden the sale.report like any other model, but when I delete the module it deletes the sale.report! This has probably something to do that sale.report isn't a table but a database view.

How I overridden it

class SaleReportGDPR(models.Model):
    _inherit = 'sale.report'


    def _from(self):
        from_str = """
                sale_order_line l
                      join sale_order s on (l.order_id=s.id)
                      join res_partner partner on (s.partner_id = partner.id and partner.personal_data=true)
                        left join product_product p on (l.product_id=p.id)
                            left join product_template t on (p.product_tmpl_id=t.id)
                    left join product_uom u on (u.id=l.product_uom)
                    left join product_uom u2 on (u2.id=t.uom_id)
                    left join product_pricelist pp on (s.pricelist_id = pp.id)
                    left join currency_rate cr on (cr.currency_id = pp.currency_id and
                        cr.company_id = s.company_id and
                        cr.date_start <= coalesce(s.date_order, now()) and
                        (cr.date_end is null or cr.date_end > coalesce(s.date_order, now())))    
        """
        return from_str

How is the right way to do this so I can upgrade my custom module so it won't delete the database view when I uninstall it? Now on uninstall it also breaks EVERY other database instance that uses the sale module so you can't see the product details when you select it. It just throws a ProgrammingError: relation "sale_report" does not exist!  

   

0
Avatar
Descartar
Avatar
Sunny Sheth
Mejor respuesta

Hello Samo Arko,


You don't need to Override, you can also use with call super()

 below example will help you in your case:

def _from(self):
    res = super(SaleReportGDPR, self)._from()
    from_str = res + """         here your query as per your requirement     """     return from_str


Thanks
0
Avatar
Descartar
Samo Arko
Autor

But I need to inherit sale report or where should put this? I think that the inherit sale report breaks the sale addon when I remove the custom module.

Sunny Sheth

hello,

my example already for Inherited sale.report,

I already used in my custom module and it will not breaks anything.

class sale_report(models.Model):

_inherit = 'sale.report'

event_id = fields.Many2one('event.event', string=_('Event'))

def _from(self):

res = super(sale_report, self)._from()

from_str = res + """

left join event_event e on e.id = s.event_id

"""

return from_str

def _select(self):

return super(sale_report, self)._select() + ", e.id as event_id"

def _group_by(self):

return super(sale_report, self)._group_by() + ", e.id"

Samo Arko
Autor

Ok... thanks I'll try it out.

Samo Arko
Autor

Nope this doesn't work! This would be useful if I'd wanted to add something to the original _from query. I need to change the query. But thanks for trying to help.

Samo Arko
Autor

from_str = """

left join event_event e on e.id = s.event_id

"""

This gets the same result like my code and when I uninstall it it also removes the sale_report database view!

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

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
website sale throws 500: Internal Server Error when entering address for confirmation of purchase. Resuelto
sale odoo10
Avatar
1
jul 18
4242
[odoo10] : How to inherit <templates> of web module? Resuelto
templates inherit odoo10
Avatar
Avatar
Avatar
18
dic 22
38702
How to pass values from sale to invoice (through invoiceable lines)
invoice sale odoo10
Avatar
0
jun 17
6042
How to assign the tax_id to the new field?
sale sale.order.line taxes odoo10
Avatar
Avatar
Avatar
8
sept 20
11623
Odoo 10 - Inherited template field appears depends upon position Resuelto
views fields inherit odoo10
Avatar
Avatar
2
mar 18
5448
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