Skip to content
Snippets Groups Projects
Commit 77c8a0d8 authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Add flag symbol for country and subdivision

issue11599
review433291003
parent 68b41353
No related branches found
No related tags found
1 merge request!114Return an empty list when the treeview has no selection
* Add flag symbol for country and subdivision
Version 6.4.0 - 2022-05-02
* Bug fixes (see mercurial logs for details)
* Use Tryton's CDN to download postal codes
......
......@@ -19,6 +19,7 @@
help="The 3 chars ISO country code.")
code_numeric = fields.Char('Numeric Code', select=True,
help="The ISO numeric country code.")
flag = fields.Function(fields.Char("Flag"), 'on_change_with_flag')
subdivisions = fields.One2Many('country.subdivision',
'country', 'Subdivisions')
......@@ -49,6 +50,17 @@
cursor.execute(*data.delete(where=(data.module == 'country')
& (data.model == cls.__name__)))
@fields.depends('code')
def on_change_with_flag(self, name=None):
if self.code:
return ''.join(map(chr, map(lambda c: 127397 + ord(c), self.code)))
def get_rec_name(self, name):
name = self.name
if self.flag:
name = ' '.join([self.flag, self.name])
return name
@classmethod
def search_rec_name(cls, name, clause):
code_value = clause[2]
......@@ -93,6 +105,7 @@
help="The main identifier of the subdivision.")
code = fields.Char('Code', required=True, select=True,
help="The ISO code of the subdivision.")
flag = fields.Function(fields.Char("Flag"), 'on_change_with_flag')
type = fields.Selection([
(None, ""),
('administration', 'Administration'),
......@@ -266,6 +279,13 @@
# Migration from 6.2: remove type required
table_h.not_null_action('type', action='remove')
@fields.depends('code')
def on_change_with_flag(self, name=None):
if self.code:
return '🏴' + ''.join(map(chr, map(
lambda c: 917504 + ord(c),
self.code.replace('-', '').lower()))) + '\U000e007f'
@classmethod
def search_rec_name(cls, name, clause):
return ['OR',
......
......@@ -2,6 +2,8 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="name" expand="1"/>
<field name="name" expand="1">
<prefix name="flag"/>
</field>
<field name="code" optional="1"/>
</tree>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment