| 1 |
|
| 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 |
|
| 18 |
|
| 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) |