Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
8256a5f9
Commit
8256a5f9
authored
Feb 23, 2023
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt scale file generation to Supercoop
parent
0d7c8c32
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
config.md
outils/config.md
+4
-0
models.py
products/models.py
+20
-5
No files found.
outils/config.md
View file @
8256a5f9
...
@@ -154,6 +154,10 @@
...
@@ -154,6 +154,10 @@
-
FIXED_BARCODE_PREFIX = '0491'
-
FIXED_BARCODE_PREFIX = '0491'
-
UNIT_BARCODE_PREFIX = '042'
-
WEIGHT_BARCODE_PREFIX =
[
'260'
]
-
FLV_CSV_NB = 4
-
FLV_CSV_NB = 4
How many distinct file for scale input have to be generated
How many distinct file for scale input have to be generated
...
...
products/models.py
View file @
8256a5f9
...
@@ -323,10 +323,14 @@ class CagetteProducts(models.Model):
...
@@ -323,10 +323,14 @@ class CagetteProducts(models.Model):
@staticmethod
@staticmethod
def
__unique_product_list
(
plist
):
def
__unique_product_list
(
plist
):
# 276
upl
=
{}
upl
=
{}
prefixes
=
getattr
(
settings
,
'WEIGHT_BARCODE_PREFIX'
,
[
'0493'
,
'0491'
])
+
[
getattr
(
settings
,
'UNIT_BARCODE_PREFIX'
,
'0499'
)]
for
p
in
plist
:
for
p
in
plist
:
if
not
(
p
[
'id'
]
in
upl
):
keep_it
=
False
# Need to clean list (for example, some products may have been checked "to weight" whereas it is not or no barcode associated to it)
for
prefix
in
prefixes
:
if
p
[
'barcode'
]
and
p
[
'barcode'
]
.
find
(
prefix
)
==
0
:
keep_it
=
True
if
keep_it
is
True
and
p
[
'id'
]
not
in
upl
:
if
(
'image_medium'
in
p
):
if
(
'image_medium'
in
p
):
p
[
'image'
]
=
p
[
'image_medium'
]
p
[
'image'
]
=
p
[
'image_medium'
]
p
[
'image_medium'
]
=
''
p
[
'image_medium'
]
=
''
...
@@ -356,7 +360,12 @@ class CagetteProducts(models.Model):
...
@@ -356,7 +360,12 @@ class CagetteProducts(models.Model):
[
'to_weight'
,
'='
,
True
],
[
'to_weight'
,
'='
,
True
],
[
'available_in_pos'
,
'='
,
True
]]
[
'available_in_pos'
,
'='
,
True
]]
if
not
withCandidate
:
if
not
withCandidate
:
cond
=
[(
'active'
,
'='
,
True
),
(
'to_weight'
,
'='
,
True
),
(
'available_in_pos'
,
'='
,
True
),
'|'
,
(
'barcode'
,
'=like'
,
'0491
%
'
),
(
'barcode'
,
'=like'
,
'0493
%
'
)]
prefixes
=
getattr
(
settings
,
'WEIGHT_BARCODE_PREFIX'
,
[
'0491'
,
'0493'
])
FIXED_BARCODE_PREFIX
=
'0490'
UNIT_BARCODE_PREFIX
=
'042'
cond
=
[(
'active'
,
'='
,
True
),
(
'to_weight'
,
'='
,
True
),
(
'available_in_pos'
,
'='
,
True
),
'|'
]
for
bc_prefix
in
prefixes
:
cond
.
append
((
'barcode'
,
'=like'
,
bc_prefix
+
'
%
'
))
return
api
.
search_read
(
'product.product'
,
cond
,
fields
)
return
api
.
search_read
(
'product.product'
,
cond
,
fields
)
...
@@ -367,7 +376,10 @@ class CagetteProducts(models.Model):
...
@@ -367,7 +376,10 @@ class CagetteProducts(models.Model):
[
'available_in_pos'
,
'='
,
True
],
[
'available_in_pos'
,
'='
,
True
],
[
'name'
,
'ilike'
,
'vrac'
]]
[
'name'
,
'ilike'
,
'vrac'
]]
if
not
withCandidate
:
if
not
withCandidate
:
cond
=
[(
'active'
,
'='
,
True
),
(
'name'
,
'ilike'
,
'vrac'
),
(
'available_in_pos'
,
'='
,
True
),
'|'
,
(
'barcode'
,
'=like'
,
'0491
%
'
),
(
'barcode'
,
'=like'
,
'0493
%
'
)]
prefixes
=
getattr
(
settings
,
'WEIGHT_BARCODE_PREFIX'
,
[
'0491'
,
'0493'
])
cond
=
[(
'active'
,
'='
,
True
),
(
'name'
,
'ilike'
,
'vrac'
),
(
'available_in_pos'
,
'='
,
True
),
'|'
]
for
bc_prefix
in
prefixes
:
cond
.
append
((
'barcode'
,
'=like'
,
bc_prefix
+
'
%
'
))
return
api
.
search_read
(
'product.product'
,
cond
,
fields
)
return
api
.
search_read
(
'product.product'
,
cond
,
fields
)
@staticmethod
@staticmethod
...
@@ -386,7 +398,10 @@ class CagetteProducts(models.Model):
...
@@ -386,7 +398,10 @@ class CagetteProducts(models.Model):
[
'available_in_pos'
,
'='
,
True
],
[
'available_in_pos'
,
'='
,
True
],
[
'categ_id'
,
'in'
,
flv_cats
]]
[
'categ_id'
,
'in'
,
flv_cats
]]
if
not
withCandidate
:
if
not
withCandidate
:
cond
=
[(
'active'
,
'='
,
True
),
(
'categ_id'
,
'in'
,
flv_cats
),
(
'available_in_pos'
,
'='
,
True
),
'|'
,
(
'barcode'
,
'=like'
,
'0493
%
'
),
(
'barcode'
,
'=like'
,
'0499
%
'
)]
prefixes
=
getattr
(
settings
,
'WEIGHT_BARCODE_PREFIX'
,
[
'0493'
])
+
[
getattr
(
settings
,
'UNIT_BARCODE_PREFIX'
,
'0499'
)]
cond
=
[(
'active'
,
'='
,
True
),
(
'categ_id'
,
'in'
,
flv_cats
),
(
'available_in_pos'
,
'='
,
True
),
'|'
]
for
bc_prefix
in
prefixes
:
cond
.
append
((
'barcode'
,
'=like'
,
bc_prefix
+
'
%
'
))
return
api
.
search_read
(
'product.product'
,
cond
,
fields
)
return
api
.
search_read
(
'product.product'
,
cond
,
fields
)
@staticmethod
@staticmethod
...
...
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