diff --git a/hr_expense_usability/__init__.py b/hr_expense_usability/__init__.py index 23553c5..2be8a21 100644 --- a/hr_expense_usability/__init__.py +++ b/hr_expense_usability/__init__.py @@ -2,4 +2,3 @@ from . import hr_expense from .post_install import create_private_car_km_prices -from .pre_install import create_decimal_precision diff --git a/hr_expense_usability/__manifest__.py b/hr_expense_usability/__manifest__.py index 9008d2d..2cac0bf 100644 --- a/hr_expense_usability/__manifest__.py +++ b/hr_expense_usability/__manifest__.py @@ -14,6 +14,7 @@ 'website': 'http://www.akretion.com', 'depends': [ 'hr_expense_sequence', + 'hr_expense_usability_dp', ], 'data': [ 'hr_expense_data.xml', @@ -24,7 +25,6 @@ 'security/expense_security.xml', 'security/ir.model.access.csv', ], - 'pre_init_hook': 'create_decimal_precision', 'post_init_hook': 'create_private_car_km_prices', 'demo': ['private_car_demo.xml'], 'installable': True, diff --git a/hr_expense_usability/pre_install.py b/hr_expense_usability/pre_install.py deleted file mode 100644 index cfd420a..0000000 --- a/hr_expense_usability/pre_install.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion (Alexis de Lattre ) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, SUPERUSER_ID - - -# I can't create decimal precision via hr_expense_data.xml because it's -# too "late" in the module installation process: in this case, -# demo data and post_install.py data have a unit_amount truncated at 2 digits -# That's why I create the decimal precision via a pre_init_hook -def create_decimal_precision(cr): - with api.Environment.manage(): - env = api.Environment(cr, SUPERUSER_ID, {}) - env['decimal.precision'].create({ - 'name': 'Expense Unit Price', - 'digits': 3, - }) diff --git a/hr_expense_usability_dp/README.rst b/hr_expense_usability_dp/README.rst new file mode 100644 index 0000000..45aaf4d --- /dev/null +++ b/hr_expense_usability_dp/README.rst @@ -0,0 +1,13 @@ +====================================== +HR Expense Usability Decimal Precision +====================================== + +I want to be able to have a decimal precision different from the default 'Product Price' precision. But, if I create this new decimal precision via the XML data of the *hr_expense_usability* module, it won't apply on demo data nor data created via post_install script, because it's too "late" in the module installation process. I tried to create this new decimal precision via a *pre_init_hook*, but it doesn't work. So I decided to make a small module that only creates this decimal precision and the *hr_expense_usability* module depends on it. + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre diff --git a/hr_expense_usability_dp/__init__.py b/hr_expense_usability_dp/__init__.py new file mode 100644 index 0000000..633f866 --- /dev/null +++ b/hr_expense_usability_dp/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- + diff --git a/hr_expense_usability_dp/__manifest__.py b/hr_expense_usability_dp/__manifest__.py new file mode 100644 index 0000000..8fabc5d --- /dev/null +++ b/hr_expense_usability_dp/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'HR Expense Usability Decimal Precision', + 'version': '10.0.1.0.0', + 'category': 'Human Resources', + 'license': 'AGPL-3', + 'summary': 'Technical module for hr_expense_usability', + 'description': '', + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['hr_expense'], + 'data': [ + 'decimal_precision_data.xml', + ], + 'installable': True, +} diff --git a/hr_expense_usability_dp/decimal_precision_data.xml b/hr_expense_usability_dp/decimal_precision_data.xml new file mode 100644 index 0000000..89c387e --- /dev/null +++ b/hr_expense_usability_dp/decimal_precision_data.xml @@ -0,0 +1,14 @@ + + + + + + + Expense Unit Price + + + +