Debian Codegraph @

addons/l10n_gcc_invoice/models/product.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 import re
4
5 from odoo import models
6
7
8 class ProductProduct(models.Model):
9 _inherit = 'product.product'
10
11 def _compute_display_name(self):
12 """ In a string consisting of space-delimited substrings, force a double-space between
13 substrings where (when looking right to left) the first substring ends with a numeral and
14 the second begins with an Arabic character.
15 """
16 def repl(match_occurrence):
17 # group(1): (\d) == numeral
18 # group(3): ([\u0600-\u06FF]) == Arabic character
19 return f'{match_occurrence.group(1)} {match_occurrence.group(3)}'
20
21 super()._compute_display_name()
22 for product in self:
23 if product.display_name:
24 product.display_name = re.sub(r'(\d)(\s)([\u0600-\u06FF])', repl, product.display_name)