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
261
Issues
261
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Paul
third-party
Commits
f53fd634
Commit
f53fd634
authored
Jul 01, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'aide_a_la_commande' into dev_cooperatic
parents
313c7e0f
2d254598
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
48 deletions
+116
-48
models.py
orders/models.py
+3
-1
oders_helper_style.css
orders/static/css/oders_helper_style.css
+43
-8
orders_helper.js
orders/static/js/orders_helper.js
+0
-0
views.py
orders/views.py
+9
-4
models.py
products/models.py
+12
-12
helper.html
templates/orders/helper.html
+49
-23
No files found.
orders/models.py
View file @
f53fd634
...
...
@@ -292,7 +292,9 @@ class Order(models.Model):
res
=
{
'id_po'
:
id_po
,
'confirm_po'
:
True
'confirm_po'
:
True
,
'supplier_id'
:
supplier_id
,
'date_planned'
:
date_planned
}
return
res
...
...
orders/static/css/oders_helper_style.css
View file @
f53fd634
...
...
@@ -91,11 +91,11 @@
#supplier_input
{
width
:
350px
;
border-radius
:
8
px
;
border-radius
:
3
px
;
}
#date_planned_input
,
#coverage_days_input
{
border-radius
:
8
px
;
border-radius
:
3
px
;
}
/* -- Table */
...
...
@@ -106,7 +106,7 @@
#products_table_filter
input
{
height
:
35px
;
width
:
300px
;
border-radius
:
10
px
;
border-radius
:
3
px
;
}
#products_table
.help
{
cursor
:
help
;}
#table_header_select_all
{
...
...
@@ -154,12 +154,34 @@
cursor
:
pointer
;
}
/* --
Bottom action button
*/
/* --
Footer
*/
#main_content_footer
{
margin
:
10px
0
35px
0
;
}
#footer_orders_recap
{
width
:
100%
;
display
:
flex
;
justify-content
:
space-evenly
;
margin-bottom
:
15px
;
}
#footer_actions
{
width
:
100%
;
display
:
flex
;
justify-content
:
space-between
;
margin
:
15px
0
35px
0
;
}
#suppliers_total_values
{
display
:
flex
;
}
.supplier_total_item
{
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
/* -- Suppliers list */
...
...
@@ -182,27 +204,32 @@
}
/* -- Attach product to supplier modal */
.
new_product_supplier
_input_area
{
.
modal
_input_area
{
margin-bottom
:
15px
;
width
:
100%
;
display
:
flex
;
justify-content
:
center
;
}
.
new_product_supplier_input
,
.new_product_supplier
_label
{
.
modal_input_container
,
.modal_input
_label
{
width
:
50%
;
margin
:
0
15px
0
15px
;
}
.
new_product_supplier
_label
{
.
modal_input
_label
{
display
:
flex
;
justify-content
:
flex-end
;
align-items
:
center
;
}
.modal_input
{
width
:
90%
;
}
/* - Orders created screen */
.order_created_header
{
margin-top
:
5px
;
margin-bottom
:
40px
;
}
...
...
@@ -227,6 +254,14 @@
text-decoration
:
none
;
color
:
white
;
}
.download_order_file_button
:active
{
text-decoration
:
none
;
color
:
white
;
}
.download_order_file_button
:focus
{
text-decoration
:
none
;
color
:
white
;
}
#recap_delivery_date
{
font-weight
:
bold
;
...
...
orders/static/js/orders_helper.js
View file @
f53fd634
This diff is collapsed.
Click to expand it.
orders/views.py
View file @
f53fd634
...
...
@@ -41,8 +41,8 @@ def get_suppliers(request):
def
get_supplier_products
(
request
):
""" Get supplier products """
s
id
=
request
.
GET
.
get
(
'sid
'
,
''
)
res
=
CagetteProducts
.
get_products_for_order_helper
(
sid
)
s
uppliers_id
=
request
.
GET
.
getlist
(
'sids
'
,
''
)
res
=
CagetteProducts
.
get_products_for_order_helper
(
s
uppliers_
id
)
if
'error'
in
res
:
return
JsonResponse
(
res
,
status
=
500
)
...
...
@@ -69,8 +69,13 @@ def create_orders(request):
# suppliers id are keys in request data
for
supplier_id
in
data
[
"suppliers_data"
]
.
keys
():
res_created
=
Order
.
create
(
supplier_id
,
data
[
"date_planned"
],
data
[
"suppliers_data"
][
supplier_id
])
res_created
[
"supplier_id"
]
=
supplier_id
supplier_data
=
data
[
"suppliers_data"
][
supplier_id
]
res_created
=
Order
.
create
(
supplier_id
,
supplier_data
[
"date_planned"
],
supplier_data
[
"lines"
]
)
res
[
"created"
]
.
append
(
res_created
)
except
Exception
as
e
:
...
...
products/models.py
View file @
f53fd634
...
...
@@ -455,11 +455,11 @@ class CagetteProducts(models.Model):
return
res
@staticmethod
def
get_products_for_order_helper
(
supplier_id
,
pids
=
[]):
def
get_products_for_order_helper
(
supplier_id
s
,
pids
=
[]):
"""
One of the two parameters must be
set
.
Get products by supplier if
a
supplier_id is set.
If supplier_id
is None, get products specified in pids
.
One of the two parameters must be
not empty
.
Get products by supplier if
one or more
supplier_id is set.
If supplier_id
s is empty, get products specified in pids. In this case, suppliers info won't be fetched
.
"""
api
=
OdooAPI
()
res
=
{}
...
...
@@ -468,10 +468,10 @@ class CagetteProducts(models.Model):
try
:
today
=
datetime
.
date
.
today
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
if
supplier_id
is
not
None
:
if
len
(
supplier_ids
)
>
0
:
# Get products/supplier relation
f
=
[
"product_tmpl_id"
,
'date_start'
,
'date_end'
,
'package_qty'
,
'price'
]
c
=
[[
'name'
,
'
='
,
int
(
supplier_id
)
]]
f
=
[
"product_tmpl_id"
,
'date_start'
,
'date_end'
,
'package_qty'
,
'price'
,
'name'
]
c
=
[[
'name'
,
'
in'
,
[
int
(
x
)
for
x
in
supplier_ids
]
]]
psi
=
api
.
search_read
(
'product.supplierinfo'
,
c
,
f
)
# Filter valid data
...
...
@@ -503,8 +503,8 @@ class CagetteProducts(models.Model):
sales_average_params
=
{
'ids'
:
ptids
,
# 'from': '2019-06
-10',
#
'to': '2019-08-10',
'from'
:
'2019-04
-10'
,
'to'
:
'2019-08-10'
,
}
sales
=
CagetteProducts
.
get_template_products_sales_average
(
sales_average_params
)
...
...
@@ -515,10 +515,10 @@ class CagetteProducts(models.Model):
# Add supplier data to product data
for
i
,
fp
in
enumerate
(
filtered_products_t
):
if
supplier_id
is
not
None
:
if
len
(
supplier_ids
)
>
0
:
psi_item
=
next
(
item
for
item
in
psi
if
item
[
"product_tmpl_id"
]
is
not
False
and
item
[
"product_tmpl_id"
][
0
]
==
fp
[
"id"
])
filtered_products_t
[
i
][
'suppliersinfo'
]
=
[{
'supplier_id'
:
int
(
supplier_id
),
'supplier_id'
:
int
(
psi_item
[
"name"
][
0
]
),
'package_qty'
:
psi_item
[
"package_qty"
],
'price'
:
psi_item
[
"price"
]
}]
...
...
@@ -531,7 +531,7 @@ class CagetteProducts(models.Model):
res
[
"products"
]
=
filtered_products_t
except
Exception
as
e
:
coop_logger
.
error
(
'get_products_for_order_helper
%
s (
%
s)'
,
str
(
e
)
,
str
(
supplier_id
)
)
coop_logger
.
error
(
'get_products_for_order_helper
%
s (
%
s)'
,
str
(
e
))
res
[
"error"
]
=
str
(
e
)
return
res
...
...
templates/orders/helper.html
View file @
f53fd634
...
...
@@ -53,7 +53,6 @@
<input
type=
"text"
name=
"supplier"
id=
"supplier_input"
placeholder=
"Rechercher un fournisseur par son nom"
>
<button
type=
"submit"
class=
'btn--primary'
>
Ajouter le fournisseur
</button>
</form>
<input
type=
"text"
name=
"date_planned"
id=
"date_planned_input"
placeholder=
"Date de livraison souhaitée"
>
</div>
<div
class=
"txtcenter"
id=
"suppliers_container"
></div>
...
...
@@ -65,18 +64,28 @@
</div>
<div
id=
"main_content_footer"
style=
"display:none;"
>
<div
class=
"add_product_container
"
>
<div
id=
"
product_form_container
"
>
<
form
action=
"javascript:;"
id=
"product_form"
>
<input
type=
"text"
name=
"article"
id=
"product_input"
placeholder=
"Rechercher un article"
>
<button
type=
"submit"
class=
'btn--primary'
>
Ajouter l'article
</button
>
<
/form
>
<div
id=
"footer_orders_recap
"
>
<div
id=
"
suppliers_total_values
"
>
<
h4>
Total /fournisseur :
</h4><div
id=
"suppliers_total_values_container"
></div
>
</div
>
<div
id=
"order_total_value_container"
>
<
h4>
Total :
<span
id=
"order_total_value"
></span></h4
>
</div>
</div>
<button
type=
"button"
class=
'btn--primary'
id=
"create_orders"
>
Générer les commandes
</button>
</div>
<div
id=
"footer_actions"
>
<div
class=
"add_product_container"
>
<div
id=
"product_form_container"
>
<form
action=
"javascript:;"
id=
"product_form"
>
<input
type=
"text"
name=
"article"
id=
"product_input"
placeholder=
"Rechercher un article"
>
<button
type=
"submit"
class=
'btn--primary'
>
Ajouter l'article
</button>
</form>
</div>
</div>
<button
type=
"button"
class=
'btn--primary'
id=
"create_orders"
>
Générer les commandes
</button>
</div>
</div>
</div>
<div
id=
"orders_created"
class=
"page_content"
style=
"display:none;"
>
...
...
@@ -88,9 +97,6 @@
<div
class=
"order_created_header txtcenter"
>
<h2>
Commandes créées !
</h2>
</div>
<div
class=
"txtcenter"
>
Livraison prévue le :
<span
id=
"recap_delivery_date"
>
XX/XX/XX
</span>
</div>
<div
id=
"created_orders_area"
></div>
<br/><br/><hr/><br/>
<div
class=
"mail_example_container"
>
...
...
@@ -128,6 +134,7 @@
<div
class=
"new_order_item"
>
<h3
class=
"new_order_supplier_name"
></h3>
<h3
class=
"new_order_po"
></h3>
<h4
class=
"new_order_date_planned"
></h4>
<div
class=
'download_order_file'
>
<i
class=
"fas fa-spinner fa-spin download_order_file_loading"
></i>
<a
class=
'btn--success download_order_file_button'
style=
"display:none;"
href=
"#"
>
...
...
@@ -168,13 +175,17 @@
Vous vous apprêtez à associer le produit
<span
class=
"product_name"
></span>
au fournisseur
<span
class=
"supplier_name"
></span>
.
<br/>
</p>
<br/>
<div
class=
"new_product_supplier_input_area"
>
<span
class=
"new_product_supplier_label"
>
Prix du produit chez ce fournisseur:
</span>
<input
type=
"number"
class=
"new_product_supplier_input new_product_supplier_price"
>
<div
class=
"modal_input_area"
>
<span
class=
"modal_input_label"
>
Prix du produit chez ce fournisseur:
</span>
<div
class=
"modal_input_container"
>
<input
type=
"number"
class=
"modal_input new_product_supplier_price"
>
</div>
</div>
<div
class=
"new_product_supplier_input_area"
>
<span
class=
"new_product_supplier_label"
>
Colisage chez ce fournisseur:
</span>
<input
type=
"number"
class=
"new_product_supplier_input new_product_supplier_package_pty"
>
<div
class=
"modal_input_area"
>
<span
class=
"modal_input_label"
>
Colisage chez ce fournisseur:
</span>
<div
class=
"modal_input_container"
>
<input
type=
"number"
class=
"modal_input new_product_supplier_package_pty"
>
</div>
</div>
<br/>
<p>
...
...
@@ -196,20 +207,35 @@
<h3>
Attention !
</h3>
<p>
Vous vous apprêtez à passer le produit
<span
class=
"product_name"
></span>
en
<span
class=
"product_npa"
></span>
.
<br/>
L'information sera enregistrée dès que vous aurez cliqué sur "Valider"
.
Dès que vous aurez cliqué sur "Valider", le produit sera retiré du tableau et l'information sera enregistrée dans Odoo
.
</p>
<p>
Êtez-vous sûr ?
</p>
<hr/>
</div>
<div
id=
"modal_create_order"
>
<h3>
Attention !
</h3>
<h3>
Dernière étape...
</h3>
<br/>
<p>
Vous vous apprêtez à générer les commandes à partir des données rentrées dans le tableau.
</p>
<p>
Êtez-vous sûr ?
</p>
<p>
Vous pouvez rentrer une date de livraison prévue pour chaque fournisseur (optionnel, la date par défaut sera celle de demain).
</p>
<br/>
<div
class=
"suppliers_date_planned_area"
></div>
<br/>
<hr/>
</div>
<div
id=
"modal_create_order__supplier_date_planned"
>
<div
class=
"modal_input_area"
>
<span
class=
"modal_input_label supplier_name"
></span>
<div
class=
"modal_input_container"
>
<input
type=
"text"
class=
"modal_input supplier_date_planned"
placeholder=
"Date de livraison prévue"
>
</div>
</div>
</div>
</div>
</div>
...
...
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