[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:
william-andre
2023-04-06 18:18:06 +02:00
parent b5981bfd08
commit df47db1310
+11
View File
@@ -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.