Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Analytic Structure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
XCG
Odoo modules
Analytic Structure
Commits
cb35b42ea32d
Commit
cb35b42ea32d
authored
9 years ago
by
Brendan Masson
Browse files
Options
Downloads
Patches
Plain Diff
Change type of analytic.structure field to Selection
parent
60e96f419da8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
analytic_structure.py
+34
-3
34 additions, 3 deletions
analytic_structure.py
analytic_views.xml
+6
-4
6 additions, 4 deletions
analytic_views.xml
with
40 additions
and
7 deletions
analytic_structure.py
+
34
−
3
View file @
cb35b42e
...
@@ -60,5 +60,32 @@
...
@@ -60,5 +60,32 @@
u
"
structure is common to all companies.
"
u
"
structure is common to all companies.
"
)
)
model_name
=
fields
.
Char
(
def
_get_model_name
(
self
):
"""
Looks up the list of model names
"""
registry
=
self
.
env
.
registry
models
=
[
model
for
name
,
model
in
registry
.
items
()
if
getattr
(
model
,
'
_analytic
'
,
False
)
]
model_names
=
set
()
for
model
in
models
:
analytic
=
model
.
_analytic
if
analytic
is
True
:
model_names
.
add
(
model
.
_name
.
replace
(
'
.
'
,
'
_
'
))
elif
isinstance
(
analytic
,
basestring
):
model_names
.
add
(
analytic
)
else
:
# Expecting analytic to be a dict
model_names
.
update
(
analytic
.
values
())
res
=
[(
model_name
,
model_name
)
for
model_name
in
model_names
]
from
pprint
import
pprint
pprint
(
res
)
return
res
model_name
=
fields
.
Selection
(
_get_model_name
,
u
"
Object
"
,
u
"
Object
"
,
...
@@ -64,3 +91,2 @@
...
@@ -64,3 +91,2 @@
u
"
Object
"
,
u
"
Object
"
,
size
=
128
,
required
=
True
,
required
=
True
,
...
@@ -66,5 +92,4 @@
...
@@ -66,5 +92,4 @@
required
=
True
,
required
=
True
,
select
=
'
1
'
,
)
)
nd_id
=
fields
.
Many2one
(
nd_id
=
fields
.
Many2one
(
'
analytic.dimension
'
,
'
analytic.dimension
'
,
...
@@ -92,6 +117,12 @@
...
@@ -92,6 +117,12 @@
),
),
]
]
def
name_get
(
self
):
names
=
[
(
record
.
id
,
record
.
model_name
)
for
record
in
self
]
return
names
def
format_field_name
(
self
,
ordering
,
prefix
=
'
a
'
,
suffix
=
'
id
'
):
def
format_field_name
(
self
,
ordering
,
prefix
=
'
a
'
,
suffix
=
'
id
'
):
"""
Return an analytic field
'
s name from its slot, prefix and suffix.
"""
Return an analytic field
'
s name from its slot, prefix and suffix.
"""
"""
...
...
This diff is collapsed.
Click to expand it.
analytic_views.xml
+
6
−
4
View file @
cb35b42e
...
@@ -121,4 +121,8 @@
...
@@ -121,4 +121,8 @@
<field
name=
"model"
>
analytic.structure
</field>
<field
name=
"model"
>
analytic.structure
</field>
<field
name=
"arch"
type=
"xml"
>
<field
name=
"arch"
type=
"xml"
>
<form
string=
"Analytic Structure"
version=
"7.0"
>
<form
string=
"Analytic Structure"
version=
"7.0"
>
<h1>
<field
name=
"display_name"
class=
"oe_inline,oe_read_only"
style=
"width: 6em"
/>
</h1>
<label
for=
"model_name"
class=
"oe_edit_only"
string=
"Target Model Name"
/>
<label
for=
"model_name"
class=
"oe_edit_only"
string=
"Target Model Name"
/>
...
@@ -124,8 +128,6 @@
...
@@ -124,8 +128,6 @@
<label
for=
"model_name"
class=
"oe_edit_only"
string=
"Target Model Name"
/>
<label
for=
"model_name"
class=
"oe_edit_only"
string=
"Target Model Name"
/>
<h1>
<field
name=
"model_name"
class=
"oe_edit_only"
<field
name=
"model_name"
class=
"oe_inline"
placeholder=
"Target Model Name"
/>
placeholder=
"Target Model Name"
style=
"width: 6em"
/>
</h1>
<group
colspan=
"4"
col=
"4"
>
<group
colspan=
"4"
col=
"4"
>
<field
name=
"nd_id"
/>
<field
name=
"nd_id"
/>
<newline
/>
<newline
/>
...
...
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