moved formatLang monkey patch in misc.py like in Odoo codebase
This commit is contained in:
@@ -3,4 +3,3 @@ from . import partner
|
|||||||
from . import company
|
from . import company
|
||||||
from . import mail
|
from . import mail
|
||||||
from . import misc
|
from . import misc
|
||||||
from . import report_sxw
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import models, fields, api
|
||||||
|
from odoo.tools import misc
|
||||||
|
from odoo.tools import float_compare
|
||||||
|
|
||||||
|
|
||||||
class BaseLanguageExport(models.TransientModel):
|
class BaseLanguageExport(models.TransientModel):
|
||||||
@@ -15,3 +17,32 @@ class BaseLanguageInstall(models.TransientModel):
|
|||||||
_inherit = 'base.language.install'
|
_inherit = 'base.language.install'
|
||||||
|
|
||||||
overwrite = fields.Boolean(default=True)
|
overwrite = fields.Boolean(default=True)
|
||||||
|
|
||||||
|
|
||||||
|
class BaseUsabilityInstalled(models.AbstractModel):
|
||||||
|
_name = "base.usability.installed"
|
||||||
|
_description = "technical flag to see if base_usability module is installed"
|
||||||
|
|
||||||
|
|
||||||
|
formatLang_original = misc.formatLang
|
||||||
|
|
||||||
|
def formatLang(self, value, digits=None, grouping=True, monetary=False,
|
||||||
|
dp=False, currency_obj=False, int_no_digits=True):
|
||||||
|
with api.Environment.manage():
|
||||||
|
env = api.Environment(self.cr, self.uid, {})
|
||||||
|
if (
|
||||||
|
'base.usability.installed' in env and
|
||||||
|
int_no_digits and
|
||||||
|
not monetary and
|
||||||
|
isinstance(value, float) and
|
||||||
|
dp):
|
||||||
|
prec = env['decimal.precision'].precision_get(dp)
|
||||||
|
if not float_compare(value, int(value), precision_digits=prec):
|
||||||
|
digits = 0
|
||||||
|
dp = False
|
||||||
|
res = formatLang_original(
|
||||||
|
self, value, digits=digits, grouping=grouping, monetary=monetary,
|
||||||
|
dp=dp, currency_obj=currency_obj)
|
||||||
|
return res
|
||||||
|
|
||||||
|
misc.formatLang = formatLang
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import models, api
|
|
||||||
from odoo.tools import misc
|
|
||||||
from odoo.tools import float_compare
|
|
||||||
|
|
||||||
|
|
||||||
class BaseUsabilityInstalled(models.AbstractModel):
|
|
||||||
_name = "base.usability.installed"
|
|
||||||
|
|
||||||
|
|
||||||
formatLang_original = misc.formatLang
|
|
||||||
|
|
||||||
def formatLang(self, value, digits=None, grouping=True, monetary=False,
|
|
||||||
dp=False, currency_obj=False, int_no_digits=True):
|
|
||||||
with api.Environment.manage():
|
|
||||||
env = api.Environment(self.cr, self.uid, {})
|
|
||||||
if (
|
|
||||||
'base.usability.installed' in env and
|
|
||||||
int_no_digits and
|
|
||||||
not monetary and
|
|
||||||
isinstance(value, float) and
|
|
||||||
dp):
|
|
||||||
prec = env['decimal.precision'].precision_get(dp)
|
|
||||||
if not float_compare(value, int(value), precision_digits=prec):
|
|
||||||
digits = 0
|
|
||||||
dp = False
|
|
||||||
res = formatLang_original(
|
|
||||||
self, value, digits=digits, grouping=grouping, monetary=monetary,
|
|
||||||
dp=dp, currency_obj=currency_obj)
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
misc.formatLang = formatLang
|
|
||||||
Reference in New Issue
Block a user