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 get the field values from another module?

Suscribirse

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

Se marcó esta pregunta
totalamountsaleorder
2 Respuestas
13390 Vistas
Avatar
William Draper

Hello,

I want to get the field values of the sale order amount_total and will be my input on the next page. Since I will create a new page that will calculate the quotation sales order total amount together its discounts. 

I tried to do this:     total_price = fields.Monetary('sale.order.amount_total', string="Price Initial") 

The result was my odoo went 500 status. compiler error. 

class sale_com(models.Model):
      _inherit ='sale.order'

     total_price = fields.Monetary('sale.order.amount_total', string="Price Initial")  <- this gave me an error

0
Avatar
Descartar
Avatar
Ashish Singh
Mejor respuesta

Hi, William

It is because you are trying to create related field using model name, but a related field required at relational field (Many2one) not model.

So in order to achieve this requirement you can use below ways.

  • Make it computed same as "amount_total" field like below

    • total_price = fields.Monetary(string='Price Initial', store=True, readonly=True, compute='_amount_all', tracking=4)
    • Inherit the "_amount_all" method,

      •     @api.depends('order_line.price_total')
            def _amount_all(self):
                """
                Compute the total amounts of the SO.
                """
                for order in self:
                    amount_untaxed = amount_tax = 0.0
                    for line in order.order_line:
                        amount_untaxed += line.price_subtotal
                        amount_tax += line.price_tax
                    order.update({
                        'amount_untaxed': amount_untaxed,
                        'amount_tax': amount_tax,
                        'amount_total': amount_untaxed + amount_tax,
                        'total_price': amount_untaxed + amount_tax,
                    })
  • Else instead of overriding existing computed method you can define your method like below,

    • total_price = fields.Monetary(string='Price Initial', store=True, readonly=True, compute='_total_price_method', tracking=4)
    • define the "_total_price_method" method,

      •     @api.depends('order_line.price_total')
            def _total_price_method(self):
                for order in self:
                    order.update({
                        'total_price': order.amount_total,
                    })
Feel free to ask in case you have any doubt related to the above point.


Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
1
Avatar
Descartar
Avatar
William Draper
Autor Mejor respuesta

I am still new to odoo development more like 2 weeks ago. Do you mean Inherit the "_amount_all" method is by creating a new function similar to this? For example:

class sale_commission(models.Model):
    _inherit = 'sale.order'

    
total_price = fields.Monetary(string='Price Initial', store=True, readonly=True, compute='_prod_price', tracking=4) @api.depends('order_line.price_total')

    def _prod_price(self):
        """
        Compute the total amounts of the SO.
        """
        for order in self:
            amount_untaxed = amount_tax = 0.0
            for line in order.order_line:
                amount_untaxed += line.price_subtotal
                amount_tax += line.price_tax
            order.update({
                'amount_untaxed': amount_untaxed,
                'amount_tax': amount_tax,
                'amount_total': amount_untaxed + amount_tax,
                'total_price': amount_untaxed + amount_tax,
            })

Thank you so much.

0
Avatar
Descartar
Ashish Singh

Hi, William

No for inheriting a method you need to define the method with the actual method name "_amount_all" not with the new name and as it is computed method then you need to define the same definition as actual method have.

If you don't want to inherit the existing method then you can simply define you function like below,

@api.depends('order_line.price_total')

def _prod_price(self):

for order in self:

order.update({

'total_price': order.amount_total,

})

Thanks,

¿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
How to modify amount_total from pos_order
order total amount
Avatar
Avatar
Avatar
4
may 16
5559
How to add a reduction amount to the amount total in POS order
order total amount coupon
Avatar
0
may 16
5411
Solve "Reference must be unique per company" following step by step Resuelto
saleorder
Avatar
Avatar
1
abr 24
4549
How to display 'total' under a column containing numeric values in tree view Resuelto
total
Avatar
Avatar
1
oct 24
26821
no currency symbol displayed at net amound and total price
currency price total amount symbol
Avatar
0
oct 21
3247
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.

Sitio web hecho con

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