Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
c262380f
Commit
c262380f
authored
Feb 23, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: refactor edit_order of Base._edit
parent
e8cd4bfb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
54 deletions
+35
-54
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Amount.py
...entTemplateItem/portal_components/document.erp5.Amount.py
+22
-0
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.DeliveryCell.py
...plateItem/portal_components/document.erp5.DeliveryCell.py
+0
-18
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.DeliveryLine.py
...plateItem/portal_components/document.erp5.DeliveryLine.py
+0
-26
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Movement.py
...tTemplateItem/portal_components/document.erp5.Movement.py
+4
-8
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+9
-2
No files found.
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Amount.py
View file @
c262380f
...
...
@@ -66,6 +66,28 @@ class Amount(Base, VariatedMixin):
,
PropertySheet
.
Reference
)
_default_edit_order
=
(
'resource'
,
'resource_value'
,
# If variations and resources are set at the same time, resource must be
# set before any variation.
'variation_base_category_list'
,
'variation_category_list'
,
# If (quantity unit, base_contribution, or use) and resource are set at the same time,
# resource must be set first, because of an interaction that copies quantity unit
# base contribution and use from resource if not set.
'quantity_unit_value'
,
'quantity_unit'
,
'use_value'
,
'use'
,
'base_contribution_list'
,
'base_contribution_value_list'
,
'base_contribution_value'
,
'base_contribution'
,
)
# A few more mix-in methods which should be relocated
# THIS MUST BE UPDATE WITH CATEGORY ACQUISITION
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.DeliveryCell.py
View file @
c262380f
...
...
@@ -124,24 +124,6 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
self
.
_setPredicateValueList
(
new_predicate_value
)
# No reindex needed since uid stable
# XXX FIXME: option variation are today not well implemented
# This little hack is needed to make the matrixbox working
# in DeliveryLine_viewIndustrialPhase
# Generic form (DeliveryLine_viewOption) is required
def
_edit
(
self
,
**
kw
):
"""
Store variation_category_list, in order to store new value of
industrial_phase after.
"""
edit_order
=
[
'variation_category_list'
,
# edit this one first
'item_id_list'
]
# this one must be the last
edit_order
[
1
:
1
]
=
[
x
for
x
in
kw
.
pop
(
'edit_order'
,
())
if
x
not
in
edit_order
]
# Base._edit updates unordered properties first
edit_order
[
1
:
1
]
=
[
x
for
x
in
kw
if
x
not
in
edit_order
]
MappedValue
.
_edit
(
self
,
edit_order
=
edit_order
,
**
kw
)
# if self.isSimulated():
# self.getRootDeliveryValue().activate().propagateResourceToSimulation()
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'updateSimulationDeliveryProperties'
)
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.DeliveryLine.py
View file @
c262380f
...
...
@@ -36,9 +36,6 @@ from Products.ERP5Type.XMLMatrix import XMLMatrix
from
erp5.component.document.Movement
import
Movement
from
erp5.component.document.ImmobilisationMovement
import
ImmobilisationMovement
from
inspect
import
getargspec
from
Products.ERP5Type.Base
import
Base
edit_args_list
=
getargspec
(
Base
.
_edit
).
args
from
erp5.component.interface.IDivergenceController
import
IDivergenceController
...
...
@@ -75,29 +72,6 @@ class DeliveryLine(Movement, XMLMatrix, ImmobilisationMovement):
# Multiple inheritance definition
updateRelatedContent
=
XMLMatrix
.
updateRelatedContent
# Force in _edit to modify variation_base_category_list first
def
_edit
(
self
,
edit_order
=
(),
**
kw
):
# XXX FIXME For now, special cases are handled in _edit methods in many
# documents : DeliveryLine, DeliveryCell ... Ideally, to prevent code
# duplication, it should be handled in a _edit method present only in
# Amount.py
# If variations and resources are set at the same time, resource must be
# set before any variation.
before_order
=
(
'resource'
,
'resource_value'
,
'variation_base_category_list'
,
'variation_category_list'
)
before_kw
=
{
k
:
kw
.
pop
(
k
)
for
k
in
before_order
if
k
in
kw
}
if
before_kw
:
before_kw
.
update
((
k
,
kw
[
k
])
for
k
in
edit_args_list
if
k
in
kw
)
Base
.
_edit
(
self
,
edit_order
=
before_order
,
**
before_kw
)
if
kw
:
Movement
.
_edit
(
self
,
edit_order
=
edit_order
,
**
kw
)
# We must check if the user has changed the resource of particular line
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'edit'
)
def
edit
(
self
,
REQUEST
=
None
,
force_update
=
0
,
reindex_object
=
1
,
**
kw
):
return
self
.
_edit
(
REQUEST
=
REQUEST
,
force_update
=
force_update
,
reindex_object
=
reindex_object
,
**
kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'isAccountable'
)
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Movement.py
View file @
c262380f
...
...
@@ -73,7 +73,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
to define quantities in orders
- Deliveries: movements track the actual transfer of resources
in the past (accounting) or in the future (planning / budget
t
ing)
in the past (accounting) or in the future (planning / budgeting)
For example, the following objects are Orders:
...
...
@@ -217,8 +217,9 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
,
PropertySheet
.
Movement
,
PropertySheet
.
Price
,
PropertySheet
.
Simulation
# XXX-JPS property should be moved to GeneratedMovement class
)
_default_edit_order
=
Amount
.
_default_edit_order
def
isPropertyRecorded
(
self
,
k
):
# XXX-JPS method should be moved to GeneratedMovement class
return
False
...
...
@@ -726,9 +727,6 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
def
_edit
(
self
,
edit_order
=
(),
**
kw
):
"""Overloaded _edit to support setting debit and credit at the same time,
which is required for the GUI.
Also sets the variation category list and property dict at the end, because
_setVariationCategoryList and _setVariationPropertyDict needs the resource
to be set.
"""
quantity
=
0
if
'source_debit'
in
kw
and
'source_credit'
in
kw
:
...
...
@@ -757,9 +755,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
if
kw
.
get
(
'destination_asset_credit'
)
in
(
None
,
''
):
kw
.
pop
(
'destination_asset_credit'
,
None
)
if
not
edit_order
:
edit_order
=
(
'variation_category_list'
,
'variation_property_dict'
,
'quantity_unit'
,)
return
XMLObject
.
_edit
(
self
,
edit_order
=
edit_order
,
**
kw
)
return
super
(
Movement
,
self
).
_edit
(
edit_order
=
edit_order
,
**
kw
)
# Debit and credit methods for asset
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
product/ERP5Type/Base.py
View file @
c262380f
...
...
@@ -222,7 +222,9 @@ class WorkflowMethod(Method):
# Otherwise, an exception is raised if the workflow transition does not
# exist from the current state, or if the guard rejects it.
valid_transition_item_list
=
[]
for
wf_id
,
transition_list
in
sorted
(
candidate_transition_item_list
):
# XXX sort ?
# for wf_id, transition_list in sorted(candidate_transition_item_list):
for
wf_id
,
transition_list
in
candidate_transition_item_list
:
candidate_workflow
=
wf
[
wf_id
]
valid_list
=
[]
state
=
candidate_workflow
.
_getWorkflowStateOf
(
instance
,
id_only
=
0
)
...
...
@@ -779,6 +781,8 @@ class Base(
# Declarative properties
property_sheets
=
(
PropertySheet
.
Base
,
)
_default_edit_order
=
()
# We want to use a default property view
manage_main
=
manage_propertiesForm
=
DTMLFile
(
'properties'
,
_dtmldir
)
manage_main
.
_setName
(
'manage_main'
)
...
...
@@ -1478,7 +1482,7 @@ class Base(
# Object attributes update method
def
_edit
(
self
,
REQUEST
=
None
,
force_update
=
0
,
reindex_object
=
0
,
keep_existing
=
0
,
activate_kw
=
None
,
edit_order
=
[]
,
restricted
=
0
,
**
kw
):
keep_existing
=
0
,
activate_kw
=
None
,
edit_order
=
()
,
restricted
=
0
,
**
kw
):
"""
Generic edit Method for all ERP5 object
The purpose of this method is to update attributed, eventually do
...
...
@@ -1496,6 +1500,7 @@ class Base(
"""
if
not
kw
:
return
edit_order
=
edit_order
or
self
.
_default_edit_order
key_list
=
kw
.
keys
()
modified_property_dict
=
self
.
_v_modified_property_dict
=
{}
modified_object_dict
=
{}
...
...
@@ -1556,6 +1561,8 @@ class Base(
self
.
setId
(
kw
[
'id'
],
reindex
=
reindex_object
)
return
not_modified_list
# XXX sort ??
#unmodified_key_list = setChangedPropertyList(sorted(unordered_key_list))
unmodified_key_list
=
setChangedPropertyList
(
unordered_key_list
)
setChangedPropertyList
(
unmodified_key_list
)
# edit_order MUST be enforced, and done at the complete end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment