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

Payroll: How to reference a 'Salary Rule Parameter'

Suscribirse

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

Se marcó esta pregunta
2 Respuestas
4513 Vistas
Avatar
Koos Kaspers

Since v15 its possible to create 'Salary Rule Parameters'. I'm trying to reference such a rule in a python code.

I'm aware of how to reference to, for example, an input parameter:



                    # Available variables:

                    #----------------------

                    # payslip: object containing the payslips

                    # employee: hr.employee object

                    # contract: hr.contract object

                    # rules: object containing the rules code (previously computed)

                    # categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).

                    # worked_days: object containing the computed worked days.

                    # inputs: object containing the computed inputs.


                    # Note: returned value have to be set in the variable 'result'


So in order to reference an input variable, this is the syntax:

                    result = inputs.variable_name.amount * 0.10


But the documentation is not showing how to reference the newly introduced 'Salary Rule Parameter'. I already tried:

rule_parameter.variable_name.amount

and some other combinations of the word rule and parameter, but to no avail. Anybody knows how to reference it?

1
Avatar
Descartar
Avatar
Rana Abdelsattar (abr)
Mejor respuesta

In v17, you can reference a rule parameter using the code payslip._rule_parameter('parameter_code')

0
Avatar
Descartar
Koos Kaspers
Autor

are you sure to include the "_" before rule?

Rana Abdelsattar (abr)

In v16 it would be payslip.rule_parameter('code') but in 17 you need to include "_" before.

Which version are you using?

Koos Kaspers
Autor

I'm on 17.0.

I just tried:

result = payslip._rule_parameter('abc')

And it's working as expected. Thank you so much!

Avatar
Renaud Desarzens
Mejor respuesta

I was able to use a rule parameter in v16 like this:

result = payslip.rule_parameter('NameOfRuleParameter')

It returns the parameter value of it respecting the valid from date specified in the rule parameter.

0
Avatar
Descartar
Sergey Vernyayev

argh. It gives me a nervous tick
- Error: <class 'AttributeError'>: "'hr.payslip' object has no attribute 'rule_parameter'" while evaluating

Koos Kaspers
Autor

Hmm, same problem here:

Fout: <class 'AttributeError'>: "'hr.payslip' object has no attribute 'rule_parameter'" while evaluating

Are you really sure, the synax is payslip.rule_parameter('<code-of-rule-paramter?') ?

Waleed Ali Mohsen

You can use
payslip.rule_parameter('code_of_parameter').

The below is details from Odoo 15.0 commit.

In a salary rule, you can directly use `payslip.rule_parameter(code)`.
The version valid at the payslip end date is automatically chosen.

To retrieve a parameter value at a particular date,
use `self.env['hr.rule.parameter']._get_parameter_from_code(code, date)`.
The date is optional and set to today by default.

Koos Kaspers
Autor

@Waleed, thanks for helping out. The first option you gave is already given by other people and is not working. I've tried the 2nd option you gave (retrieve a parameter value at a particular date) and this isn't working neither:

<class 'NameError'>: "name 'self' is not defined" while evaluating
"result = self.env['hr.rule.parameter']._get_parameter_from_code('abc', '2024-01-01')"

I'd say: please try it yourself. Create a "salary rule parameter" with code 'abc' and value '1'. Then create a "salary rule", choose 'python code' at 'amount type' and try to reference to the newly created salary rule parameter by entering:

result = payslip.rule_parameter('abc')

I'm pretty sure you will end up with the same error:

<class 'AttributeError'>: "'hr.payslip' object has no attribute 'rule_parameter'" while evaluating
"result = payslip.rule_parameter('abc')"

¿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 empresariales de código abierto que cubre 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.

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