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
    • 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 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 make Analytic Account field as a required field?

Suscribirse

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

Se marcó esta pregunta
accountingodoov12
3 Respuestas
5800 Vistas
Avatar
Sameer Ahmad

According to my requirement i need the Analytic Account field as mandatory in invoice line items and also journal entry line items. I have inherited and defined both of them as required=True.

Now when i validate a invoice the default odoo behavior saves some items in account_move_line table and as i defined the field analytic_account_id as required, when it tries to save or insert the data, it is throwing me a not null constraint error.

As a workaround i have removed the required=True in journal entry screen and i override the create and write methods to check for the same, below is my code

@api.model
def create(self, vals):
res = super(AccountMoveInherited, self).create(vals=vals)
lines = vals.get('line_ids')
if lines:
for line in lines:
values = line[2]
if values.get('analytic_account_id'):
continue
if not
values.get('analytic_account_id'):
raise UserError(_("Some Journal Entry items are missing "
"Analytic Account field, Please add them and try again."
))
return res

@api.multi
def write(self, vals):
res = super(AccountMoveInherited, self).write(vals=vals)
lines = vals.get('line_ids')
if lines:
for line in lines:
values = line[2]
if values.get('analytic_account_id'):
continue
if not
values.get('analytic_account_id'):
raise UserError(_("Journal Entry item(s) are missing "
"Analytic Account field, Please add them and try again."
))
return res

It works just fine but now when i try to validate an invoice, it is throwing me this error. I have wasted my 4 hours of time figuring this and implementing it and now i'm right at where i started.

Can anyone tell me a good approach to achieve my required functionality as i'm out of ideas and don't know how can i achieve the functionality anymore

0
Avatar
Descartar
Avatar
Sameer Ahmad
Autor Mejor respuesta

I have noticed that when data is entered into invoice line items, the tax and ar/ap account data is being fed and stored in the account_move_line table and since tax is being  aggregated and stored as a single entry for all the invoice line items of a particular invoice, the analytic account wasn't being passed and stored into the table and since we made analytic_account_id as a required field, it was throwing an error. So as a temporary workaround i have hardcoded to add the analytic account of id 1 to all the items that are getting stored in account_move_line when an invoice is validated.

0
Avatar
Descartar
Avatar
Ahmed Salah
Mejor respuesta

Hello,

you have to decide where exactly you need to check for analytic account. (create, edit, validate)

check before applying the validate

--> if in validate then you can just inherit the method which create the entry data.

I hope this is helpful for you


-1
Avatar
Descartar
Sameer Ahmad
Autor

I'm sorry but i'm afraid you didn't get my question correctly

¿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
How to modify Balance Sheet report?
accounting reports odoov12
Avatar
Avatar
1
mar 19
8202
I found a small typo in the Odoo 19 Chart of Accounts — and it made my day 😆 Resuelto
accounting
Avatar
Avatar
Avatar
2
nov 25
219
Invoice-Digitize-Individual Line Items
accounting
Avatar
Avatar
1
nov 25
451
Guía~Básica¿Cómo hablo con una persona en vivo en Delta?
accounting
Avatar
0
nov 25
3
How can I manipulate the email template when sending an email in Accounting so that my PDF with the XML is inserted instead of the standard view with XML?
accounting
Avatar
Avatar
1
nov 25
305
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