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
191d5560a4ba
Commit
191d5560a4ba
authored
2 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Plain Diff
11.0-tomerge
parents
994d317a97b0
82fbb8fb0aed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!14
🤝 11.0-tomerge
Pipeline
#45188
passed
2 years ago
Stage: build
Stage: test
Stage: doc
This commit is part of merge request
!14
. Comments created here will be created in the context of that merge request.
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
MetaAnalytic.py
+12
-0
12 additions, 0 deletions
MetaAnalytic.py
NEWS.rst
+2
-0
2 additions, 0 deletions
NEWS.rst
README.rst
+4
-0
4 additions, 0 deletions
README.rst
models/analytic_structure.py
+22
-1
22 additions, 1 deletion
models/analytic_structure.py
with
40 additions
and
1 deletion
MetaAnalytic.py
+
12
−
0
Edit
View file @
191d5560
...
@@ -155,6 +155,18 @@
...
@@ -155,6 +155,18 @@
@AddMethod
(
superclass
)
@AddMethod
(
superclass
)
@api.model
@api.model
def
get_analytic_field_names
(
self
):
field_names
=
[]
analytic_osv
=
self
.
env
[
"
analytic.structure
"
]
for
model_name
,
prefix
,
suffix
in
all_analytic
:
for
ordering
in
analytic_osv
.
get_dimensions_names
(
model_name
):
field_names
.
append
(
"
%s%s_%s
"
%
(
prefix
,
ordering
,
suffix
))
return
field_names
@AddMethod
(
superclass
)
@api.model
def
fields_get
(
self
,
allfields
=
None
,
attributes
=
None
):
def
fields_get
(
self
,
allfields
=
None
,
attributes
=
None
):
"""
Override this method to rename analytic fields.
"""
"""
Override this method to rename analytic fields.
"""
...
...
This diff is collapsed.
Click to expand it.
NEWS.rst
+
2
−
0
Edit
View file @
191d5560
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
- code_description
- code_description
- parent_column
- parent_column
New partners without name, does not trigger an analytic_code creation.
New partners without name, does not trigger an analytic_code creation.
Added a method able to return the technical names of all the analytic fields of
a class.
.. _2.2:
.. _2.2:
...
...
This diff is collapsed.
Click to expand it.
README.rst
+
4
−
0
Edit
View file @
191d5560
...
@@ -101,6 +101,10 @@
...
@@ -101,6 +101,10 @@
.. _AnalyticFields:
.. _AnalyticFields:
This metaclass adds a method able to return the technical names of all the
analytic fields of the inheriting class:
.. get_analytic_field_names
Add analytic fields to a model
Add analytic fields to a model
------------------------------
------------------------------
...
...
This diff is collapsed.
Click to expand it.
models/analytic_structure.py
+
22
−
1
Edit
View file @
191d5560
...
@@ -300,7 +300,7 @@
...
@@ -300,7 +300,7 @@
else
:
else
:
# No analytic structure defined for this field, hide it.
# No analytic structure defined for this field, hide it.
modifiers
=
json
.
loads
(
match
.
get
(
"
modifiers
"
,
"
{}
"
))
modifiers
=
json
.
loads
(
match
.
get
(
"
modifiers
"
,
"
{}
"
))
modifiers
[
"
invisible
"
]
=
modifiers
[
"
tree
_invisible
"
]
=
True
modifiers
[
"
invisible
"
]
=
modifiers
[
"
column
_invisible
"
]
=
True
modifiers
[
"
required
"
]
=
False
modifiers
[
"
required
"
]
=
False
match
.
set
(
"
invisible
"
,
"
true
"
)
match
.
set
(
"
invisible
"
,
"
true
"
)
match
.
set
(
"
required
"
,
"
false
"
)
match
.
set
(
"
required
"
,
"
false
"
)
...
@@ -346,4 +346,11 @@
...
@@ -346,4 +346,11 @@
)
)
view
[
"
fields
"
].
update
(
elem_fields_def
)
view
[
"
fields
"
].
update
(
elem_fields_def
)
# Prepare the "modifiers" attribute normally dynamically added.
# Specifics here:
# * We compare against explicit attributes in the view. This
# way we avoid all-read-only fields as the main
# "analytic_dimensions" pseudo-field is read-only.
# * When comparing, handle column_invisible -> invisible (see
# odoo/osv/orm.py > transfer_node_to_modifiers).
modifiers
=
json
.
loads
(
elem
.
attrib
.
get
(
"
modifiers
"
,
"
{}
"
))
modifiers
=
json
.
loads
(
elem
.
attrib
.
get
(
"
modifiers
"
,
"
{}
"
))
...
@@ -349,4 +356,13 @@
...
@@ -349,4 +356,13 @@
modifiers
=
json
.
loads
(
elem
.
attrib
.
get
(
"
modifiers
"
,
"
{}
"
))
modifiers
=
json
.
loads
(
elem
.
attrib
.
get
(
"
modifiers
"
,
"
{}
"
))
modifiers
=
json
.
dumps
(
{
attr
:
value
for
attr
,
value
in
modifiers
.
items
()
if
elem
.
attrib
.
get
(
_MODIFIER_TO_ATTR
.
get
(
attr
,
attr
))
in
(
"
True
"
,
"
true
"
,
"
1
"
)
}
)
# Now we can insert the fields in the view's architecture.
# Now we can insert the fields in the view's architecture.
model_map
=
{
model_map
=
{
...
@@ -382,3 +398,8 @@
...
@@ -382,3 +398,8 @@
view
[
"
arch
"
]
=
etree
.
tostring
(
doc
)
view
[
"
arch
"
]
=
etree
.
tostring
(
doc
)
return
view
return
view
# Used above in analytic_fields_view_get to compare "modifiers" vs explicit
# attributes. See odoo/osv/orm.py > transfer_node_to_modifiers.
_MODIFIER_TO_ATTR
=
{
"
column_invisible
"
:
"
invisible
"
}
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