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
a57456e8
Commit
a57456e8
authored
May 28, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display products details info
parent
d34b217a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
9 deletions
+37
-9
orders_helper.js
orders/static/js/orders_helper.js
+32
-4
models.py
products/models.py
+5
-5
No files found.
orders/static/js/orders_helper.js
View file @
a57456e8
...
@@ -192,7 +192,11 @@ function prepare_datatable_data() {
...
@@ -192,7 +192,11 @@ function prepare_datatable_data() {
for
(
product
of
products
)
{
for
(
product
of
products
)
{
let
item
=
{
let
item
=
{
id
:
product
.
id
,
id
:
product
.
id
,
name
:
product
.
name
name
:
product
.
name
,
default_code
:
product
.
default_code
,
incoming_qty
:
+
parseFloat
(
product
.
incoming_qty
).
toFixed
(
3
),
// + sign removes unecessary zeroes at the end
qty_available
:
+
parseFloat
(
product
.
qty_available
).
toFixed
(
3
),
uom
:
product
.
uom_id
[
1
],
};
};
// If product not related to supplier : false ; else null (qty to be set) or qty
// If product not related to supplier : false ; else null (qty to be set) or qty
...
@@ -220,12 +224,30 @@ function prepare_datatable_columns() {
...
@@ -220,12 +224,30 @@ function prepare_datatable_columns() {
{
{
data
:
"id"
,
data
:
"id"
,
title
:
"id"
,
title
:
"id"
,
visible
:
false
visible
:
false
,
},
{
data
:
"default_code"
,
title
:
"Référence Produit"
,
width
:
"10%"
,
render
:
function
(
data
)
{
return
(
data
===
false
)
?
""
:
data
;
}
},
},
{
{
data
:
"name"
,
data
:
"name"
,
title
:
"Produit"
title
:
"Produit"
}
},
{
data
:
"qty_available"
,
title
:
"Stock"
,
width
:
"5%"
,
},
{
data
:
"incoming_qty"
,
title
:
"Quantité entrante"
,
width
:
"5%"
,
},
];
];
for
(
supplier
of
selected_suppliers
)
{
for
(
supplier
of
selected_suppliers
)
{
...
@@ -247,6 +269,12 @@ function prepare_datatable_columns() {
...
@@ -247,6 +269,12 @@ function prepare_datatable_columns() {
});
});
}
}
columns
.
push
({
data
:
"uom"
,
title
:
"UDM"
,
width
:
"5%"
,
})
return
columns
;
return
columns
;
}
}
...
@@ -350,5 +378,5 @@ $(document).ready(function() {
...
@@ -350,5 +378,5 @@ $(document).ready(function() {
add_supplier
();
add_supplier
();
});
});
// TODO: on click on 'X' change to input
// TODO: on click on 'X' change to input
, make product available for this supplier
});
});
products/models.py
View file @
a57456e8
...
@@ -406,18 +406,18 @@ class CagetteProducts(models.Model):
...
@@ -406,18 +406,18 @@ class CagetteProducts(models.Model):
ptids
=
[]
ptids
=
[]
for
p
in
psi
:
for
p
in
psi
:
if
(
p
[
"product_tmpl_id"
]
is
not
False
if
(
p
[
"product_tmpl_id"
]
is
not
False
and
(
p
[
"date_start"
]
is
False
or
p
[
"date_
start"
]
<
today
)
and
(
p
[
"date_start"
]
is
False
or
p
[
"date_
end"
]
is
not
False
and
p
[
"date_start"
]
<=
today
)
and
(
p
[
"date_end"
]
is
False
or
p
[
"date_end"
]
<
today
)):
and
(
p
[
"date_end"
]
is
False
or
p
[
"date_end"
]
is
not
False
and
p
[
"date_end"
]
>=
today
)):
ptids
.
append
(
p
[
"product_tmpl_id"
][
0
])
ptids
.
append
(
p
[
"product_tmpl_id"
][
0
])
# Get products templates
# Get products templates
f
=
[
"id"
,
"state"
,
"
product_variant_ids"
,
"name
"
]
f
=
[
"id"
,
"state"
,
"
name"
,
"default_code"
,
"qty_available"
,
"incoming_qty"
,
"uom_id
"
]
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
True
]]
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
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"
]
#
TODO get additional product data (product_variant_ids -> list of product.product)
#
Note: if product.product is needed, get "product_variant_ids" from product template
res
[
"products"
]
=
filtered_products_t
res
[
"products"
]
=
filtered_products_t
except
Exception
as
e
:
except
Exception
as
e
:
print
(
str
(
e
))
print
(
str
(
e
))
...
...
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