[IMP] base: add format to res.currency
`res.currency` already has some utilitises like `round` or `compare_amounts` but until now we always needed to import `format_amount` from the tools in order to format. This commit unifies the API. X-original-commit: 3517a0fece96dd5d0deb02c9fd973444e748986b Part-of: odoo/odoo#117964
This commit is contained in:
@@ -188,6 +188,17 @@ class Currency(models.Model):
|
||||
)
|
||||
return amount_words
|
||||
|
||||
def format(self, amount):
|
||||
"""Return ``amount`` formatted according to ``self``'s rounding rules, symbols and positions.
|
||||
|
||||
Also take care of removing the minus sign when 0.0 is negative
|
||||
|
||||
:param float amount: the amount to round
|
||||
:return: formatted str
|
||||
"""
|
||||
self.ensure_one()
|
||||
return tools.format_amount(self.env, amount + 0.0, self)
|
||||
|
||||
def round(self, amount):
|
||||
"""Return ``amount`` rounded according to ``self``'s rounding rules.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user