Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
9d8a2b9e
Commit
9d8a2b9e
authored
12 years ago
by
Antonin Bourguignon
Browse files
Options
Downloads
Patches
Plain Diff
[WIP] move the code to another place
bzr revid: abo@openerp.com-20130121150748-3bw28jhvsj23s1zo
parent
64eedb68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openerp/addons/base/res/res_config.py
+30
-14
30 additions, 14 deletions
openerp/addons/base/res/res_config.py
openerp/exceptions.py
+0
-16
0 additions, 16 deletions
openerp/exceptions.py
with
30 additions
and
30 deletions
openerp/addons/base/res/res_config.py
+
30
−
14
View file @
9d8a2b9e
...
...
@@ -20,12 +20,13 @@
##############################################################################
import
logging
from
operator
import
attrgetter
import
re
from
openerp
import
pooler
,
SUPERUSER_ID
from
openerp.osv
import
osv
,
fields
from
openerp.tools
import
ustr
from
openerp.tools.translate
import
_
from
openerp
.addons.base.ir.ir_ui_menu
import
MENU_ITEM_SEPARATOR
from
openerp
import
exceptions
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -594,26 +595,41 @@ class res_config_settings(osv.osv_memory):
Return a string representing the path to access a specific
configuration option through the interface.
:return
tuple t: t[0
] contains the full path,
t[1
] contains
:return
dict d: d[
'
path
'
] contains the full path,
d[
'
name
'
] contains
the
"
human readable
"
configuration option name
"""
res
=
{
'
path
'
:
None
,
'
name
'
:
None
}
# Fetch the path to the config option
module_name
,
menu_xml_id
=
menu_xml_id
.
split
(
'
.
'
)
dummy
,
menu_id
=
self
.
pool
.
get
(
'
ir.model.data
'
).
get_object_reference
(
cr
,
uid
,
module_name
,
menu_xml_id
)
ir_ui_menu
=
self
.
pool
.
get
(
'
ir.ui.menu
'
).
browse
(
cr
,
uid
,
menu_id
,
context
=
context
)
res_path
=
ir_ui_menu
.
complete_name
if
(
menu_xml_id
):
module_name
,
menu_xml_id
=
menu_xml_id
.
split
(
'
.
'
)
dummy
,
menu_id
=
self
.
pool
.
get
(
'
ir.model.data
'
).
get_object_reference
(
cr
,
uid
,
module_name
,
menu_xml_id
)
ir_ui_menu
=
self
.
pool
.
get
(
'
ir.ui.menu
'
).
browse
(
cr
,
uid
,
menu_id
,
context
=
context
)
res
[
'
path
'
]
=
ir_ui_menu
.
complete_name
# Fetch the exact config option name
model_name
,
field_name
=
full_field_name
.
rsplit
(
'
.
'
,
1
)
res_name
=
self
.
pool
.
get
(
model_name
).
_all_columns
.
get
(
field_name
).
column
.
string
if
(
full_field_name
):
model_name
,
field_name
=
full_field_name
.
rsplit
(
'
.
'
,
1
)
res
[
'
name
'
]
=
self
.
pool
.
get
(
model_name
).
_all_columns
.
get
(
field_name
).
column
.
string
return
(
res
_path
,
res_name
)
return
res
def
get_config_path
(
cr
,
menu_xml_id
=
None
,
field_name
=
None
,
context
=
None
):
"""
Simple helper for res_config_settings.get_path().
"""
return
pooler
.
get_pool
(
cr
.
dbname
).
get
(
'
res.config.settings
'
).
get_path
(
cr
,
SUPERUSER_ID
,
menu_xml_id
,
field_name
,
context
)
def
get_warning_config
(
cr
,
msg
,
context
=
None
):
res_config_obj
=
pooler
.
get_pool
(
cr
.
dbname
).
get
(
'
res.config.settings
'
)
def
sub_path
(
g
):
s
=
g
.
group
(
1
)
return
res_config_obj
.
get_path
(
cr
,
SUPERUSER_ID
,
menu_xml_id
=
s
,
full_field_name
=
None
,
context
=
context
)[
'
path
'
]
def
sub_field
(
g
):
s
=
g
.
group
(
1
)
return
res_config_obj
.
get_path
(
cr
,
SUPERUSER_ID
,
menu_xml_id
=
None
,
full_field_name
=
s
,
context
=
context
)[
'
name
'
]
# Treat the msg: find the menu_xml_id and the field_name
msg
=
re
.
sub
(
r
'
\[path:([a-z_\.]*)\]
'
,
sub_path
,
msg
)
msg
=
re
.
sub
(
r
'
\[field:([a-z_\.]*)\]
'
,
sub_field
,
msg
)
return
exceptions
.
WarningConfig
(
msg
)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
This diff is collapsed.
Click to expand it.
openerp/exceptions.py
+
0
−
16
View file @
9d8a2b9e
...
...
@@ -27,28 +27,12 @@ treated as a 'Server error'.
"""
import
re
class
Warning
(
Exception
):
pass
class
WarningConfig
(
Exception
):
"""
Warning bound to a misconfiguration.
"""
def
__init__
(
self
,
msg
):
# WIP WIP WIP WIP WIP WIP WIP
def
sub_path
(
g
):
menu_xml_id
=
g
.
group
(
1
)
return
'
(group to convert:
'
+
menu_xml_id
+
'
)
'
def
sub_path
(
g
):
menu_xml_id
=
g
.
group
(
1
)
return
'
(group to convert:
'
+
menu_xml_id
+
'
)
'
# Treat the msg: find the menu_xml_id and the field_name
teststr
=
'
coucou [path:blabla_bla_bla]
'
print
"
>>>>> sub:
"
,
re
.
sub
(
r
'
\[path:([a-z_]*)\]
'
,
sub_path
,
teststr
)
super
(
WarningConfig
,
self
).
__init__
(
msg
)
class
AccessDenied
(
Exception
):
...
...
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