initial commit

This commit is contained in:
Abdul Aziz Amrullah 2026-04-09 13:36:37 +07:00
commit 49344a3a02
9 changed files with 110 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

33
README.md Normal file
View File

@ -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 `<block>`.
- Generates `dp_reward_point` within Odoo's internal `decimal.precision` registry.

1
__init__.py Normal file
View File

@ -0,0 +1 @@
from . import models

17
__manifest__.py Normal file
View File

@ -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',
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="dp_reward_point" model="decimal.precision">
<field name="name">Reward Point</field>
<field name="digits">2</field>
</record>
</data>
</odoo>

2
models/__init__.py Normal file
View File

@ -0,0 +1,2 @@
from . import loyalty_rule
from . import res_config_settings

6
models/loyalty_rule.py Normal file
View File

@ -0,0 +1,6 @@
from odoo import fields, models
class LoyaltyRule(models.Model):
_inherit = 'loyalty.rule'
reward_point_amount = fields.Float(digits='Reward Point')

View File

@ -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

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.pos_reward_point_digits</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//block[@id='pos_pricing_section']" position="inside">
<setting id="reward_point_digits" string="Reward Point Digits" help="Set the number of decimal precision digits for reward points.">
<field name="pos_reward_point_digits" widget="integer"/>
</setting>
</xpath>
</field>
</record>
</odoo>