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
e3f14924
Commit
e3f14924
authored
Feb 02, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove archived product in order ; remove products when distantly archived
parent
e1eb5891
Pipeline
#1743
passed with stage
in 1 minute 41 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
orders_helper.js
orders/static/js/orders_helper.js
+39
-4
models.py
products/models.py
+1
-1
No files found.
orders/static/js/orders_helper.js
View file @
e3f14924
...
@@ -261,8 +261,12 @@ function check_products_data() {
...
@@ -261,8 +261,12 @@ function check_products_data() {
traditional
:
true
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
let
loaded_products_ids
=
products
.
map
(
p
=>
p
.
id
);
// Going through products fetched from server
for
(
let
product
of
data
.
res
.
products
)
{
for
(
let
product
of
data
.
res
.
products
)
{
const
p_index
=
products
.
findIndex
(
p
=>
p
.
id
==
product
.
id
);
const
p_id
=
product
.
id
;
const
p_index
=
products
.
findIndex
(
p
=>
p
.
id
==
p_id
);
if
(
p_index
===
-
1
)
{
if
(
p_index
===
-
1
)
{
// Add product if it wasn't fetched before (made available since last access to order)
// Add product if it wasn't fetched before (made available since last access to order)
...
@@ -283,9 +287,39 @@ function check_products_data() {
...
@@ -283,9 +287,39 @@ function check_products_data() {
}
}
}
}
}
}
}
// Remove fetched product id from loaded products list
const
loaded_p_index
=
loaded_products_ids
.
indexOf
(
p_id
);
if
(
loaded_p_index
>
-
1
)
{
loaded_products_ids
.
splice
(
loaded_p_index
,
1
);
}
}
$
(
'.notifyjs-wrapper'
).
trigger
(
'notify-hide'
);
$
(
'.notifyjs-wrapper'
).
trigger
(
'notify-hide'
);
/**
* If loaded p_ids are remaining:
* these products were loaded but don't match the conditions to be fetched anymore.
* Remove them.
*/
if
(
loaded_products_ids
.
length
>
0
)
{
for
(
pid
of
loaded_products_ids
)
{
const
p_index
=
products
.
findIndex
(
p
=>
p
.
id
==
pid
);
const
p_name
=
products
[
p_index
].
name
;
products
.
splice
(
p_index
,
1
);
$
.
notify
(
`Produit "
${
p_name
}
" retiré de la commande.\nIl a probablement été passé en archivé ou en NPA sur un autre poste.`
,
{
globalPosition
:
"top left"
,
className
:
"info"
,
autoHideDelay
:
12000
,
clickToHide
:
false
}
);
}
}
resolve
();
resolve
();
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
...
@@ -723,8 +757,9 @@ function commit_actions_on_product(product, inputs) {
...
@@ -723,8 +757,9 @@ function commit_actions_on_product(product, inputs) {
const
index
=
products
.
findIndex
(
p
=>
p
.
id
==
product
.
id
);
const
index
=
products
.
findIndex
(
p
=>
p
.
id
==
product
.
id
);
products
[
index
].
minimal_stock
=
actions
.
minimal_stock
;
products
[
index
].
minimal_stock
=
actions
.
minimal_stock
;
if
(
actions
.
npa
.
length
>
0
)
{
// Remove NPA products
if
(
actions
.
npa
.
length
>
0
||
actions
.
to_archive
===
true
)
{
// Remove NPA & archived products
products
.
splice
(
index
,
1
);
products
.
splice
(
index
,
1
);
}
}
...
...
products/models.py
View file @
e3f14924
...
@@ -624,7 +624,7 @@ class CagetteProducts(models.Model):
...
@@ -624,7 +624,7 @@ class CagetteProducts(models.Model):
"product_variant_ids"
,
"product_variant_ids"
,
"minimal_stock"
"minimal_stock"
]
]
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
True
]]
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
True
]
,
[
'active'
,
'='
,
True
]
]
products_t
=
api
.
search_read
(
'product.template'
,
c
,
f
)
products_t
=
api
.
search_read
(
'product.template'
,
c
,
f
)
filtered_products_t
=
[
p
for
p
in
products_t
if
p
[
"state"
]
!=
"end"
and
p
[
"state"
]
!=
"obsolete"
]
filtered_products_t
=
[
p
for
p
in
products_t
if
p
[
"state"
]
!=
"end"
and
p
[
"state"
]
!=
"obsolete"
]
...
...
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