Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Tryton
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tryton
Tryton
Commits
77c8a0d8
Commit
77c8a0d8
authored
2 years ago
by
Cédric Krier
Browse files
Options
Downloads
Patches
Plain Diff
Add flag symbol for country and subdivision
issue11599 review433291003
parent
68b41353
No related branches found
Branches containing commit
No related tags found
1 merge request
!114
Return an empty list when the treeview has no selection
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG
+2
-0
2 additions, 0 deletions
CHANGELOG
country.py
+20
-0
20 additions, 0 deletions
country.py
view/country_tree.xml
+3
-1
3 additions, 1 deletion
view/country_tree.xml
with
25 additions
and
1 deletion
CHANGELOG
+
2
−
0
View file @
77c8a0d8
* 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
...
...
This diff is collapsed.
Click to expand it.
country.py
+
20
−
0
View file @
77c8a0d8
...
...
@@ -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
'
,
...
...
This diff is collapsed.
Click to expand it.
view/country_tree.xml
+
3
−
1
View file @
77c8a0d8
...
...
@@ -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>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment