commit 49344a3a020d79eb7e3eaf8c399e23da1740c8a7 Author: Abdul Aziz Amrullah Date: Thu Apr 9 13:36:37 2026 +0700 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7213be3 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# POS Reward Point Digits (Odoo 19) + +## Overview +By default, the `reward_point_amount` field on the `loyalty.rule` model within the Odoo Point of Sale restricts inputs to the default 2 decimal places. + +This custom module adds a configurable setting inside of the Point of Sale setup screen to allow you to specify the exact number of decimal precision digits for reward points. + +## Features +- Overrides the `reward_point_amount` numeric field to utilize a dynamic Point of Sale configuration. +- Introduces a designated "Reward Point" Decimal Precision configuration. +- Provides an easy-to-access integer widget in `res.config.settings` for POS administrators to adjust precision without needing to touch backend code or data files. + +## Installation +1. Move the `pos_reward_point_digits` directory into your active Odoo 19 `custom` addons path. +2. Log into your Odoo 19 database as an Administrator. +3. Turn on **Developer Mode**. +4. Go to **Apps** -> **Update Apps List**. +5. Search for "POS Reward Point Digits". +6. Click **Activate**. + +## Configuration +1. Navigate to **Point of Sale -> Configuration -> Settings**. +2. Scroll to the **Pricing** section. +3. Locate the **Reward Point Digits** field. +4. Set your desired integer value (e.g. `3` or `4`) to allow that many digits behind the decimal place. +5. Click **Save**. + +Going forward, when accessing any Loyalty Program configuration rule, the grant reward setting (`reward_point_amount`) will properly respect the precision set within your Point of Sale configurations. + +## Technical Details +- **Module Dependence**: `point_of_sale`, `pos_loyalty`, `loyalty`. +- Modifies `ir.ui.view` `res_config_settings_view_form` to append to the Pricing ``. +- Generates `dp_reward_point` within Odoo's internal `decimal.precision` registry. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..9b3a22c --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,17 @@ +{ + 'name': 'POS Reward Point Digits', + 'version': '1.0', + 'category': 'Point of Sale', + 'summary': 'Configure the decimal precision of reward points in POS loyalty rules', + 'description': """ +This module allows administrators to configure the number of decimal places for the reward_point_amount field in loyalty programs directly from the Point of Sale settings. + """, + 'depends': ['point_of_sale', 'pos_loyalty', 'loyalty'], + 'data': [ + 'data/decimal_precision_data.xml', + 'views/res_config_settings_views.xml', + ], + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/data/decimal_precision_data.xml b/data/decimal_precision_data.xml new file mode 100644 index 0000000..d85964b --- /dev/null +++ b/data/decimal_precision_data.xml @@ -0,0 +1,9 @@ + + + + + Reward Point + 2 + + + diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..75eb0c0 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,2 @@ +from . import loyalty_rule +from . import res_config_settings diff --git a/models/loyalty_rule.py b/models/loyalty_rule.py new file mode 100644 index 0000000..0d312af --- /dev/null +++ b/models/loyalty_rule.py @@ -0,0 +1,6 @@ +from odoo import fields, models + +class LoyaltyRule(models.Model): + _inherit = 'loyalty.rule' + + reward_point_amount = fields.Float(digits='Reward Point') diff --git a/models/res_config_settings.py b/models/res_config_settings.py new file mode 100644 index 0000000..4028f0b --- /dev/null +++ b/models/res_config_settings.py @@ -0,0 +1,26 @@ +from odoo import api, fields, models + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + pos_reward_point_digits = fields.Integer( + string="Reward Point Digits", + config_parameter='pos_reward_point_digits', + default=2 + ) + + @api.model + def get_values(self): + res = super(ResConfigSettings, self).get_values() + precision = self.env.ref('pos_reward_point_digits.dp_reward_point', raise_if_not_found=False) + if precision: + res.update({ + 'pos_reward_point_digits': precision.digits, + }) + return res + + def set_values(self): + super(ResConfigSettings, self).set_values() + precision = self.env.ref('pos_reward_point_digits.dp_reward_point', raise_if_not_found=False) + if precision and precision.digits != self.pos_reward_point_digits: + precision.sudo().digits = self.pos_reward_point_digits diff --git a/views/res_config_settings_views.xml b/views/res_config_settings_views.xml new file mode 100644 index 0000000..015562f --- /dev/null +++ b/views/res_config_settings_views.xml @@ -0,0 +1,15 @@ + + + + res.config.settings.view.form.inherit.pos_reward_point_digits + res.config.settings + + + + + + + + + +