Skip to main content

Time dependent parameters Adds the feature to define parameters with time based versions.

Project description

Beta License: LGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

A value may change over time. With this module you may set starting dates and values.

Table of contents

Configuration

The user needs the access right “Manage Time Parameters”.

Usage

Menu: “Settings/Technical/Time Parameters”

Create a parameter with different versions (start date and value).

If model_id is empty, any model/record may get the time parameter.

The value may be a text or reference.

Get the value like this:

# Pass no date: using today's date
value = model.get_time_parameter("parameter_code_or_name")
# Pass a date or datetime
value = model.get_time_parameter("parameter_code_or_name", date=datetime.datetime.now()))
# Pass the name of a date/datetime field of the record
value = record.get_time_parameter("parameter_code_or_name", "date")

Example of implementation in another module

Payroll implementation:

  • Menu “Payroll/Configuration/Time Parameters” only shows payslip parameters.

  • New parameters will get “model_id = payslip model”.

  • By default, the model_id field is hidden in the form.

<record id="base_time_parameter_action" model="ir.actions.act_window">
    <field name="name">Time Parameters</field>
    <field name="res_model">base.time.parameter</field>
    <field name="view_mode">tree,form</field>
    <field
        name="domain"
        eval="[('model_id', '=', ref('payroll.model_hr_payslip'))]"
    />
    <field
        name="context"
        eval="{'default_model_id': ref('payroll.model_hr_payslip')}"
    />
</record>
<menuitem
    id="menu_action_base_time_parameter"
    action="base_time_parameter_action"
    name="Time Parameters"
    parent="payroll_menu_configuration"
    sequence="35"
/>

Reference field implementatiton:

from odoo import api, fields, models

""" Add account.account to the model selection of the reference field """

class TimeParameterVersion(models.Model):
    _inherit = "base.time.parameter.version"

    value_reference = fields.Reference(
        selection="_value_reference_selection",
    )

    @api.model
    def _value_reference_selection(self):
        selection_models = self.env.context.get("selection_models", [])
        selection_models.append("account.account")
        return super(
            TimeParameterVersion,
            self.with_context(selection_models=selection_models)
        )._value_reference_selection()

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 smashing it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Nimarosa

  • appstogrow

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainers:

appstogrow nimarosa

This module is part of the OCA/server-tools project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file odoo14_addon_base_time_parameter-14.0.3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo14_addon_base_time_parameter-14.0.3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb6e795ab1e2a6ae6bec80ec9ede47c411010907198652cc0659f453f8d2e5f2
MD5 0b5887ce4574417e40dbd563e3ce4bc5
BLAKE2b-256 6741a1105f1eae60dc9268f8c6acb56de9e20bbb01679055953e14c7d11db1ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page