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
80eee51d
Commit
80eee51d
authored
Jul 26, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manually delete orders
parent
0ee8de08
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
5 deletions
+138
-5
oders_helper_style.css
orders/static/css/oders_helper_style.css
+22
-0
orders_helper.js
orders/static/js/orders_helper.js
+103
-5
helper.html
templates/orders/helper.html
+13
-0
No files found.
orders/static/css/oders_helper_style.css
View file @
80eee51d
...
...
@@ -50,6 +50,28 @@
padding-top
:
15px
;
}
.order_pill
{
flex-direction
:
row
;
}
.pill_order_name
{
flex
:
3
0
auto
;
}
.remove_order_icon
{
flex
:
0
1
auto
;
color
:
#B22222
;
margin-left
:
5px
;
cursor
:
pointer
;
z-index
:
2
;
}
.remove_order_icon
:hover
{
color
:
#CD5C5C
;
}
.remove_order_name
{
font-weight
:
bold
;
}
.order_last_update
{
font-weight
:
bold
;
}
...
...
orders/static/js/orders_helper.js
View file @
80eee51d
...
...
@@ -625,11 +625,12 @@ function set_product_npa(p_id, npa) {
// Give time for modal to fade
setTimeout
(
function
()
{
$
.
notify
(
$
(
".actions_buttons_area .rights_buttons"
)
.
notify
(
"Produit passé en NPA !"
,
{
globalPosition
:
"top right"
,
className
:
"success"
position
:
"bottom right"
,
className
:
"success"
,
arrowShow
:
false
}
);
},
500
);
...
...
@@ -832,6 +833,8 @@ function create_cdb_order() {
/**
* Update order data of an existing order in couchdb
*
* @returns Promise resolved after update is complete
*/
function
update_cdb_order
()
{
order_doc
.
products
=
products
;
...
...
@@ -860,6 +863,28 @@ function update_cdb_order() {
}
/**
* Delete an order in couchdb.
*
* @returns Promise resolved after delete is complete
*/
function
delete_cdb_order
()
{
order_doc
.
_deleted
=
true
;
return
new
Promise
((
resolve
,
reject
)
=>
{
dbc
.
put
(
order_doc
,
function
callback
(
err
,
result
)
{
if
(
!
err
&&
result
!==
undefined
)
{
resolve
();
}
else
{
alert
(
"Erreur lors de la suppression de la commande... Si l'erreur persiste contactez un administrateur svp."
);
console
.
log
(
err
);
reject
();
}
});
});
}
/**
* Create the Product Orders in Odoo
*/
function
create_orders
()
{
...
...
@@ -965,8 +990,8 @@ function create_orders() {
get_order_attachments
();
// Clear data
order_doc
.
_deleted
=
true
;
update_cdb_order
().
then
(()
=>
{
delete_cdb_order
().
finally
(()
=>
{
// Continue with workflow anyway
update_order_selection_screen
().
then
(()
=>
{
reset_data
();
switch_screen
(
'orders_created'
);
...
...
@@ -1721,6 +1746,44 @@ function update_order_selection_screen() {
}
$
(
".order_pill"
).
on
(
"click"
,
order_pill_on_click
);
$
(
".remove_order_icon"
).
on
(
"click"
,
function
(
e
)
{
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
order_name_container
=
$
(
this
).
prev
()[
0
];
let
order_id
=
$
(
order_name_container
).
text
();
let
modal_remove_order
=
$
(
'#templates #modal_remove_order'
);
modal_remove_order
.
find
(
".remove_order_name"
).
text
(
order_id
);
openModal
(
modal_remove_order
.
html
(),
()
=>
{
if
(
is_time_to
(
'validate_remove_order'
))
{
dbc
.
get
(
order_id
).
then
((
doc
)
=>
{
order_doc
=
doc
;
delete_cdb_order
().
then
(()
=>
{
update_order_selection_screen
().
then
(()
=>
{
reset_data
();
setTimeout
(
function
()
{
$
.
notify
(
"Commande supprimée !"
,
{
globalPosition
:
"top left"
,
className
:
"success"
}
);
},
500
);
});
})
.
catch
(()
=>
{
console
.
log
(
"error deleting order"
);
});
});
}
},
'Valider'
);
});
}
resolve
();
...
...
@@ -1888,6 +1951,41 @@ $(document).ready(function() {
}
});
$
(
"#delete_order_button"
).
on
(
"click"
,
function
(
e
)
{
if
(
is_time_to
(
'press_delete_order_button'
,
1000
))
{
let
modal_remove_order
=
$
(
'#templates #modal_remove_order'
);
modal_remove_order
.
find
(
".remove_order_name"
).
text
(
order_doc
.
_id
);
openModal
(
modal_remove_order
.
html
(),
()
=>
{
if
(
is_time_to
(
'validate_remove_order'
))
{
delete_cdb_order
().
then
(()
=>
{
update_order_selection_screen
().
then
(()
=>
{
reset_data
();
switch_screen
(
'order_selection'
);
setTimeout
(
function
()
{
$
.
notify
(
"Commande supprimée !"
,
{
globalPosition
:
"top left"
,
className
:
"success"
}
);
},
500
);
});
})
.
catch
(()
=>
{
console
.
log
(
"error deleting order"
);
});
}
},
'Valider'
);
}
});
$
(
'#back_to_order_selection_from_main'
).
on
(
'click'
,
function
()
{
if
(
is_time_to
(
'back_to_order_selection_from_main'
,
1000
))
{
back
();
...
...
templates/orders/helper.html
View file @
80eee51d
...
...
@@ -41,6 +41,9 @@
<i
class=
"fas fa-arrow-left"
></i>
Retour
</button>
<div
class=
"rights_buttons"
>
<button
type=
"button"
class=
'btn--danger'
id=
"delete_order_button"
>
Supprimer la commande
</button>
<button
type=
"button"
class=
'btn--primary'
id=
"do_inventory"
style=
"display:none;"
>
Faire un inventaire
</button>
...
...
@@ -143,6 +146,7 @@
<div
id=
"order_pill_template"
>
<div
class=
"pill order_pill btn btn--primary"
>
<span
class=
"pill_order_name"
></span>
<i
class=
"fas fa-times remove_order_icon"
></i>
</div>
</div>
...
...
@@ -174,6 +178,15 @@
<hr/>
</div>
<div
id=
"modal_remove_order"
>
<h3>
Attention !
</h3>
<p>
Vous vous apprêtez à supprimer cette commande en cours :
<span
class=
"remove_order_name"
></span>
.
<br/>
</p>
<p>
Êtez-vous sûr ?
</p>
<hr/>
</div>
<div
id=
"modal_remove_supplier"
>
<h3>
Attention !
</h3>
<p>
...
...
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