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
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
Alexis AOUN
third-party
Commits
9f638578
Commit
9f638578
authored
Jul 01, 2021
by
Damien Moulard
Committed by
Alexis Aoun
Jul 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
date planned for each supplier
parent
1fa5625a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
87 deletions
+126
-87
models.py
orders/models.py
+3
-1
oders_helper_style.css
orders/static/css/oders_helper_style.css
+16
-3
orders_helper.js
orders/static/js/orders_helper.js
+71
-69
views.py
orders/views.py
+7
-2
helper.html
templates/orders/helper.html
+29
-12
No files found.
orders/models.py
View file @
9f638578
...
@@ -292,7 +292,9 @@ class Order(models.Model):
...
@@ -292,7 +292,9 @@ class Order(models.Model):
res
=
{
res
=
{
'id_po'
:
id_po
,
'id_po'
:
id_po
,
'confirm_po'
:
True
'confirm_po'
:
True
,
'supplier_id'
:
supplier_id
,
'date_planned'
:
date_planned
}
}
return
res
return
res
...
...
orders/static/css/oders_helper_style.css
View file @
9f638578
...
@@ -182,27 +182,32 @@
...
@@ -182,27 +182,32 @@
}
}
/* -- Attach product to supplier modal */
/* -- Attach product to supplier modal */
.
new_product_supplier
_input_area
{
.
modal
_input_area
{
margin-bottom
:
15px
;
margin-bottom
:
15px
;
width
:
100%
;
width
:
100%
;
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
}
}
.
new_product_supplier_input
,
.new_product_supplier
_label
{
.
modal_input_container
,
.modal_input
_label
{
width
:
50%
;
width
:
50%
;
margin
:
0
15px
0
15px
;
margin
:
0
15px
0
15px
;
}
}
.
new_product_supplier
_label
{
.
modal_input
_label
{
display
:
flex
;
display
:
flex
;
justify-content
:
flex-end
;
justify-content
:
flex-end
;
align-items
:
center
;
align-items
:
center
;
}
}
.modal_input
{
width
:
90%
;
}
/* - Orders created screen */
/* - Orders created screen */
.order_created_header
{
.order_created_header
{
margin-top
:
5px
;
margin-bottom
:
40px
;
margin-bottom
:
40px
;
}
}
...
@@ -227,6 +232,14 @@
...
@@ -227,6 +232,14 @@
text-decoration
:
none
;
text-decoration
:
none
;
color
:
white
;
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
{
#recap_delivery_date
{
font-weight
:
bold
;
font-weight
:
bold
;
...
...
orders/static/js/orders_helper.js
View file @
9f638578
...
@@ -15,7 +15,6 @@ var dbc = null,
...
@@ -15,7 +15,6 @@ var dbc = null,
sync
=
null
,
sync
=
null
,
order_doc
=
{
order_doc
=
{
_id
:
null
,
_id
:
null
,
date_planned
:
null
,
coverage_days
:
null
,
coverage_days
:
null
,
last_update
:
{
last_update
:
{
timestamp
:
null
,
timestamp
:
null
,
...
@@ -42,7 +41,6 @@ function reset_data() {
...
@@ -42,7 +41,6 @@ function reset_data() {
product_orders
=
[];
product_orders
=
[];
order_doc
=
{
order_doc
=
{
_id
:
null
,
_id
:
null
,
date_planned
:
null
,
coverage_days
:
null
,
coverage_days
:
null
,
last_update
:
{
last_update
:
{
timestamp
:
null
,
timestamp
:
null
,
...
@@ -717,13 +715,44 @@ function update_cdb_order() {
...
@@ -717,13 +715,44 @@ function update_cdb_order() {
* Create the Product Orders in Odoo
* Create the Product Orders in Odoo
*/
*/
function
create_orders
()
{
function
create_orders
()
{
openModal
();
let
orders_data
=
{
let
orders_data
=
{
"date_planned"
:
order_doc
.
date_planned
,
"suppliers_data"
:
{}
"suppliers_data"
:
{}
};
};
// Get planned delivery date for each supplier before hiding the modal
for
(
let
supplier
of
selected_suppliers
)
{
// Get planned date from modal
let
supplier_date_planned
=
$
(
`#date_planned_supplier_
${
supplier
.
id
}
`
).
val
();
let
formatted_date
=
null
;
if
(
supplier_date_planned
!==
''
)
{
if
(
date_format
===
"dd/mm/yy"
)
{
// Change format [dd/mm/yy] to ISO [yy-mm-dd]
formatted_date
=
supplier_date_planned
.
split
(
'/'
)
.
reverse
()
.
join
(
'-'
)
+
' 00:00:00'
;
}
else
{
formatted_date
=
supplier_date_planned
+
' 00:00:00'
;
}
}
else
{
// Default date : tomorrow
let
date_object
=
new
Date
();
date_object
.
setDate
(
date_object
.
getDate
()
+
1
);
// Get ISO format bare string
formatted_date
=
date_object
.
toISOString
().
replace
(
'T'
,
' '
).
split
(
'.'
)[
0
];
}
// Create an entry for this supplier
orders_data
.
suppliers_data
[
supplier
.
id
]
=
{
date_planned
:
formatted_date
,
lines
:
[]
}
}
openModal
();
// Prepare data: get products where a qty is set
// Prepare data: get products where a qty is set
for
(
let
p
of
products
)
{
for
(
let
p
of
products
)
{
for
(
let
p_supplierinfo
of
p
.
suppliersinfo
)
{
for
(
let
p_supplierinfo
of
p
.
suppliersinfo
)
{
...
@@ -731,12 +760,7 @@ function create_orders() {
...
@@ -731,12 +760,7 @@ function create_orders() {
if
(
'qty'
in
p_supplierinfo
)
{
if
(
'qty'
in
p_supplierinfo
)
{
const
supplier_id
=
p_supplierinfo
.
supplier_id
;
const
supplier_id
=
p_supplierinfo
.
supplier_id
;
// Create entry for this supplier in data object if doesn't exist
orders_data
.
suppliers_data
[
supplier_id
].
lines
.
push
({
if
(
orders_data
.
suppliers_data
[
supplier_id
]
===
undefined
)
{
orders_data
.
suppliers_data
[
supplier_id
]
=
[];
}
orders_data
.
suppliers_data
[
supplier_id
].
push
({
'package_qty'
:
p_supplierinfo
.
package_qty
,
'package_qty'
:
p_supplierinfo
.
package_qty
,
'product_id'
:
p
.
id
,
'product_id'
:
p
.
id
,
'name'
:
p
.
name
,
'name'
:
p
.
name
,
...
@@ -751,13 +775,6 @@ function create_orders() {
...
@@ -751,13 +775,6 @@ function create_orders() {
}
}
}
}
if
(
Object
.
keys
(
orders_data
.
suppliers_data
).
length
===
0
)
{
closeModal
();
alert
(
"Commande non créée : vous n'avez rentré aucune quantité !"
);
return
-
1
;
}
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
"/orders/create_orders"
,
url
:
"/orders/create_orders"
,
...
@@ -766,12 +783,16 @@ function create_orders() {
...
@@ -766,12 +783,16 @@ function create_orders() {
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
orders_data
),
data
:
JSON
.
stringify
(
orders_data
),
success
:
(
result
)
=>
{
success
:
(
result
)
=>
{
$
(
'#recap_delivery_date'
).
text
(
$
(
'#date_planned_input'
).
val
());
// Display new orders
// Display new orders
for
(
let
new_order
of
result
.
res
.
created
)
{
for
(
let
new_order
of
result
.
res
.
created
)
{
const
supplier_name
=
suppliers_list
.
find
(
s
=>
s
.
id
==
new_order
.
supplier_id
).
display_name
;
const
supplier_name
=
suppliers_list
.
find
(
s
=>
s
.
id
==
new_order
.
supplier_id
).
display_name
;
const
date_planned
=
new_order
.
date_planned
.
split
(
' '
)[
0
]
.
split
(
'-'
)
.
reverse
()
.
join
(
'/'
);
product_orders
.
push
({
product_orders
.
push
({
'id'
:
new_order
.
id_po
,
'id'
:
new_order
.
id_po
,
'supplier_id'
:
new_order
.
supplier_id
,
'supplier_id'
:
new_order
.
supplier_id
,
...
@@ -782,6 +803,7 @@ function create_orders() {
...
@@ -782,6 +803,7 @@ function create_orders() {
new_order_template
.
find
(
".new_order_supplier_name"
).
text
(
supplier_name
);
new_order_template
.
find
(
".new_order_supplier_name"
).
text
(
supplier_name
);
new_order_template
.
find
(
".new_order_po"
).
text
(
`PO
${
new_order
.
id_po
}
`
);
new_order_template
.
find
(
".new_order_po"
).
text
(
`PO
${
new_order
.
id_po
}
`
);
new_order_template
.
find
(
".new_order_date_planned"
).
text
(
`Date de livraison prévue:
${
date_planned
}
`
);
new_order_template
.
find
(
".download_order_file_button"
).
attr
(
'id'
,
`download_attachment_
${
new_order
.
id_po
}
`
);
new_order_template
.
find
(
".download_order_file_button"
).
attr
(
'id'
,
`download_attachment_
${
new_order
.
id_po
}
`
);
$
(
'#created_orders_area'
).
append
(
new_order_template
.
html
());
$
(
'#created_orders_area'
).
append
(
new_order_template
.
html
());
...
@@ -1409,17 +1431,6 @@ function update_main_screen(params) {
...
@@ -1409,17 +1431,6 @@ function update_main_screen(params) {
});
});
}
}
if
(
order_doc
.
date_planned
!==
null
)
{
// Switch format from yy-mm-dd hh:mm:ss to readable dd/mm/yy
let
date_to_format
=
order_doc
.
date_planned
.
split
(
' '
)[
0
];
let
readable_date
=
date_to_format
.
split
(
'-'
).
reverse
()
.
join
(
'/'
);
$
(
"#date_planned_input"
).
val
(
readable_date
);
}
else
{
$
(
"#date_planned_input"
).
val
(
''
);
}
if
(
order_doc
.
coverage_days
!==
null
)
{
if
(
order_doc
.
coverage_days
!==
null
)
{
$
(
"#coverage_days_input"
).
val
(
order_doc
.
coverage_days
);
$
(
"#coverage_days_input"
).
val
(
order_doc
.
coverage_days
);
}
else
{
}
else
{
...
@@ -1586,13 +1597,18 @@ $(document).ready(function() {
...
@@ -1586,13 +1597,18 @@ $(document).ready(function() {
});
});
$
(
'#create_orders'
).
on
(
'click'
,
function
()
{
$
(
'#create_orders'
).
on
(
'click'
,
function
()
{
if
(
order_doc
.
date_planned
===
null
)
{
let
modal_create_order
=
$
(
'#templates #modal_create_order'
);
alert
(
"Veuillez rentrer une date de livraison prévue."
);
modal_create_order
.
find
(
'.suppliers_date_planned_area'
).
empty
(
);
return
-
1
;
for
(
let
supplier
of
selected_suppliers
)
{
let
supplier_date_planned_template
=
$
(
'#templates #modal_create_order__supplier_date_planned'
);
supplier_date_planned_template
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
supplier_date_planned_template
.
find
(
".modal_input_container"
).
attr
(
'id'
,
`container_date_planned_supplier_
${
supplier
.
id
}
`
);
modal_create_order
.
find
(
'.suppliers_date_planned_area'
).
append
(
supplier_date_planned_template
.
html
());
}
}
let
modal_create_order
=
$
(
'#templates #modal_create_order'
);
openModal
(
openModal
(
modal_create_order
.
html
(),
modal_create_order
.
html
(),
...
@@ -1603,6 +1619,26 @@ $(document).ready(function() {
...
@@ -1603,6 +1619,26 @@ $(document).ready(function() {
false
false
);
);
// Add id to input once modal is displayed
for
(
let
supplier
of
selected_suppliers
)
{
$
(
`#modal #container_date_planned_supplier_
${
supplier
.
id
}
`
).
find
(
".supplier_date_planned"
).
attr
(
'id'
,
`date_planned_supplier_
${
supplier
.
id
}
`
);
}
$
(
"#modal .supplier_date_planned"
)
.
datepicker
({
defaultDate
:
"+1d"
,
minDate
:
new
Date
()
})
.
on
(
'change'
,
function
()
{
try
{
// When date input changes, try to read date
$
.
datepicker
.
parseDate
(
date_format
,
$
(
this
).
val
());
}
catch
{
alert
(
'Date invalide'
);
$
(
this
).
val
(
''
);
}
});
return
0
;
return
0
;
});
});
...
@@ -1634,40 +1670,6 @@ $(document).ready(function() {
...
@@ -1634,40 +1670,6 @@ $(document).ready(function() {
};
};
$
.
datepicker
.
setDefaults
(
$
.
datepicker
.
regional
[
'fr'
]);
$
.
datepicker
.
setDefaults
(
$
.
datepicker
.
regional
[
'fr'
]);
const
tomorrow
=
new
Date
();
tomorrow
.
setDate
(
tomorrow
.
getDate
()
+
1
);
$
(
"#date_planned_input"
)
.
datepicker
({
defaultDate
:
"+1d"
,
minDate
:
tomorrow
})
.
on
(
'change'
,
function
()
{
try
{
// When date input changes, try to read date
$
.
datepicker
.
parseDate
(
date_format
,
$
(
this
).
val
());
// No exception raised: date is valid.
// Change format from readable (dd/mm/yy) to ISO (yy-mm-dd)
let
formatted_date
=
$
(
this
).
val
()
.
split
(
'/'
)
.
reverse
()
.
join
(
'-'
)
+
' 00:00:00'
;
// Update doc if changed
if
(
formatted_date
!==
order_doc
.
date_planned
)
{
order_doc
.
date_planned
=
formatted_date
;
update_cdb_order
();
}
}
catch
(
error
)
{
alert
(
'Date invalide'
);
$
(
this
).
val
(
''
);
order_doc
.
date_planned
=
null
;
update_cdb_order
();
}
});
// Order selection screen
// Order selection screen
update_order_selection_screen
();
update_order_selection_screen
();
...
...
orders/views.py
View file @
9f638578
...
@@ -69,8 +69,13 @@ def create_orders(request):
...
@@ -69,8 +69,13 @@ def create_orders(request):
# suppliers id are keys in request data
# suppliers id are keys in request data
for
supplier_id
in
data
[
"suppliers_data"
]
.
keys
():
for
supplier_id
in
data
[
"suppliers_data"
]
.
keys
():
res_created
=
Order
.
create
(
supplier_id
,
data
[
"date_planned"
],
data
[
"suppliers_data"
][
supplier_id
])
supplier_data
=
data
[
"suppliers_data"
][
supplier_id
]
res_created
[
"supplier_id"
]
=
supplier_id
res_created
=
Order
.
create
(
supplier_id
,
supplier_data
[
"date_planned"
],
supplier_data
[
"lines"
]
)
res
[
"created"
]
.
append
(
res_created
)
res
[
"created"
]
.
append
(
res_created
)
except
Exception
as
e
:
except
Exception
as
e
:
...
...
templates/orders/helper.html
View file @
9f638578
...
@@ -53,7 +53,6 @@
...
@@ -53,7 +53,6 @@
<input
type=
"text"
name=
"supplier"
id=
"supplier_input"
placeholder=
"Rechercher un fournisseur par son nom"
>
<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>
<button
type=
"submit"
class=
'btn--primary'
>
Ajouter le fournisseur
</button>
</form>
</form>
<input
type=
"text"
name=
"date_planned"
id=
"date_planned_input"
placeholder=
"Date de livraison souhaitée"
>
</div>
</div>
<div
class=
"txtcenter"
id=
"suppliers_container"
></div>
<div
class=
"txtcenter"
id=
"suppliers_container"
></div>
...
@@ -88,9 +87,6 @@
...
@@ -88,9 +87,6 @@
<div
class=
"order_created_header txtcenter"
>
<div
class=
"order_created_header txtcenter"
>
<h2>
Commandes créées !
</h2>
<h2>
Commandes créées !
</h2>
</div>
</div>
<div
class=
"txtcenter"
>
Livraison prévue le :
<span
id=
"recap_delivery_date"
>
XX/XX/XX
</span>
</div>
<div
id=
"created_orders_area"
></div>
<div
id=
"created_orders_area"
></div>
<br/><br/><hr/><br/>
<br/><br/><hr/><br/>
<div
class=
"mail_example_container"
>
<div
class=
"mail_example_container"
>
...
@@ -128,6 +124,7 @@
...
@@ -128,6 +124,7 @@
<div
class=
"new_order_item"
>
<div
class=
"new_order_item"
>
<h3
class=
"new_order_supplier_name"
></h3>
<h3
class=
"new_order_supplier_name"
></h3>
<h3
class=
"new_order_po"
></h3>
<h3
class=
"new_order_po"
></h3>
<h4
class=
"new_order_date_planned"
></h4>
<div
class=
'download_order_file'
>
<div
class=
'download_order_file'
>
<i
class=
"fas fa-spinner fa-spin download_order_file_loading"
></i>
<i
class=
"fas fa-spinner fa-spin download_order_file_loading"
></i>
<a
class=
'btn--success download_order_file_button'
style=
"display:none;"
href=
"#"
>
<a
class=
'btn--success download_order_file_button'
style=
"display:none;"
href=
"#"
>
...
@@ -168,13 +165,17 @@
...
@@ -168,13 +165,17 @@
Vous vous apprêtez à associer le produit
<span
class=
"product_name"
></span>
au fournisseur
<span
class=
"supplier_name"
></span>
.
<br/>
Vous vous apprêtez à associer le produit
<span
class=
"product_name"
></span>
au fournisseur
<span
class=
"supplier_name"
></span>
.
<br/>
</p>
</p>
<br/>
<br/>
<div
class=
"new_product_supplier_input_area"
>
<div
class=
"modal_input_area"
>
<span
class=
"new_product_supplier_label"
>
Prix du produit chez ce fournisseur:
</span>
<span
class=
"modal_input_label"
>
Prix du produit chez ce fournisseur:
</span>
<input
type=
"number"
class=
"new_product_supplier_input new_product_supplier_price"
>
<div
class=
"modal_input_container"
>
<input
type=
"number"
class=
"modal_input new_product_supplier_price"
>
</div>
</div>
</div>
<div
class=
"new_product_supplier_input_area"
>
<div
class=
"modal_input_area"
>
<span
class=
"new_product_supplier_label"
>
Colisage chez ce fournisseur:
</span>
<span
class=
"modal_input_label"
>
Colisage chez ce fournisseur:
</span>
<input
type=
"number"
class=
"new_product_supplier_input new_product_supplier_package_pty"
>
<div
class=
"modal_input_container"
>
<input
type=
"number"
class=
"modal_input new_product_supplier_package_pty"
>
</div>
</div>
</div>
<br/>
<br/>
<p>
<p>
...
@@ -203,13 +204,29 @@
...
@@ -203,13 +204,29 @@
</div>
</div>
<div
id=
"modal_create_order"
>
<div
id=
"modal_create_order"
>
<h3>
Attention !
</h3>
<h3>
Dernière étape...
</h3>
<br/>
<p>
<p>
Vous vous apprêtez à générer les commandes à partir des données rentrées dans le tableau.
Vous vous apprêtez à générer les commandes à partir des données rentrées dans le tableau.
</p>
</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/>
<hr/>
</div>
</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>
</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