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

Odoo custom module fix taxes order line?

Suscribirse

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

Se marcó esta pregunta
codetaxordertax_id13
2 Respuestas
5771 Vistas
Avatar
Gargano Dok Scarl

I'm a Odoo user (not developer). I have a custom module that have a bug, I'm trying to understand how fix bug, but I don't find solution. I think code interested is in model file. Module, by barcode scanning in a custom field, add product line in Order with Product, Description, Qty, Unit price, but missing taxes. If same product barcode is scanned more time, is increase quantity in same product line. Bug issue is Not add product Taxes, so I have a product line without taxes. I've seen inside code, and there is not any command that invokes Taxes.

Please, anyone can help me to fix this, and say me correct code to add? I'm not a developer, I don't know nothing about code and programming.

------------First code part:  

# added the price history map

priceHistory = {}

class SaleOrder(models.Model):
"""Inherit Sale Order."""

_inherit = "sale.order"
barcode = fields.Char(string='Barcode', size=50)


def _add_product(self, product, qty, price):
"""Add line or update qty and price based on barcode."""
corresponding_line = self.order_line.filtered(lambda r: r.product_id.id == product.id)
if corresponding_line:
corresponding_line[0].product_uom_qty += float(qty)
corresponding_line[0].price_unit = float(price) or product.list_price
else:
self.order_line += self.order_line.new({
'product_id': product.id,
'product_uom_qty': qty,
'name': product.name,
'product_uom': product.uom_id.id,
'price_unit': float(price) or product.list_price,
})
return True

------------ Last code part 

            if product_id:                 # get the history price
                if price_position == -1:
                    #if priceHistory.has_key(product_id.id):
                    if product_id.id in priceHistory.keys():
                        price = priceHistory[product_id.id]

                self._add_product(product_id, qty, price)
                self.barcode = barcode = None

                #save the product price
                priceHistory[product_id.id] = price
                return

​Here I've tried to add:

  'tax_id' : account.tax

belowe line

'price_unit': float(price) or product.list_price,
but is not correct, I have error

Thank you very much


0
Avatar
Descartar
Avatar
Gargano Dok Scarl
Autor Mejor respuesta

Hi  Zbik, thank you very much for your help, your code in sale order work perfect!!

I've tryed to replicate it in purchase order also (because module work in Purchase order, Account move and Stock Picking also) but in Purchase I have error.  Can you see if I need adapt it in purchase? Please can you help me again like in sale order.

This is code I've used, what I mistake?  Thanks very much

class PurchaseOrder(models.Model):
"""Inherit Purchase Order."""

_inherit = "purchase.order"
barcode = fields.Char(string='Barcode', size=50)


def _add_product(self, product, qty, price):
"""Add line or update qty and price based on barcode."""
corresponding_line = self.order_line.filtered(lambda r: r.product_id.id == product.id)
taxes = product.taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
taxes_ids = taxes.ids

if corresponding_line:
corresponding_line[0].product_qty += float(qty)
corresponding_line[0].price_unit = float(price) or product.list_price
if self.partner_id and self.fiscal_position_id:
taxes_ids = self.fiscal_position_id.map_tax(taxes, product, self.partner_id).ids

else:
self.order_line += self.order_line.new({
'product_id': product.id,
'product_qty': qty,
'date_planned': fields.Datetime.to_string(datetime.datetime.now() - dateutil.relativedelta.relativedelta(months=1)),
'name': product.name,
'product_uom': product.uom_id.id,
'price_unit': float(price) or product.list_price,
'tax_id': [(6, 0, taxes_ids)],
})
return True
                
            
1
Avatar
Descartar
Zbik

You calculate taxes_ids before ... if corresponding_line

Gargano Dok Scarl
Autor

Hi Zbik thanks, I've solved yesterday. If you can, can yoy give me a suggestion for this https://www.odoo.com/it_IT/forum/help-1/question/custom-module-how-fix-bug-price-order-line-163337 It's a new bug I've found. Thank you very much

Avatar
Zbik
Mejor respuesta

You must first calculate the taxes that should be applied based on your partner, company and fiscal position.
For example, int this way:

taxes = product.taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
taxes_ids = taxes.ids
if self.partner_id and self.fiscal_position_id:
taxes_ids = self.fiscal_position_id.map_tax(taxes, product, self.partner_id).ids


Finally apply:

'tax_id': [(6, 0, taxes_ids)],

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
[SOLVED] Get and Set default tax by Python command line Resuelto
tax tax_id
Avatar
Avatar
4
ene 16
11233
Setting up the tax on the total not per product
tax order
Avatar
0
mar 15
3463
Create custom Group Tax with custom module Resuelto
tax tax_id account.tax
Avatar
Avatar
1
may 18
6904
How to show only Tax Name on Invoices
code invoice tax
Avatar
Avatar
1
mar 15
12525
"Incompatible companies on records" when adding "tax_id" to an order line through API
orders tax tax_id order.line
Avatar
0
abr 24
1925
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