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
1
Merge Requests
1
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
5d71f735
Commit
5d71f735
authored
Jan 22, 2025
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_trade: properly use variation API for offset cells
parent
c9006a5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Inventory_computeOffset.py
...teItem/portal_skins/erp5_trade/Inventory_computeOffset.py
+27
-21
No files found.
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/Inventory_computeOffset.py
View file @
5d71f735
...
...
@@ -103,30 +103,36 @@ def compareDict(base, compare, path):
for
product_relative_url
,
base_product_content
in
base_dict
.
items
():
if
not
"price"
in
base_product_content
:
offset_line
=
None
variation_list
=
[]
for
variation_partial_text
,
base_variation_content
in
base_product_content
.
items
():
missing_quantity
=
compareDict
(
base_dict
,
compare_dict
,
[
product_relative_url
,
variation_partial_text
])
# Cannot create cells upfront because it is first needed to
# know the cell range. First iteration prepares all objects
# which will be created after.
cell_dict
=
{}
for
variation_text
,
base_variation_content
in
base_product_content
.
items
():
missing_quantity
=
compareDict
(
base_dict
,
compare_dict
,
[
product_relative_url
,
variation_text
])
if
missing_quantity
!=
0.0
:
if
offset_line
is
None
:
offset_line
=
context
.
newContent
(
portal_type
=
"Inventory Offset Line"
,
resource
=
product_relative_url
,
)
variation
=
variation_partial_text
.
split
(
"/"
,
1
)[
1
]
offset_line
.
newContent
(
portal_type
=
"Inventory Offset Cell"
,
quantity
=
missing_quantity
,
variation
=
variation
,
price
=
base_variation_content
[
"price"
],
)
variation_list
.
append
(
variation
)
if
offset_line
is
not
None
:
cell_dict
[
variation_text
]
=
{
"portal_type"
:
"Inventory Offset Cell"
,
"variation"
:
variation_text
.
split
(
"/"
,
1
)[
1
],
"quantity"
:
missing_quantity
,
"price"
:
base_variation_content
[
"price"
],
"base_id"
:
"movement"
,
}
variation_list
=
cell_dict
.
keys
()
if
len
(
variation_list
)
>
0
:
offset_line
=
context
.
newContent
(
portal_type
=
"Inventory Offset Line"
,
resource
=
product_relative_url
,
)
offset_line
.
setVariationList
(
variation_list
)
offset_line
.
setCellRange
(
variation_list
,
base_id
=
"movement"
)
for
variation_text
,
cell_kw
in
cell_dict
.
items
():
offset_line
.
newCell
(
variation_text
,
**
cell_kw
)
else
:
missing_quantity
=
compareDict
(
base_dict
,
compare_dict
,
[
product_relative_url
])
...
...
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