| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 599 |
| Technical Name |
monetary_index_update |
| License | LGPL-3 |
| Website | https://github.com/KMEE/kmee-odoo-addons |
Monetary Index Update

Este é um módulo base que fornece a infraestrutura para atualizar valores monetários utilizando índices econômicos, como SELIC, IPCA, INPC, entre outros. Ele deve ser estendido por outros módulos que implementarão a funcionalidade específica para diferentes partes do sistema (vendas, contratos, faturas, etc.).
O módulo permite cadastrar e gerenciar índices monetários com suas respectivas taxas históricas, associadas a autoridades emissoras (como BACEN, IBGE) e países específicos. Também fornece um serviço de cálculo de correção monetária que pode ser utilizado por módulos dependentes.
Módulos que estendem este módulo base podem aplicar correções monetárias em campos específicos de seus modelos, selecionando o índice desejado e o período de atualização (data inicial e final), com prévia visualização dos valores atualizados antes da confirmação.
Table of contents
Usage
This is a base/technical module that provides the infrastructure for monetary updates. It should be used together with other modules that implement the specific functionality for different system models.
For End Users
The monetary update functionality will be made available through specific modules that extend this base module. Each implementing module may provide different ways to access the monetary correction feature (e.g., buttons, menu items, actions).
Using Monetary Update on Records
When the functionality is implemented in a model, you will typically use a wizard to apply monetary corrections. The wizard allows you to:
- Select a Monetary Index: Choose the economic index to use for correction (e.g., SELIC, IPCA, INPC)
- Set the Start Date: Define the original date of the monetary value
- Set the End Date: Define the date to which you want to correct the value
- Preview Changes: Review the updated values and percentage changes before applying
- Apply Correction: Confirm to update the monetary values
Note: The exact workflow and access method depends on how each specific module implements the monetary update functionality. Refer to the documentation of the module you are using for detailed instructions.
Viewing Monetary Indexes
To view the monetary indexes available in the system:
- Go to Settings > Monetary Indexes
- View the list of registered indexes (SELIC, IPCA, INPC, etc.)
- Click on an index to see its historical rates and detailed information
Note: Standard users can only view indexes. Only users with “Monetary Update Manager” permission can create, edit, or delete indexes.
For Monetary Update Managers
Managing Monetary Indexes
- Go to Settings > Monetary Indexes
- Click Create to add a new index
- Fill in the fields:
- Name: Index name (e.g., “SELIC”)
- Code: Unique code (e.g., “selic”)
- Authority: Issuing authority (e.g., “BACEN”, “IBGE”)
- Country: Country associated with the index
- Description: Detailed information about the index
Managing Historical Rates
- Open a monetary index form
- Go to the Rates tab
- Add historical rates:
- Date: Effective date of the rate
- Value: Percentage value of the rate
- Source: Data source (optional)
- Note: Additional notes (optional)
For Developers
To implement monetary correction in your custom modules, follow these steps:
1. Add Dependency
In your module’s __manifest__.py:
{ "name": "Your Module", "depends": [ "base_module", # your existing dependencies "monetary_index_update", ], # ... }
2. Extend Your Model
Inherit from monetary.update.service and specify which fields should be tracked:
from odoo import models, fields class YourModel(models.Model): _name = "your.model" _inherit = ["your.model", "monetary.update.service"] # Define which monetary fields should be updatable _fields_to_track = ["unit_price", "total_amount"] # Your model fields and methods...
3. Add UI Access
Provide a way for users to trigger the monetary update wizard. This can be done through:
Option A - Button in tree/form view:
<record id="view_your_model_tree_monetary" model="ir.ui.view"> <field name="name">your.model.tree.monetary</field> <field name="model">your.parent.model</field> <field name="inherit_id" ref="your_module.view_your_model_tree"/> <field name="arch" type="xml"> <xpath expr="//field[@name='line_ids']/tree" position="inside"> <button name="monetary_update_fields_by_index_wizard" type="object" icon="fa-calculator" title="Update by Monetary Index"/> </xpath> </field> </record>
Option B - Action in context menu, or any other UI pattern that fits your use case.
4. Using the Service Programmatically (Optional)
You can also use the monetary update service directly in your code:
# Calculate updated amount updated_amount = self.env["monetary.update.service"].compute_updated_amount( index_code="selic", amount=1000.00, start_date="2023-01-01", end_date="2024-01-01", )
Key Points
- The _fields_to_track attribute defines which monetary fields can be updated
- The wizard (monetary_update_fields_by_index_wizard) is automatically available once you inherit from monetary.update.service
- Users need appropriate permissions to see and use the monetary update functionality
- The wizard provides a preview before applying changes, allowing users to review the updated values
Refer to the source code and tests for complete implementation examples.
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Authors
- KMEE
Maintainers
This module is part of the KMEE/kmee-odoo-addons project on GitHub.
You are welcome to contribute.
Please log in to comment on this module