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
2fa5307f
Commit
2fa5307f
authored
Jul 01, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
date planned for each supplier
parent
6ab2aecd
Show 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 @
2fa5307f
...
...
@@ -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 @
2fa5307f
...
...
@@ -182,27 +182,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 +232,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 @
2fa5307f
...
...
@@ -15,7 +15,6 @@ var dbc = null,
sync
=
null
,
order_doc
=
{
_id
:
null
,
date_planned
:
null
,
coverage_days
:
null
,
last_update
:
{
timestamp
:
null
,
...
...
@@ -42,7 +41,6 @@ function reset_data() {
product_orders
=
[];
order_doc
=
{
_id
:
null
,
date_planned
:
null
,
coverage_days
:
null
,
last_update
:
{
timestamp
:
null
,
...
...
@@ -718,13 +716,44 @@ function update_cdb_order() {
* Create the Product Orders in Odoo
*/
function
create_orders
()
{
openModal
();
let
orders_data
=
{
"date_planned"
:
order_doc
.
date_planned
,
"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
for
(
let
p
of
products
)
{
for
(
let
p_supplierinfo
of
p
.
suppliersinfo
)
{
...
...
@@ -732,12 +761,7 @@ function create_orders() {
if
(
'qty'
in
p_supplierinfo
)
{
const
supplier_id
=
p_supplierinfo
.
supplier_id
;
// Create entry for this supplier in data object if doesn't exist
if
(
orders_data
.
suppliers_data
[
supplier_id
]
===
undefined
)
{
orders_data
.
suppliers_data
[
supplier_id
]
=
[];
}
orders_data
.
suppliers_data
[
supplier_id
].
push
({
orders_data
.
suppliers_data
[
supplier_id
].
lines
.
push
({
'package_qty'
:
p_supplierinfo
.
package_qty
,
'product_id'
:
p
.
id
,
'name'
:
p
.
name
,
...
...
@@ -752,13 +776,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
({
type
:
"POST"
,
url
:
"/orders/create_orders"
,
...
...
@@ -767,12 +784,16 @@ function create_orders() {
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
orders_data
),
success
:
(
result
)
=>
{
$
(
'#recap_delivery_date'
).
text
(
$
(
'#date_planned_input'
).
val
());
// Display new orders
for
(
let
new_order
of
result
.
res
.
created
)
{
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
({
'id'
:
new_order
.
id_po
,
'supplier_id'
:
new_order
.
supplier_id
,
...
...
@@ -783,6 +804,7 @@ function create_orders() {
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_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
}
`
);
$
(
'#created_orders_area'
).
append
(
new_order_template
.
html
());
...
...
@@ -1410,17 +1432,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
)
{
$
(
"#coverage_days_input"
).
val
(
order_doc
.
coverage_days
);
}
else
{
...
...
@@ -1587,13 +1598,18 @@ $(document).ready(function() {
});
$
(
'#create_orders'
).
on
(
'click'
,
function
()
{
if
(
order_doc
.
date_planned
===
null
)
{
alert
(
"Veuillez rentrer une date de livraison prévue."
);
let
modal_create_order
=
$
(
'#templates #modal_create_order'
);
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
(
modal_create_order
.
html
(),
...
...
@@ -1604,6 +1620,26 @@ $(document).ready(function() {
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
;
});
...
...
@@ -1635,40 +1671,6 @@ $(document).ready(function() {
};
$
.
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
update_order_selection_screen
();
...
...
orders/views.py
View file @
2fa5307f
...
...
@@ -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
:
...
...
templates/orders/helper.html
View file @
2fa5307f
...
...
@@ -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>
...
...
@@ -88,9 +87,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 +124,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 +165,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=
"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
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>
<br/>
<p>
...
...
@@ -203,13 +204,29 @@
</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