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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
57e9945f
Commit
57e9945f
authored
Sep 18, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core: WIP Inventory Lines and Cells are not a Delivery Lines and Cells
parent
c52c4ec9
Pipeline
#36857
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
61 deletions
+27
-61
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.InventoryCell.py
...lateItem/portal_components/document.erp5.InventoryCell.py
+3
-30
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.InventoryCell.xml
...ateItem/portal_components/document.erp5.InventoryCell.xml
+3
-1
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.InventoryLine.py
...lateItem/portal_components/document.erp5.InventoryLine.py
+21
-30
No files found.
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.InventoryCell.py
View file @
57e9945f
...
...
@@ -30,11 +30,11 @@ from Acquisition import aq_base
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
from
erp5.component.document.DeliveryCell
import
DeliveryCell
from
erp5.component.document.MappedValue
import
MappedValue
from
erp5.component.document.Amount
import
Amount
class
InventoryCell
(
DeliveryCell
):
class
InventoryCell
(
MappedValue
,
Amount
):
"""
An InventoryCell allows to define specific inventory
for each variation of a resource in an inventory line.
...
...
@@ -42,7 +42,6 @@ class InventoryCell(DeliveryCell):
meta_type
=
'ERP5 Inventory Cell'
portal_type
=
'Inventory Cell'
add_permission
=
Permissions
.
AddPortalContent
isInventoryMovement
=
ConstantGetter
(
'isInventoryMovement'
,
value
=
True
)
# Declarative security
security
=
ClassSecurityInfo
()
...
...
@@ -68,23 +67,6 @@ class InventoryCell(DeliveryCell):
"""
return
self
.
getInventory
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getQuantity'
)
def
getQuantity
(
self
):
"""
Computes a quantity which allows to reach inventory
"""
if
not
self
.
hasCellContent
():
# First check if quantity already exists
quantity
=
self
.
_baseGetQuantity
()
if
quantity
not
in
(
0.0
,
0
,
None
):
return
quantity
# Make sure inventory is defined somewhere (here or parent)
if
getattr
(
aq_base
(
self
),
'inventory'
,
None
)
is
None
:
return
0.0
# No inventory defined, so no quantity
return
self
.
getInventory
()
else
:
return
None
# Inventory cataloging
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getConvertedInventory'
)
def
getConvertedInventory
(
self
):
...
...
@@ -93,12 +75,3 @@ class InventoryCell(DeliveryCell):
no inventory was defined.
"""
return
self
.
getInventory
()
# XXX quantity unit is missing
def
reindexObject
(
self
,
*
args
,
**
kw
):
"""
Reindex Inventory too
"""
DeliveryCell
.
reindexObject
(
self
,
*
args
,
**
kw
)
# No need to reindex recursively as Delivery does, so call
# _reindexObject() directly
self
.
getRootDeliveryValue
().
_reindexObject
(
*
args
,
**
kw
)
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.InventoryCell.xml
View file @
57e9945f
...
...
@@ -43,7 +43,9 @@
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
<tuple>
<string>
W: 29, 0: Unused aq_base imported from Acquisition (unused-import)
</string>
</tuple>
</value>
</item>
<item>
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.InventoryLine.py
View file @
57e9945f
...
...
@@ -27,21 +27,19 @@
##############################################################################
from
AccessControl
import
ClassSecurityInfo
from
Acquisition
import
aq_base
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
erp5.component.document.DeliveryLine
import
DeliveryLine
from
Products.ERP5Type.XMLMatrix
import
XMLMatrix
from
erp5.component.document.Movement
import
Movement
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
from
erp5.component.document.Amount
import
Amount
class
InventoryLine
(
DeliveryLine
):
class
InventoryLine
(
XMLMatrix
,
Amount
):
"""
An Inventory Line describe the inventory of a resource, by variations.
"""
meta_type
=
'ERP5 Inventory Line'
portal_type
=
'Inventory Line'
add_permission
=
Permissions
.
AddPortalContent
isInventoryMovement
=
ConstantGetter
(
'isInventoryMovement'
,
value
=
True
)
# Declarative security
security
=
ClassSecurityInfo
()
...
...
@@ -52,14 +50,21 @@ class InventoryLine(DeliveryLine):
,
PropertySheet
.
XMLObject
,
PropertySheet
.
CategoryCore
,
PropertySheet
.
Amount
,
PropertySheet
.
InventoryMovement
,
PropertySheet
.
Task
,
PropertySheet
.
Arrow
,
PropertySheet
.
Movement
,
PropertySheet
.
VariationRange
,
PropertySheet
.
ItemAggregation
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'hasCellContent'
)
def
hasCellContent
(
self
,
base_id
=
"movement"
):
"""
Returns True is the line contains cells.
"""
cell_range
=
XMLMatrix
.
getCellRange
(
self
,
base_id
=
base_id
)
return
(
cell_range
is
not
None
and
len
(
cell_range
)
>
0
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTotalInventory'
)
def
getTotalInventory
(
self
):
"""
...
...
@@ -74,24 +79,19 @@ class InventoryLine(DeliveryLine):
total_quantity
+=
cell
.
getInventory
()
return
total_quantity
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getQuantity'
)
def
getQuantity
(
self
):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTotalPrice'
)
def
getTotalPrice
(
self
):
"""
Computes a quantity which allows to reach inventory
Returns the price if no cell or the total price if cells
"""
if
not
self
.
hasCellContent
():
# First check if quantity already exists
quantity
=
self
.
_baseGetQuantity
()
if
quantity
not
in
(
0.0
,
0
,
None
):
return
quantity
# Make sure inventory is defined somewhere (here or parent)
inventory
=
getattr
(
aq_base
(
self
),
'inventory'
,
None
)
if
inventory
is
not
None
:
return
inventory
return
quantity
return
self
.
getPrice
()
else
:
return
None
total_price
=
0.0
for
cell
in
self
.
getCellValueList
(
base_id
=
'movement'
):
if
cell
.
getPrice
()
is
not
None
:
total_price
+=
cell
.
getPrice
()
return
total_price
# Inventory cataloging
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -111,12 +111,3 @@ class InventoryLine(DeliveryLine):
Take into account efficiency in converted target quantity
"""
return
Movement
.
getInventoriatedQuantity
(
self
)
def
reindexObject
(
self
,
*
args
,
**
kw
):
"""
Reindex Inventory too
"""
DeliveryLine
.
reindexObject
(
self
,
*
args
,
**
kw
)
# No need to reindex recursively as Delivery does, so call
# _reindexObject() directly
self
.
getRootDeliveryValue
().
_reindexObject
(
*
args
,
**
kw
)
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