Commit 07250cbf by Damien Moulard

fix merge conflict with dev

parents 15c034c5 7a0149bc
Pipeline #1283 passed with stage
in 1 minute 39 seconds
## Add odoo user login button
- In the template, include "conn_admin.html" as following :
```
{% block content %}
{% include "common/conn_admin.html" %}
```
- In the JS code, use the following pattern (for example) :
```
$(document).ready(function() {
if (coop_is_connected()) {
show content
}
}
```
...@@ -97,7 +97,8 @@ SHIFT_INFO = """A la cagette, un service est une plage de trois heures un jour ...@@ -97,7 +97,8 @@ SHIFT_INFO = """A la cagette, un service est une plage de trois heures un jour
PB_INSTRUCTIONS = """Si j'ai un problème, que je suis désinscrit, que je veux changer de créneaux ou quoi que ce soit, merci de vous rendre dans la section \"J'ai un problème\" sur le site web de <a href=\"https://lacagette-coop.fr/?MonEspaceMembre\">La Cagette</a>""" PB_INSTRUCTIONS = """Si j'ai un problème, que je suis désinscrit, que je veux changer de créneaux ou quoi que ce soit, merci de vous rendre dans la section \"J'ai un problème\" sur le site web de <a href=\"https://lacagette-coop.fr/?MonEspaceMembre\">La Cagette</a>"""
ENTRANCE_COME_FOR_SHOPING_MSG = "Hey coucou toi ! Cet été nous sommes plus de <strong>1000 acheteur·euses</strong> pour seulement <strong>300 coopérateur·rice·s</strong> en service. <br />Tu fais tes courses à La Cagette cet été ?<br/> Inscris-toi sur ton espace membre !" ENTRANCE_COME_FOR_SHOPING_MSG = "Hey coucou toi ! Cet été nous sommes plus de <strong>1000 acheteur·euses</strong> pour seulement <strong>300 coopérateur·rice·s</strong> en service. <br />Tu fais tes courses à La Cagette cet été ?<br/> Inscris-toi sur ton espace membre !"
ENTRANCE_EXTRA_BUTTONS_DISPLAY = False
ENTRANCE_EASY_SHIFT_VALIDATE = True
# Members space / shifts # Members space / shifts
UNSUBSCRIBED_MSG = 'Vous êtes désincrit·e, merci de remplir <a href="https://docs.google.com/forms/d/e/1FAIpQLSfPiC2PkSem9x_B5M7LKpoFNLDIz0k0V5I2W3Mra9AnqnQunw/viewform">ce formulaire</a> pour vous réinscrire sur un créneau.<br />Vous pouvez également contacter le Bureau des Membres en remplissant <a href="https://docs.google.com/forms/d/e/1FAIpQLSeZP0m5-EXPVJxEKJk6EjwSyZJtnbiGdYDuAeFI3ENsHAOikg/viewform">ce formulaire</a>' UNSUBSCRIBED_MSG = 'Vous êtes désincrit·e, merci de remplir <a href="https://docs.google.com/forms/d/e/1FAIpQLSfPiC2PkSem9x_B5M7LKpoFNLDIz0k0V5I2W3Mra9AnqnQunw/viewform">ce formulaire</a> pour vous réinscrire sur un créneau.<br />Vous pouvez également contacter le Bureau des Membres en remplissant <a href="https://docs.google.com/forms/d/e/1FAIpQLSeZP0m5-EXPVJxEKJk6EjwSyZJtnbiGdYDuAeFI3ENsHAOikg/viewform">ce formulaire</a>'
CONFIRME_PRESENT_BTN = 'Clique ici pour valider ta présence' CONFIRME_PRESENT_BTN = 'Clique ici pour valider ta présence'
...@@ -111,3 +112,5 @@ DISPLAY_COL_AUTRES = False ...@@ -111,3 +112,5 @@ DISPLAY_COL_AUTRES = False
# Should block service exchange if old service is happening in less than 24h # Should block service exchange if old service is happening in less than 24h
BLOCK_SERVICE_EXCHANGE_24H_BEFORE = True BLOCK_SERVICE_EXCHANGE_24H_BEFORE = True
# URL to the metabase dashboard for orders helper
ORDERS_HELPER_METABASE_URL = "https://metabase.lacagette-coop.fr/dashboard/16"
...@@ -22,7 +22,7 @@ class CagetteMember(models.Model): ...@@ -22,7 +22,7 @@ class CagetteMember(models.Model):
"""Class to handle cagette Odoo member.""" """Class to handle cagette Odoo member."""
m_default_fields = ['name', 'sex', 'image_medium', 'active', m_default_fields = ['name', 'sex', 'image_medium', 'active',
'barcode_base', 'barcode', 'in_ftop_team', 'barcode_base', 'barcode', 'in_ftop_team',
'is_associated_people', 'is_member', 'is_associated_people', 'is_member', 'shift_type',
'display_ftop_points', 'display_std_points', 'display_ftop_points', 'display_std_points',
'is_exempted', 'cooperative_state', 'date_alert_stop'] 'is_exempted', 'cooperative_state', 'date_alert_stop']
...@@ -1176,6 +1176,44 @@ class CagetteServices(models.Model): ...@@ -1176,6 +1176,44 @@ class CagetteServices(models.Model):
result['service_found'] = False result['service_found'] = False
return result return result
@staticmethod
def easy_validate_shift_presence(coop_id):
"""Add a presence point if the request is valid."""
res = {}
try:
api = OdooAPI()
# let verify coop_id is corresponding to a ftop subscriber
cond = [['id', '=', coop_id]]
fields = ['shift_type']
coop = api.search_read('res.partner', cond, fields)
if coop:
if coop[0]['shift_type'] == 'ftop':
evt_name = getattr(settings, 'ENTRANCE_ADD_PT_EVENT_NAME', 'Validation service comité')
c = [['partner_id', '=', coop_id], ['name', '=', evt_name]]
f = ['create_date']
last_point_mvts = api.search_read('shift.counter.event', c, f,
order ="create_date DESC", limit=1)
ok_for_adding_pt = False
if len(last_point_mvts):
now = datetime.datetime.now()
past = datetime.datetime. strptime(last_point_mvts[0]['create_date'],
'%Y-%m-%d %H:%M:%S')
if (now - past).total_seconds() >= 3600 * 24:
ok_for_adding_pt = True
else:
ok_for_adding_pt = True
if ok_for_adding_pt is True:
res['evt_id'] = CagetteMember(coop_id).add_pts('ftop', 1, evt_name)
else:
res['error'] = "One point has been added less then 24 hours ago"
else:
res['error'] = "Unallowed coop"
else:
res['error'] = "Invalid coop id"
except Exception as e:
coop_logger.error("easy_validate_shift_presence : %s %s", str(coop_id), str(e))
return res
class CagetteUser(models.Model): class CagetteUser(models.Model):
@staticmethod @staticmethod
......
...@@ -58,7 +58,8 @@ h1 .member_name {font-weight: bold;} ...@@ -58,7 +58,8 @@ h1 .member_name {font-weight: bold;}
#member_slide .btn[data-next] #member_slide .btn[data-next]
{margin-top: 35px; background: #449d44; color:#FFF;} {margin-top: 35px; background: #449d44; color:#FFF;}
[data-next="rattrapage_1"] {float:right;color:#171A17 !important; margin-top: 25px;} [data-next="rattrapage_1"] {float:right;color:#171A17 !important; margin-top: 25px;}
#service_en_cours .info a {line-height: 24px; font-size:18px; margin-top:15px;} #service_en_cours .info {font-size: 26px;}
#service_en_cours .info a {line-height: 24px; font-size:14px; margin-top:15px;}
.outside_list a {margin-left:15px;} .outside_list a {margin-left:15px;}
#rattrapage_1 .advice {margin-top:15px;} #rattrapage_1 .advice {margin-top:15px;}
.btn.present {background:#50C878;} .btn.present {background:#50C878;}
...@@ -67,3 +68,5 @@ h1 .member_name {font-weight: bold;} ...@@ -67,3 +68,5 @@ h1 .member_name {font-weight: bold;}
.msg-big {font-size: xx-large; background: #fff; padding:25px; text-align: center;} .msg-big {font-size: xx-large; background: #fff; padding:25px; text-align: center;}
#member_advice {background: #FFF; color: red;} #member_advice {background: #FFF; color: red;}
.easy_shift_validate {text-align: center; margin-top: 3em;}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
})(jQuery); })(jQuery);
var current_displayed_member = null, var current_displayed_member = null,
operator = null,
results = null, results = null,
loaded_services = null, loaded_services = null,
selected_service = null, selected_service = null,
...@@ -23,6 +24,8 @@ var current_displayed_member = null, ...@@ -23,6 +24,8 @@ var current_displayed_member = null,
rattrapage_ou_volant = null, rattrapage_ou_volant = null,
timeout_counter = null; timeout_counter = null;
var search_button = $('.btn--primary.search'); var search_button = $('.btn--primary.search');
var sm_search_member_button = $('#sm_search_member_button'),
sm_search_member_input = $('#sm_search_member_input');
var loading2 = $('.loading2'); var loading2 = $('.loading2');
var search_field = $('input[name="search_string"]'); var search_field = $('input[name="search_string"]');
var shift_title = $('#current_shift_title'); var shift_title = $('#current_shift_title');
...@@ -36,6 +39,8 @@ var photo_advice = $('#photo_advice'); ...@@ -36,6 +39,8 @@ var photo_advice = $('#photo_advice');
var photo_studio = $('#photo_studio'); var photo_studio = $('#photo_studio');
var coop_info = $('.coop-info'); var coop_info = $('.coop-info');
const missed_begin_msg = $('#missed_begin_msg').html();
let no_pict_msg = $('#no-picture-msg'); let no_pict_msg = $('#no-picture-msg');
var pages = { var pages = {
...@@ -162,6 +167,7 @@ function canSearch() { ...@@ -162,6 +167,7 @@ function canSearch() {
function search_member(force_search = false) { function search_member(force_search = false) {
chars = []; // to prevent false "as barcode-reader" input chars = []; // to prevent false "as barcode-reader" input
operator = null;
if (canSearch() || force_search) { if (canSearch() || force_search) {
html_elts.member_slide.hide(); html_elts.member_slide.hide();
...@@ -279,7 +285,15 @@ function fill_service_entry(s) { ...@@ -279,7 +285,15 @@ function fill_service_entry(s) {
rattrapage_wanted.show(); rattrapage_wanted.show();
} }
function clean_search_for_easy_validate_zone() {
$('.search_member_results_area').hide();
$('.search_member_results').empty();
sm_search_member_input.val('');
operator = null;
}
function clean_service_entry() { function clean_service_entry() {
clean_search_for_easy_validate_zone();
rattrapage_wanted.hide(); rattrapage_wanted.hide();
shift_title.text(''); shift_title.text('');
shift_members.html(''); shift_members.html('');
...@@ -346,8 +360,8 @@ function get_service_entry_data() { ...@@ -346,8 +360,8 @@ function get_service_entry_data() {
page_title.text('Qui es-tu ?'); page_title.text('Qui es-tu ?');
try { try {
if (rData.res.length == 0) { if (rData.res.length == 0) {
info_place.text('La période pendant laquelle il est possible de s\'enregistrer est close.'); info_place.html(missed_begin_msg);
page_title.text(''); page_title.html('');
} else { } else {
if (rData.res.length > 1) { if (rData.res.length > 1) {
...@@ -667,6 +681,73 @@ html_elts.image_medium.on('click', function() { ...@@ -667,6 +681,73 @@ html_elts.image_medium.on('click', function() {
} }
}); });
function ask_for_easy_shift_validation() {
//alert("operator = " + JSON.stringify(operator))
msg = "<p>Je suis bien " + operator.name + "<br/> et <br/>je valide mon service 'Comité' </p>";
openModal(msg, function() {
try {
post_form(
'/members/easy_validate_shift_presence',
{
coop_id: operator.id
},
function(err, result) {
if (!err) {
alert("1 point volant vient d'être ajouté.");
clean_search_for_easy_validate_zone();
closeModal();
} else {
if (typeof (err.responseJSON) != "undefined"
&& typeof (err.responseJSON.error) != "undefined") {
alert(err.responseJSON.error);
} else {
console.log(err);
}
}
}
);
} catch (e) {
console.log(e);
}
}, 'Confirmer');
}
// Display the members from the search result (copied from stock_movements)
function display_possible_members() {
$('.search_member_results_area').show();
$('.search_member_results').empty();
if (members_search_results.length > 0) {
for (member of members_search_results) {
let btn_classes = "btn";
if (operator != null && operator.id == member.id) {
btn_classes = "btn--success";
}
// Display results (possible members) as buttons
var member_button = '<button class="' + btn_classes + ' btn_member" member_id="'
+ member.id + '">'
+ member.barcode_base + ' - ' + member.name
+ '</button>';
$('.search_member_results').append(member_button);
// Set action on click on a member button
$('.btn_member').on('click', function() {
for (member of members_search_results) {
if (member.id == $(this).attr('member_id')) {
operator = member;
// Enable validation button when operator is selected
ask_for_easy_shift_validation();
break;
}
}
display_possible_members();
});
}
} else {
$('.search_member_results').html('<p><i>Aucun résultat ! Faites-vous partie d\'un comité ? <br/> Si oui, vérifiez la recherche..</i></p>');
}
}
$(document).ready(function() { $(document).ready(function() {
var shopping_entry_btn = $('a[data-next="shopping_entry"]'); var shopping_entry_btn = $('a[data-next="shopping_entry"]');
...@@ -708,6 +789,44 @@ $(document).ready(function() { ...@@ -708,6 +789,44 @@ $(document).ready(function() {
init_webcam(); init_webcam();
}); });
$('#sm_search_member_form').submit(function() {
if (is_time_to('search_member', 1000)) {
sm_search_member_button.empty().append(`<i class="fas fa-spinner fa-spin"></i>`);
let search_str = sm_search_member_input.val();
$.ajax({
url: '/members/search/' + search_str,
dataType : 'json',
success: function(data) {
members_search_results = [];
for (member of data.res) {
if (member.shift_type == 'ftop') {
members_search_results.push(member);
}
}
display_possible_members();
},
error: function(data) {
err = {
msg: "erreur serveur lors de la recherche de membres",
ctx: 'easy_validate.search_members'
};
report_JS_error(err, 'members');
$.notify("Erreur lors de la recherche de membre, il faut ré-essayer plus tard...", {
globalPosition:"top right",
className: "error"
});
},
complete: function() {
sm_search_member_button.empty().append(`Recherche`);
}
});
}
});
}); });
Webcam.on('live', function() { Webcam.on('live', function() {
......
...@@ -46,6 +46,7 @@ urlpatterns = [ ...@@ -46,6 +46,7 @@ urlpatterns = [
url(r'^remove_data_from_couchdb$', views.remove_data_from_CouchDB), url(r'^remove_data_from_couchdb$', views.remove_data_from_CouchDB),
url(r'^image/([0-9]+)', views.getmemberimage), url(r'^image/([0-9]+)', views.getmemberimage),
url(r'^add_pts_to_everybody/([0-9]+)/([a-zA-Z0-9_ ]+)$', admin.add_pts_to_everybody), url(r'^add_pts_to_everybody/([0-9]+)/([a-zA-Z0-9_ ]+)$', admin.add_pts_to_everybody),
url(r'^easy_validate_shift_presence$', views.easy_validate_shift_presence),
# conso / groupe recherche / socio # conso / groupe recherche / socio
url(r'^panel_get_purchases$', views.panel_get_purchases), url(r'^panel_get_purchases$', views.panel_get_purchases),
] ]
...@@ -24,6 +24,10 @@ def index(request): ...@@ -24,6 +24,10 @@ def index(request):
'WELCOME_SUBTITLE_ENTRANCE_MSG': getattr(settings, 'WELCOME_SUBTITLE_ENTRANCE_MSG', ''), 'WELCOME_SUBTITLE_ENTRANCE_MSG': getattr(settings, 'WELCOME_SUBTITLE_ENTRANCE_MSG', ''),
'ENTRANCE_SHOPPING_BTN': getattr(settings, 'ENTRANCE_SHOPPING_BTN', 'Je viens faire mes courses'), 'ENTRANCE_SHOPPING_BTN': getattr(settings, 'ENTRANCE_SHOPPING_BTN', 'Je viens faire mes courses'),
'ENTRANCE_SERVICE_BTN': getattr(settings, 'ENTRANCE_SERVICE_BTN', 'Je viens faire mon service'), 'ENTRANCE_SERVICE_BTN': getattr(settings, 'ENTRANCE_SERVICE_BTN', 'Je viens faire mon service'),
'ENTRANCE_MISSED_SHIFT_BEGIN_MSG': getattr(settings, 'ENTRANCE_MISSED_SHIFT_BEGIN_MSG',
"La période pendant laquelle il est possible de s'enregistrer est close."),
'ENTRANCE_EASY_SHIFT_VALIDATE_MSG': getattr(settings, 'ENTRANCE_EASY_SHIFT_VALIDATE_MSG',
'Je valide mon service "Comité"'),
'CONFIRME_PRESENT_BTN' : getattr(settings, 'CONFIRME_PRESENT_BTN', 'Présent.e') 'CONFIRME_PRESENT_BTN' : getattr(settings, 'CONFIRME_PRESENT_BTN', 'Présent.e')
} }
for_shoping_msg = getattr(settings, 'ENTRANCE_COME_FOR_SHOPING_MSG', '') for_shoping_msg = getattr(settings, 'ENTRANCE_COME_FOR_SHOPING_MSG', '')
...@@ -33,6 +37,8 @@ def index(request): ...@@ -33,6 +37,8 @@ def index(request):
for_shoping_msg = msettings['msg_accueil']['value'] for_shoping_msg = msettings['msg_accueil']['value']
context['ENTRANCE_COME_FOR_SHOPING_MSG'] = for_shoping_msg context['ENTRANCE_COME_FOR_SHOPING_MSG'] = for_shoping_msg
context['ftop_btn_display'] = getattr(settings, 'ENTRANCE_FTOP_BUTTON_DISPLAY', True) context['ftop_btn_display'] = getattr(settings, 'ENTRANCE_FTOP_BUTTON_DISPLAY', True)
context['extra_btns_display'] = getattr(settings, 'ENTRANCE_EXTRA_BUTTONS_DISPLAY', True)
context['easy_shift_validate'] = getattr(settings, 'ENTRANCE_EASY_SHIFT_VALIDATE', False)
if 'no_picture_member_advice' in msettings: if 'no_picture_member_advice' in msettings:
if len(msettings['no_picture_member_advice']['value']) > 0: if len(msettings['no_picture_member_advice']['value']) > 0:
context['no_picture_member_advice'] = msettings['no_picture_member_advice']['value'] context['no_picture_member_advice'] = msettings['no_picture_member_advice']['value']
...@@ -283,6 +289,22 @@ def record_service_presence(request): ...@@ -283,6 +289,22 @@ def record_service_presence(request):
res['error'] = str(e) res['error'] = str(e)
return JsonResponse({'res': res}) return JsonResponse({'res': res})
def easy_validate_shift_presence(request):
"""Add a presence point if the request is valid."""
res = {}
try:
coop_id = int(request.POST.get("coop_id", "nan"))
res = CagetteServices.easy_validate_shift_presence(coop_id)
except Exception as e:
res['error'] = str(e)
if 'error' in res:
if res['error'] == "One point has been added less then 24 hours ago":
# TODO : use translation (all project wide)
res['error'] = "Vous ne pouvez pas valider plus d'un service par 24h"
return JsonResponse(res, status=500)
else:
return JsonResponse(res, safe=False)
def record_absences(request): def record_absences(request):
return JsonResponse({'res': CagetteServices.record_absences()}) return JsonResponse({'res': CagetteServices.record_absences()})
......
...@@ -258,6 +258,11 @@ class Order(models.Model): ...@@ -258,6 +258,11 @@ class Order(models.Model):
} }
for line in order_lines: for line in order_lines:
product_line_name = line["name"]
if "product_code" in line and line["product_code"] is not False:
product_code = str(line["product_code"])
product_line_name = "[" + product_code + "] " + product_line_name
order_data["order_line"].append( order_data["order_line"].append(
[ [
0, 0,
...@@ -267,7 +272,7 @@ class Order(models.Model): ...@@ -267,7 +272,7 @@ class Order(models.Model):
"price_policy": "uom", "price_policy": "uom",
"indicative_package": True, "indicative_package": True,
"product_id": line["product_variant_ids"][0], "product_id": line["product_variant_ids"][0],
"name": line["name"], "name": product_line_name,
"date_planned": date_planned, "date_planned": date_planned,
"account_analytic_id": False, "account_analytic_id": False,
"product_qty_package":line["product_qty_package"], "product_qty_package":line["product_qty_package"],
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
position: relative; position: relative;
} }
.page_content { .page_content, .login_area {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 5px 30px 5px 30px; padding: 7px 30px 7px 30px;
margin: 0 10px 5px 10px; margin: 0 10px 5px 10px;
} }
...@@ -31,6 +31,26 @@ ...@@ -31,6 +31,26 @@
background-color: #a1a2a3; background-color: #a1a2a3;
} }
.link_as_button:hover {
text-decoration: none;
color: white;
}
.link_as_button:active {
text-decoration: none;
color: white;
}
.link_as_button:focus {
text-decoration: none;
color: white;
}
.remove_order_modal_text {
font-size: 2rem;
}
.remove_order_name {
font-weight: bold;
}
/* - Order selection screen */ /* - Order selection screen */
#new_order_area { #new_order_area {
margin-bottom: 40px; margin-bottom: 40px;
...@@ -50,6 +70,25 @@ ...@@ -50,6 +70,25 @@
padding-top: 15px; padding-top: 15px;
} }
.order_pill {
flex-direction: row;
}
.pill_order_name {
flex: 3 0 auto;
}
.remove_order_icon {
flex: 0 1 auto;
color: #912930;
margin-left: 5px;
cursor: pointer;
z-index: 2;
transform: scale(1.2);
}
.remove_order_icon:hover {
color: #e62720;
}
.order_last_update { .order_last_update {
font-weight: bold; font-weight: bold;
} }
...@@ -82,6 +121,40 @@ ...@@ -82,6 +121,40 @@
justify-content: flex-start; justify-content: flex-start;
} }
.right_action_buttons {
display: flex;
}
#actions_buttons_wrapper {
position: relative;
margin-right: 5px;
}
#toggle_action_buttons {
width: 250px;
position: relative;
}
.toggle_action_buttons_icon {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 15px;
}
#actions_buttons_container {
position: absolute;
display: flex;
flex-direction: column;
width: 250px;
display: none;
}
.action_button {
width: 100%;
min-height: 45px;
}
/* -- Order data */ /* -- Order data */
#order_data_container { #order_data_container {
font-size: 1.8rem; font-size: 1.8rem;
...@@ -92,17 +165,27 @@ ...@@ -92,17 +165,27 @@
} }
#order_forms_container { #order_forms_container {
margin-top: 30px; margin-top: 20px;
display: flex; display: flex;
flex-wrap: wrap;
justify-content: space-evenly; justify-content: space-evenly;
} }
.order_form_item {
margin-top: 10px;
}
#supplier_input { #supplier_input {
width: 350px; width: 350px;
border-radius: 3px; border-radius: 3px;
} }
#date_planned_input, #coverage_days_input { #stats_date_period_select {
margin-left: 5px;
min-width: 200px;
}
#date_planned_input, #coverage_days_input, #stats_date_period_select {
border-radius: 3px; border-radius: 3px;
} }
...@@ -144,13 +227,26 @@ ...@@ -144,13 +227,26 @@
width: 100px; width: 100px;
} }
.product_ref_input {
padding: .5rem .5rem;
}
.supplier_package_qty { .supplier_package_qty {
font-style: italic; font-style: italic;
font-size: 1.3rem; font-size: 1.3rem;
} }
.product_not_from_supplier { .product_not_from_supplier {
background-color: #e7e9ed; background-color: #e8ebf0;
cursor: pointer;
}
.product_not_from_supplier:hover {
background-color: #d3d7db;
}
.product_ref_cell:hover {
background-color: #d3d7db;
cursor: pointer; cursor: pointer;
} }
...@@ -162,6 +258,18 @@ ...@@ -162,6 +258,18 @@
cursor: pointer; cursor: pointer;
} }
.focused_line {
background-color: #76cf71 !important;
}
.dataTables_scrollHead {
position: sticky !important;
position: -webkit-sticky !important;
top: 0;
z-index: 3;
background-color: white;
}
/* -- Footer */ /* -- Footer */
#main_content_footer { #main_content_footer {
...@@ -181,19 +289,24 @@ ...@@ -181,19 +289,24 @@
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
margin: 30px 0 20px 0; margin: 30px 0 20px 0;
position: -webkit-sticky;
position: sticky;
top: 140px;
z-index: 5;
} }
.supplier_pill { .supplier_pill {
background-color: #e7e9edc5; background-color: #a0daff;
border: 1px solid black; border: 1px solid #6ea8cc;
} }
.pill_supplier_name { .pill_supplier_name {
font-weight: bold; font-weight: bold;
} }
.supplier_total_value_container { .supplier_data {
font-size: 1.5rem; font-size: 1.5rem;
display: flex;
} }
.remove_supplier_icon { .remove_supplier_icon {
...@@ -249,19 +362,6 @@ ...@@ -249,19 +362,6 @@
margin-top: 10px; margin-top: 10px;
} }
.download_order_file_button:hover {
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 { #recap_delivery_date {
font-weight: bold; font-weight: bold;
} }
......
...@@ -13,6 +13,7 @@ urlpatterns = [ ...@@ -13,6 +13,7 @@ urlpatterns = [
url(r'^get_suppliers$', views.get_suppliers), url(r'^get_suppliers$', views.get_suppliers),
url(r'^get_supplier_products$', views.get_supplier_products), url(r'^get_supplier_products$', views.get_supplier_products),
url(r'^associate_supplier_to_product$', views.associate_supplier_to_product), url(r'^associate_supplier_to_product$', views.associate_supplier_to_product),
url(r'^end_supplier_product_association$', views.end_supplier_product_association),
url(r'^create_orders$', views.create_orders), url(r'^create_orders$', views.create_orders),
url(r'^get_orders_attachment$', views.get_orders_attachment), url(r'^get_orders_attachment$', views.get_orders_attachment),
] ]
...@@ -19,7 +19,8 @@ def helper(request): ...@@ -19,7 +19,8 @@ def helper(request):
'title': 'Aide à la commande', 'title': 'Aide à la commande',
'couchdb_server': settings.COUCHDB['url'], 'couchdb_server': settings.COUCHDB['url'],
'db': settings.COUCHDB['dbs']['orders'], 'db': settings.COUCHDB['dbs']['orders'],
'odoo_server': settings.ODOO['url'] 'odoo_server': settings.ODOO['url'],
'metabase_url': getattr(settings, 'ORDERS_HELPER_METABASE_URL', '')
} }
template = loader.get_template('orders/helper.html') template = loader.get_template('orders/helper.html')
...@@ -42,7 +43,8 @@ def get_supplier_products(request): ...@@ -42,7 +43,8 @@ def get_supplier_products(request):
""" Get supplier products """ """ Get supplier products """
suppliers_id = request.GET.getlist('sids', '') suppliers_id = request.GET.getlist('sids', '')
res = CagetteProducts.get_products_for_order_helper(suppliers_id) stats_from = request.GET.get('stats_from')
res = CagetteProducts.get_products_for_order_helper(suppliers_id, [], stats_from)
if 'error' in res: if 'error' in res:
return JsonResponse(res, status=500) return JsonResponse(res, status=500)
...@@ -52,15 +54,29 @@ def get_supplier_products(request): ...@@ -52,15 +54,29 @@ def get_supplier_products(request):
def associate_supplier_to_product(request): def associate_supplier_to_product(request):
""" This product is now supplied by this supplier """ """ This product is now supplied by this supplier """
res = {} res = {}
try:
data = json.loads(request.body.decode()) data = json.loads(request.body.decode())
res = CagetteProduct.associate_supplier_to_product(data) res = CagetteProduct.associate_supplier_to_product(data)
except Exception as e:
res["error"] = str(e) if 'error' in res:
return JsonResponse(res, status=500) return JsonResponse(res, status=500)
else:
return JsonResponse({'res': res})
return JsonResponse({'res': res}) return JsonResponse({'res': res})
def end_supplier_product_association(request):
""" This product is now unavailable from this supplier """
res = {}
data = json.loads(request.body.decode())
res = CagetteProduct.end_supplier_product_association(data)
if 'error' in res:
return JsonResponse(res, status=500)
else:
return JsonResponse({'res': res})
def create_orders(request): def create_orders(request):
""" Create products orders """ """ Create products orders """
res = { "created": [] } res = { "created": [] }
......
...@@ -228,6 +228,22 @@ ...@@ -228,6 +228,22 @@
- ENTRANCE_SERVICE_BTN = "…faire <b>mon service 🤝" - ENTRANCE_SERVICE_BTN = "…faire <b>mon service 🤝"
- ENTRANCE_EXTRA_BUTTONS_DISPLAY = False (no button is shown above shift coop. list) (True if not set)
- ENTRANCE_EASY_SHIFT_VALIDATE = False (default value)
When set to True allow coop to identify and have 1 point (only if FTOP)
- ENTRANCE_ADD_PT_EVENT_NAME = 'Add 1 point name throught easy validate' (default : 'Validation service comité'')
- ENTRANCE_MISSED_SHIFT_BEGIN_MSG (default : "")
This message is dispayed when time to register is last
- ENTRANCE_EASY_SHIFT_VALIDATE_MSG (default = 'Je valide mon service "Comité"')
(makes sens if ENTRANCE_EASY_SHIFT_VALIDATE is True)
### Member space ### Member space
- EM_URL = '' - EM_URL = ''
......
...@@ -59,10 +59,9 @@ function post_form(url, data, callback) { ...@@ -59,10 +59,9 @@ function post_form(url, data, callback) {
$.post(ajax_params) $.post(ajax_params)
.done(function(rData) { .done(function(rData) {
callback(null, rData); callback(null, rData);
}) })
.fail(function(err) { .fail(function(err) {
console.log(err); callback(err, {});
}); });
} }
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint . --max-warnings 362 '**/*.js'", "lint": "eslint . --max-warnings 326 '**/*.js'",
"lint-fix": "eslint . --fix --max-warnings 362 '**/*.js'" "lint-fix": "eslint . --fix --max-warnings 326 '**/*.js'"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
...@@ -130,27 +130,91 @@ class CagetteProduct(models.Model): ...@@ -130,27 +130,91 @@ class CagetteProduct(models.Model):
@staticmethod @staticmethod
def associate_supplier_to_product(data): def associate_supplier_to_product(data):
api = OdooAPI() api = OdooAPI()
res = {}
product_tmpl_id = data["product_tmpl_id"] product_tmpl_id = data["product_tmpl_id"]
partner_id = data["supplier_id"] partner_id = data["supplier_id"]
package_qty = data["package_qty"] package_qty = data["package_qty"]
price = data["price"] price = data["price"]
# Look for existing association
f = ["id"]
c = [['product_tmpl_id', '=', product_tmpl_id], ['name', '=', partner_id]]
res_existing_supplierinfo = api.search_read('product.supplierinfo', c, f)
f = ["id", "standard_price", "purchase_ok"] if (len(res_existing_supplierinfo) > 0):
c = [['product_tmpl_id', '=', product_tmpl_id]] # A relation already exists, update it's start & end dates
res_products = api.search_read('product.product', c, f) psi_id = res_existing_supplierinfo[0]['id']
product = res_products[0]
f = { today = datetime.date.today().strftime("%Y-%m-%d")
'product_tmpl_id' : product_tmpl_id,
'product_id' : product["id"], f = {
'name' : partner_id, 'date_start': today,
'product_purchase_ok': product["purchase_ok"], 'date_end': False,
'price': price, 'price': price,
'base_price': price, 'base_price': price,
'package_qty': package_qty 'package_qty': package_qty,
} 'sequence': 1000 # lowest priority for the new suppliers
res = api.create('product.supplierinfo', f) }
try:
res["update"] = api.update('product.supplierinfo', psi_id, f)
except Exception as e:
res['error'] = str(e)
else:
# Relation doesn't exists, create one
f = ["id", "standard_price", "purchase_ok"]
c = [['product_tmpl_id', '=', product_tmpl_id]]
res_products = api.search_read('product.product', c, f)
product = res_products[0]
today = datetime.date.today().strftime("%Y-%m-%d")
f = {
'product_tmpl_id' : product_tmpl_id,
'product_id' : product["id"],
'name' : partner_id,
'product_purchase_ok': product["purchase_ok"],
'price': price,
'base_price': price,
'package_qty': package_qty,
'date_start': today,
'sequence': 1000 # lowest priority for the new suppliers
}
try:
res['create'] = api.create('product.supplierinfo', f)
except Exception as e:
res['error'] = str(e)
return res
@staticmethod
def end_supplier_product_association(data):
api = OdooAPI()
res = {}
product_tmpl_id = data["product_tmpl_id"]
partner_id = data["supplier_id"]
f = ["id"]
c = [['product_tmpl_id', '=', product_tmpl_id], ['name', '=', partner_id], ['date_end', '=', False]]
res_supplierinfo = api.search_read('product.supplierinfo', c, f)
# End all active associations in case multiple are open (which shouldn't happen)
for psi in res_supplierinfo:
psi_id = psi['id']
today = datetime.date.today().strftime("%Y-%m-%d")
f = {
'date_end': today
}
try:
res["update"] = api.update('product.supplierinfo', psi_id, f)
except Exception as e:
res['error'] = str(e)
return res return res
...@@ -171,6 +235,23 @@ class CagetteProduct(models.Model): ...@@ -171,6 +235,23 @@ class CagetteProduct(models.Model):
return res return res
@staticmethod
def update_product_internal_ref(product_tmpl_id, default_code):
api = OdooAPI()
res = {}
f = {
'default_code': default_code
}
try:
res["update"] = api.update('product.template', product_tmpl_id, f)
except Exception as e:
res["error"] = str(e)
print(str(e))
return res
class CagetteProducts(models.Model): class CagetteProducts(models.Model):
"""Initially used to make massive barcode update.""" """Initially used to make massive barcode update."""
...@@ -455,31 +536,32 @@ class CagetteProducts(models.Model): ...@@ -455,31 +536,32 @@ class CagetteProducts(models.Model):
return res return res
@staticmethod @staticmethod
def get_products_for_order_helper(supplier_ids, pids = []): def get_products_for_order_helper(supplier_ids, pids = [], stats_from = None):
""" """
One of the two parameters must be not empty. supplier_ids: Get products by supplier if one or more supplier id is set. If set, pids is ignored.
Get products by supplier if one or more supplier_id is set. pids: If set & supplier_ids is None/empty, get products specified in pids. In this case, suppliers info won't be fetched.
If supplier_ids is empty, get products specified in pids. In this case, suppliers info won't be fetched. stats_from: date from which we should calculate sells stats.
""" """
api = OdooAPI() api = OdooAPI()
res = {} res = {}
# todo : try with no result
try: try:
today = datetime.date.today().strftime("%Y-%m-%d") today = datetime.date.today().strftime("%Y-%m-%d")
if supplier_ids is not None and len(supplier_ids) > 0: if supplier_ids is not None and len(supplier_ids) > 0:
# Get products/supplier relation # Get products/supplier relation
f = ["product_tmpl_id", 'date_start', 'date_end', 'package_qty', 'price', 'name'] f = ["product_tmpl_id", 'date_start', 'date_end', 'package_qty', 'price', 'name', 'product_code']
c = [['name', 'in', [ int(x) for x in supplier_ids]]] c = [['name', 'in', [ int(x) for x in supplier_ids]]]
psi = api.search_read('product.supplierinfo', c, f) psi = api.search_read('product.supplierinfo', c, f)
# Filter valid data # Filter valid data
ptids = [] ptids = []
valid_psi = []
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_end"] is not False and p["date_start"] <= today) and (p["date_start"] is False or p["date_start"] is not False and p["date_start"] <= today)
and (p["date_end"] is False or p["date_end"] is not False and p["date_end"] >= today)): and (p["date_end"] is False or p["date_end"] is not False and p["date_end"] > today)):
valid_psi.append(p)
ptids.append(p["product_tmpl_id"][0]) ptids.append(p["product_tmpl_id"][0])
else: else:
ptids = [ int(x) for x in pids ] ptids = [ int(x) for x in pids ]
...@@ -506,6 +588,10 @@ class CagetteProducts(models.Model): ...@@ -506,6 +588,10 @@ class CagetteProducts(models.Model):
# 'from': '2019-04-10', # 'from': '2019-04-10',
# 'to': '2019-08-10', # 'to': '2019-08-10',
} }
if stats_from is not None and stats_from != '':
sales_average_params['from'] = stats_from
sales = CagetteProducts.get_template_products_sales_average(sales_average_params) sales = CagetteProducts.get_template_products_sales_average(sales_average_params)
if 'list' in sales and len(sales['list']) > 0: if 'list' in sales and len(sales['list']) > 0:
...@@ -516,12 +602,16 @@ class CagetteProducts(models.Model): ...@@ -516,12 +602,16 @@ class CagetteProducts(models.Model):
# Add supplier data to product data # Add supplier data to product data
for i, fp in enumerate(filtered_products_t): for i, fp in enumerate(filtered_products_t):
if supplier_ids is not None and len(supplier_ids) > 0: if supplier_ids is not None and 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"]) # Add all the product suppliersinfo (products from multiple suppliers into the suppliers list provided)
filtered_products_t[i]['suppliersinfo'] = [{ filtered_products_t[i]['suppliersinfo'] = []
'supplier_id': int(psi_item["name"][0]), for psi_item in valid_psi:
'package_qty': psi_item["package_qty"], if psi_item["product_tmpl_id"] is not False and psi_item ["product_tmpl_id"][0] == fp["id"]:
'price': psi_item["price"] filtered_products_t[i]['suppliersinfo'].append({
}] 'supplier_id': int(psi_item["name"][0]),
'package_qty': psi_item["package_qty"],
'price': psi_item["price"],
'product_code': psi_item["product_code"]
})
for s in sales: for s in sales:
if s["id"] == fp["id"]: if s["id"] == fp["id"]:
......
...@@ -10,6 +10,7 @@ urlpatterns = [ ...@@ -10,6 +10,7 @@ urlpatterns = [
url(r'^get_products_stdprices$', views.get_products_stdprices), url(r'^get_products_stdprices$', views.get_products_stdprices),
url(r'^update_product_stock$', views.update_product_stock), url(r'^update_product_stock$', views.update_product_stock),
url(r'^update_product_purchase_ok$', views.update_product_purchase_ok), url(r'^update_product_purchase_ok$', views.update_product_purchase_ok),
url(r'^update_product_internal_ref$', views.update_product_internal_ref),
url(r'^labels_appli_csv(\/?[a-z]*)$', views.labels_appli_csv, name='labels_appli_csv'), url(r'^labels_appli_csv(\/?[a-z]*)$', views.labels_appli_csv, name='labels_appli_csv'),
url(r'^label_print/([0-9]+)/?([0-9\.]*)/?([a-z]*)/?([0-9]*)$', views.label_print), url(r'^label_print/([0-9]+)/?([0-9\.]*)/?([a-z]*)/?([0-9]*)$', views.label_print),
url(r'^shelf_labels$', views.shelf_labels), # massive print url(r'^shelf_labels$', views.shelf_labels), # massive print
......
...@@ -42,8 +42,10 @@ def get_simple_list(request): ...@@ -42,8 +42,10 @@ def get_simple_list(request):
def get_product_for_order_helper(request): def get_product_for_order_helper(request):
res = {} res = {}
try: try:
pids = json.loads(request.body.decode()) data = json.loads(request.body.decode())
res = CagetteProducts.get_products_for_order_helper(None, pids) pids = data['pids']
stats_from = data['stats_from']
res = CagetteProducts.get_products_for_order_helper(None, pids, stats_from)
except Exception as e: except Exception as e:
coop_logger.error("get_product_for_help_order_line : %s", str(e)) coop_logger.error("get_product_for_help_order_line : %s", str(e))
res['error'] = str(e) res['error'] = str(e)
...@@ -112,6 +114,17 @@ def update_product_purchase_ok(request): ...@@ -112,6 +114,17 @@ def update_product_purchase_ok(request):
else: else:
return JsonResponse({"res": res}) return JsonResponse({"res": res})
def update_product_internal_ref(request):
res = {}
data = json.loads(request.body.decode())
res = CagetteProduct.update_product_internal_ref(data["product_tmpl_id"], data["default_code"])
if ('error' in res):
return JsonResponse(res, status=500)
else:
return JsonResponse({"res": res})
def labels_appli_csv(request, params): def labels_appli_csv(request, params):
"""Generate files to put in DAV directory to be retrieved by scales app.""" """Generate files to put in DAV directory to be retrieved by scales app."""
withCandidate = False withCandidate = False
......
...@@ -31,7 +31,7 @@ class CagetteReception(models.Model): ...@@ -31,7 +31,7 @@ class CagetteReception(models.Model):
pids.append(int(r['purchase_id'][0])) pids.append(int(r['purchase_id'][0]))
if len(pids): if len(pids):
f=["id","name","date_order", "partner_id", "date_planned", "amount_untaxed", "amount_total", "x_reception_status"] f=["id","name","date_order", "partner_id", "date_planned", "amount_untaxed", "amount_total", "x_reception_status", 'create_uid']
# Only get orders that need to be treated in Reception # Only get orders that need to be treated in Reception
c = [['id', 'in', pids], ["x_reception_status", "in", [False, 'qty_valid', 'valid_pending', 'br_valid']]] c = [['id', 'in', pids], ["x_reception_status", "in", [False, 'qty_valid', 'valid_pending', 'br_valid']]]
...@@ -48,6 +48,25 @@ class CagetteReception(models.Model): ...@@ -48,6 +48,25 @@ class CagetteReception(models.Model):
def get_order_lines_by_po(id_po, nullQty=False): def get_order_lines_by_po(id_po, nullQty=False):
"""Return all purchases order lines linked with purchase order id in Odoo.""" """Return all purchases order lines linked with purchase order id in Odoo."""
return Order(id_po).get_lines(withNullQty=nullQty) return Order(id_po).get_lines(withNullQty=nullQty)
def get_mail_create_po(id_po):
"""Return name et email from id_po of order"""
try:
api = OdooAPI()
f = ["create_uid"]
c = [['id', '=', id_po]]
res = api.search_read('purchase.order', c, f)
f = ["email", "display_name"]
c = [['user_ids', '=', int(res[0]['create_uid'][0])]]
res = api.search_read('res.partner', c, f)
except Exception as e:
print(str(e))
return res
def implies_scale_file_generation(self): def implies_scale_file_generation(self):
answer = False answer = False
...@@ -132,6 +151,7 @@ class CagetteReception(models.Model): ...@@ -132,6 +151,7 @@ class CagetteReception(models.Model):
self.o_api.update('stock.move.operation.link', [linked_move_op_id], {'qty': received_products[pack['product_id'][0]]}) self.o_api.update('stock.move.operation.link', [linked_move_op_id], {'qty': received_products[pack['product_id'][0]]})
pfields['product_uom_qty'] = received_qty pfields['product_uom_qty'] = received_qty
self.o_api.update('stock.move', [move_id], pfields) self.o_api.update('stock.move', [move_id], pfields)
del pfields['product_uom_qty'] # field not in stock.pack.operation
pfields['qty_done'] = pfields['product_qty'] = received_qty pfields['qty_done'] = pfields['product_qty'] = received_qty
self.o_api.update('stock.pack.operation', [int(pack['id'])], pfields) self.o_api.update('stock.pack.operation', [int(pack['id'])], pfields)
processed_lines += 1 processed_lines += 1
......
...@@ -103,18 +103,29 @@ function goto(id) { ...@@ -103,18 +103,29 @@ function goto(id) {
* @param {int} group_index index of group in groups array * @param {int} group_index index of group in groups array
*/ */
function group_goto(group_index) { function group_goto(group_index) {
let missing_orders = [];
// Make sure a couchdb document exists for all group's orders // Make sure a couchdb document exists for all group's orders
for (let i in order_groups.groups[group_index]) { for (let i in order_groups.groups[group_index]) {
let order_data = null; let order_data = null;
let order_id = order_groups.groups[group_index][i];
// Find order data // Find order data
for (let order of orders) { for (let order of orders) {
if (order.id == order_groups.groups[group_index][i]) { if (order.id == order_id) {
order_data = order; order_data = order;
} }
} }
create_order_doc(order_data); if (order_data != null) {
create_order_doc(order_data);
} else {
missing_orders.push(order_id);
}
}
if (missing_orders.length > 0) {
// TODO what to do when orders are missing from group?
} }
// go to first order // go to first order
...@@ -212,7 +223,7 @@ function validatePrices() { ...@@ -212,7 +223,7 @@ function validatePrices() {
var updates = { var updates = {
'group_amount_total' : order['amount_total'], 'group_amount_total' : order['amount_total'],
'update_type' : 'br_vaid', 'update_type' : 'br_valid',
'updated_products' : [], 'updated_products' : [],
'user_comments': "", 'user_comments': "",
'orders' : [order] 'orders' : [order]
...@@ -285,7 +296,10 @@ function group_action() { ...@@ -285,7 +296,10 @@ function group_action() {
* Remove the grouped orders from the order table to prevent grouping in multiple groups. * Remove the grouped orders from the order table to prevent grouping in multiple groups.
*/ */
function display_grouped_orders() { function display_grouped_orders() {
if (table_orders !== null) { if (table_orders !== null) {
var display_something = false;
$('#groups_items').empty(); $('#groups_items').empty();
let groups_display_content = "<ul>"; let groups_display_content = "<ul>";
...@@ -308,33 +322,38 @@ function display_grouped_orders() { ...@@ -308,33 +322,38 @@ function display_grouped_orders() {
} }
} }
// Display group if (group_orders.length > 0) {
document.getElementById("container_groups").hidden = false; // Display group
let group_row = `<li class="group_line"> Commandes de `; display_something = true;
document.getElementById("container_groups").hidden = false;
let group_row = `<li class="group_line"> Commandes de `;
for (let i in group_orders) {
if (i == group_orders.length-1) { // last element of list
group_row += "<b>" + group_orders[i].partner + "</b> du " + group_orders[i].date_order + " : ";
} else {
group_row += "<b>" + group_orders[i].partner + "</b> du " + group_orders[i].date_order + ", ";
}
}
for (let i in group_orders) { if (group_orders[0].reception_status == 'False') {
if (i == group_orders.length-1) { // last element of list group_row += "<button class='btn--primary' onClick='group_goto("
group_row += "<b>" + group_orders[i].partner + "</b> du " + group_orders[i].date_order + " : "; + group_index
+ ")'>Compter les produits</button>";
} else { } else {
group_row += "<b>" + group_orders[i].partner + "</b> du " + group_orders[i].date_order + ", "; group_row += "<button class='btn--success' onClick='group_goto("
+ group_index
+ ")'>Mettre à jour les prix</button>";
} }
}
if (group_orders[0].reception_status == 'False') { group_row += "</li>";
group_row += "<button class='btn--primary' onClick='group_goto(" groups_display_content += group_row;
+ group_index
+ ")'>Compter les produits</button>";
} else {
group_row += "<button class='btn--success' onClick='group_goto("
+ group_index
+ ")'>Mettre à jour les prix</button>";
} }
group_row += "</li>";
groups_display_content += group_row;
} }
$('#container_groups').show(); if (display_something === true) {
$('#groups_items').append(groups_display_content); $('#container_groups').show();
$('#groups_items').append(groups_display_content);
}
} }
} }
...@@ -346,7 +365,9 @@ function display_orders_table() { ...@@ -346,7 +365,9 @@ function display_orders_table() {
table_orders.clear().destroy(); table_orders.clear().destroy();
$('#orders').empty(); $('#orders').empty();
} }
for (let j in orders) {
console.log(orders[j].id);
}
table_orders = $('#orders').DataTable({ table_orders = $('#orders').DataTable({
data: orders, data: orders,
columns:[ columns:[
......
...@@ -84,10 +84,10 @@ function select_product_from_bc(barcode) { ...@@ -84,10 +84,10 @@ function select_product_from_bc(barcode) {
} }
}); });
if (found.data != null) { if (found.data == null) {
$.each(list_processed, function(i, e) { $.each(list_processed, function(i, e) {
if (e.product_id[0] == p.data[barcodes['keys']['id']]) { if (e.product_id[0] == p.data[barcodes['keys']['id']]) {
found.data = e; found.data = JSON.parse(JSON.stringify(e));
found.place = 'processed'; found.place = 'processed';
} }
}); });
...@@ -99,10 +99,6 @@ function select_product_from_bc(barcode) { ...@@ -99,10 +99,6 @@ function select_product_from_bc(barcode) {
let row = table_to_process.row($('#'+found.data.product_id[0])); let row = table_to_process.row($('#'+found.data.product_id[0]));
remove_from_toProcess(row, found.data); remove_from_toProcess(row, found.data);
} else {
let row = table_processed.row($('#'+found.data.product_id[0]));
remove_from_processed(row, found.data);
} }
} }
} }
...@@ -862,12 +858,20 @@ function editProductInfo (productToEdit, value = null, batch = false) { ...@@ -862,12 +858,20 @@ function editProductInfo (productToEdit, value = null, batch = false) {
var index = searchUpdatedProduct(); var index = searchUpdatedProduct();
var firstUpdate = false; var firstUpdate = false;
let newValue = value; let newValue = value;
var addition = false;
// If 'value' parameter not set, get value from edition input // If 'value' parameter not set, get value from edition input
if (value == null) { if (value == null) {
newValue = parseFloat(document.getElementById('edition_input').value.replace(',', '.')); newValue = parseFloat(document.getElementById('edition_input').value.replace(',', '.'));
} }
$.each(list_processed, function(i, e) {
if (e.product_id[0] == productToEdit.product_id[0]) {
addition = true;
productToEdit = e;
newValue = newValue + productToEdit.product_qty;
}
});
// If qty edition & Check if qty changed // If qty edition & Check if qty changed
if (reception_status == "False" && productToEdit.product_qty != newValue) { if (reception_status == "False" && productToEdit.product_qty != newValue) {
if (index == -1) { // First update if (index == -1) { // First update
...@@ -944,6 +948,12 @@ function editProductInfo (productToEdit, value = null, batch = false) { ...@@ -944,6 +948,12 @@ function editProductInfo (productToEdit, value = null, batch = false) {
update_distant_order(productToEdit.id_po); update_distant_order(productToEdit.id_po);
} }
if (addition) {
let row = table_processed.row($('#'+productToEdit.product_id[0]));
remove_from_processed(row, productToEdit);
}
add_to_processed(productToEdit); add_to_processed(productToEdit);
} catch (e) { } catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'edit product info'}; err = {msg: e.name + ' : ' + e.message, ctx: 'edit product info'};
...@@ -1206,6 +1216,39 @@ function send() { ...@@ -1206,6 +1216,39 @@ function send() {
error_report_data.orders.push(orders[i]); error_report_data.orders.push(orders[i]);
} }
//Create list of articl with no barcode
no_barcode_list = [];
for (var i = 0; i < list_processed.length; i++) {
if (list_processed[i].product_qty != 0 && (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "")) {
no_barcode_list.push([
list_processed[i]["product_id"][0],
list_processed[i]["product_id"][1]
]);
}
}
data_send_no_barcode={
"order" : orders[order_data['id_po']],
"no_barcode_list" : no_barcode_list
};
// Send of articl with no barcode to mail send
if (no_barcode_list.length > 0) {
$.ajax({
type: "POST",
url: "../send_mail_no_barcode",
dataType: "json",
traditional: true,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data_send_no_barcode),
success: function() {},
error: function() {
alert('Erreur dans l\'envoi des produite sont barre code.');
}
});
}
// Send request for error report // Send request for error report
$.ajax({ $.ajax({
type: "POST", type: "POST",
...@@ -1248,7 +1291,7 @@ function send() { ...@@ -1248,7 +1291,7 @@ function send() {
document.getElementById("nothingToDo").hidden = true; document.getElementById("nothingToDo").hidden = true;
barcodes_to_print = true; barcodes_to_print = true;
} else if (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "") { } /* else if (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "") {
// Products with no barcode // Products with no barcode
var node = document.createElement('li'); var node = document.createElement('li');
let textNode = document.createTextNode(list_processed[i]["product_id"][1]); let textNode = document.createTextNode(list_processed[i]["product_id"][1]);
...@@ -1260,7 +1303,20 @@ function send() { ...@@ -1260,7 +1303,20 @@ function send() {
document.getElementById("barcodesEmpty").hidden = false; document.getElementById("barcodesEmpty").hidden = false;
document.getElementById("nothingToDo").hidden = true; document.getElementById("nothingToDo").hidden = true;
} }
} }*/
}
}
for (let i = 0; i < no_barcode_list.length; i++) {
var node = document.createElement('li');
let textNode = document.createTextNode(no_barcode_list[i]);
node.appendChild(textNode);
document.getElementById('barcodesEmpty_list').appendChild(node);
if (document.getElementById("barcodesEmpty").hidden) {
document.getElementById("barcodesEmpty").hidden = false;
document.getElementById("nothingToDo").hidden = true;
} }
} }
......
...@@ -16,5 +16,6 @@ urlpatterns = [ ...@@ -16,5 +16,6 @@ urlpatterns = [
url(r'^reception_qtiesValidated', views.reception_qtiesValidated), url(r'^reception_qtiesValidated', views.reception_qtiesValidated),
url(r'^reception_pricesValidated', views.reception_pricesValidated), url(r'^reception_pricesValidated', views.reception_pricesValidated),
# url(r'^update_order_status/([0-9]+)$', views.tmp_update_order_status), # url(r'^update_order_status/([0-9]+)$', views.tmp_update_order_status),
url(r'^po_process_picking$', views.po_process_picking) url(r'^po_process_picking$', views.po_process_picking),
url(r'^send_mail_no_barcode', views.send_mail_no_barcode)
] ]
...@@ -162,7 +162,6 @@ function init_datatable() { ...@@ -162,7 +162,6 @@ function init_datatable() {
// Listener on inputs // Listener on inputs
$('#products_table tbody').on('change', '.stock_edit_input', function () { $('#products_table tbody').on('change', '.stock_edit_input', function () {
let qty = $(this).val(); let qty = $(this).val();
let row = products_table.row($(this).parents('tr')); let row = products_table.row($(this).parents('tr'));
let data = row.data(); let data = row.data();
...@@ -172,24 +171,7 @@ function init_datatable() { ...@@ -172,24 +171,7 @@ function init_datatable() {
data.qty = validated_data; data.qty = validated_data;
row.remove().draw(); row.remove().draw();
products_table.row.add(data).draw(); products_table.row.add(data).draw();
} else {
data.qty = null;
row.remove().draw();
products_table.row.add(data).draw();
if (validated_data == -2) {
$.notify("Ce produit est vendu à l'unité : la valeur doit être un nombre entier !", {
globalPosition:"top right",
className: "error"
});
} else if (validated_data == -1 || validated_data == -3) {
$.notify("Valeur invalide.", {
globalPosition:"top right",
className: "error"
});
}
} }
update_total_value(); update_total_value();
}); });
...@@ -441,20 +423,34 @@ var update_existing_product = function(product, added_qty, undo_option = false) ...@@ -441,20 +423,34 @@ var update_existing_product = function(product, added_qty, undo_option = false)
*/ */
function qty_validation(qty, uom_id) { function qty_validation(qty, uom_id) {
if (qty == null || qty == '') { if (qty == null || qty == '') {
$.notify("Il n'y a pas de quantité indiquée, ou ce n'est pas un nombre", {
globalPosition:"top right",
className: "error"});
return -1; return -1;
} }
if (uom_id == 1) { if (uom_id == 1) {
if (qty/parseInt(qty) != 1 && qty != 0) if (qty/parseInt(qty) != 1 && qty != 0) {
$.notify("Une quantité avec décimale est indiquée alors que c'est un article à l'unité", {
globalPosition:"top right",
className: "error"});
return -2; return -2;
}
qty = parseInt(qty); // product by unit qty = parseInt(qty); // product by unit
} else { } else {
qty = parseFloat(qty).toFixed(2); qty = parseFloat(qty).toFixed(2);
} }
if (isNaN(qty)) if (isNaN(qty)) {
$.notify("Une quantité n'est pas un nombre", {
globalPosition:"top right",
className: "error"});
return -3; return -3;
}
return qty; return qty;
} }
......
...@@ -137,13 +137,16 @@ ...@@ -137,13 +137,16 @@
<div class="col-1"></div> <div class="col-1"></div>
<div class="col-4"> <div class="col-4">
<h1 class="col-4 txtcenter">Qui es-tu ?</h1> <h1 class="col-4 txtcenter">Qui es-tu ?</h1>
<section class="outside_list"> {% if extra_btns_display %}
<a class="btn b_orange" data-next="rattrapage_1" data-type="rattrapage">Je viens faire un rattrapage</a> <section class="outside_list">
{% if ftop_btn_display %} <a class="btn b_orange" data-next="rattrapage_1" data-type="rattrapage">Je viens faire un rattrapage</a>
<a class="btn b_yellow" data-next="rattrapage_1" data-type="volant">Je suis volant</a> {% if ftop_btn_display %}
<a class="btn b_yellow" data-next="rattrapage_1" data-type="volant">Je suis volant</a>
{% endif %}
</section>
{% endif %} {% endif %}
</section>
</div> </div>
<div class="col-1"></div> <div class="col-1"></div>
<div class="col-1"></div> <div class="col-1"></div>
<section id="service_en_cours" class="col-4"> <section id="service_en_cours" class="col-4">
...@@ -153,6 +156,12 @@ ...@@ -153,6 +156,12 @@
<div id="current_shift_members"> <div id="current_shift_members">
</div> </div>
{% if easy_shift_validate %}
<div class="easy_shift_validate">
<p>{{ENTRANCE_EASY_SHIFT_VALIDATE_MSG|safe}}</p>
{% include "members/member_selection.html" %}
</div>
{% endif %}
</section> </section>
</section> </section>
...@@ -227,6 +236,9 @@ ...@@ -227,6 +236,9 @@
<input type="text" placeholder="crop_height" id="img_crop_height" /><br /> <input type="text" placeholder="crop_height" id="img_crop_height" /><br />
<button type="button" id="init_webcam">Cam</button> <button type="button" id="init_webcam">Cam</button>
</section> </section>
<div style="display:none;">
<p id="missed_begin_msg">{{ENTRANCE_MISSED_SHIFT_BEGIN_MSG|safe}}</p>
</div>
<script src="{% static "js/all_common.js" %}?v="></script> <script src="{% static "js/all_common.js" %}?v="></script>
<script src="{% static "js/members.js" %}?v="></script> <script src="{% static "js/members.js" %}?v="></script>
{% endblock %} {% endblock %}
<form id="sm_search_member_form" action="javascript:;" method="post">
<input type="text" id="sm_search_member_input" value="" placeholder="Votre nom ou numéro..." required>
<button type="submit" class="btn--primary" id="sm_search_member_button">Recherche</button>
</form>
<div class="search_member_results_area" style="display:none;">
<div>
<p>Vous êtes (cliquez sur votre nom) :</p>
</div>
<div class="search_member_results"></div>
</div>
\ No newline at end of file
...@@ -16,14 +16,20 @@ ...@@ -16,14 +16,20 @@
{% block content %} {% block content %}
<div class="page_body"> <div class="page_body">
<div id="select_order_content" class="page_content txtcenter"> <div id="select_order_content" class="page_content txtcenter">
<div class="login_area">
{% include "common/conn_admin.html" %}
</div>
<div id="new_order_area"> <div id="new_order_area">
<h2>Créer une nouvelle commande</h2> <h2>Créer une nouvelle commande</h2>
<form id="new_order_form"> <div class="txtcenter" id="not_connected_content" style="display:none;">
<p>Vous devez vous connecter avec un compte Odoo pour accéder au module d'aide à la commande.</p>
</div>
<form id="new_order_form" style="display:none;">
<input type="text" id="new_order_name" placeholder="Nom de la commande..."> <input type="text" id="new_order_name" placeholder="Nom de la commande...">
<button type="submit" class="btn btn--primary">Valider</button> <button type="submit" class="btn btn--primary">C'est parti !</button>
</form> </form>
</div> </div>
<div id="existing_orders_area"> <div id="existing_orders_area" style="display:none;">
<h2>Ou, continuer une commande en cours de création</h2> <h2>Ou, continuer une commande en cours de création</h2>
<div id="existing_orders"></div> <div id="existing_orders"></div>
</div> </div>
...@@ -34,9 +40,30 @@ ...@@ -34,9 +40,30 @@
<button type="button" class="btn--danger" id="back_to_order_selection_from_main"> <button type="button" class="btn--danger" id="back_to_order_selection_from_main">
<i class="fas fa-arrow-left"></i>&nbsp; Retour <i class="fas fa-arrow-left"></i>&nbsp; Retour
</button> </button>
<button type="button" class='btn--primary' id="do_inventory" style="display:none;"> <div class="right_action_buttons">
Faire un inventaire
</button> <div id="actions_buttons_wrapper">
<button type="button" class='btn--primary' id="toggle_action_buttons">
<span class="button_content">
Actions
</span>
<span class="toggle_action_buttons_icon">
<i class="fas fa-chevron-down"></i>
</span>
</button>
<div id="actions_buttons_container">
<button type="button" class='btn--primary action_button' id="do_inventory" style="display:none;">
Faire un inventaire
</button>
<button type="button" class='btn--danger action_button' id="delete_order_button">
Supprimer la commande
</button>
</div>
</div>
<a class='btn--warning link_as_button' id="access_metabase" style="display:none;" href="{{metabase_url}}" target="_blank">
Stats Métabase
</a>
</div>
</div> </div>
<div class="header txtcenter"> <div class="header txtcenter">
...@@ -49,14 +76,23 @@ ...@@ -49,14 +76,23 @@
</div> </div>
<div class="txtcenter" id="order_forms_container"> <div class="txtcenter" id="order_forms_container">
<form action="javascript:;" id="coverage_form"> <form action="javascript:;" id="supplier_form" class="order_form_item">
<input type="number" name="coverage_days" id="coverage_days_input" placeholder="Nb jours de couverture" min="1">
<button type="submit" class='btn--primary'>Calculer les besoins</button>
</form>
<form action="javascript:;" id="supplier_form">
<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>
<form action="javascript:;" id="stats_date_from_form" class="order_form_item">
<label for="stats_date_period_select">Période de calcul de la conso moyenne </label>
<select name="stats_date_period_select" id="stats_date_period_select">
<option value="">Par défaut</option>
<option value="1week">1 semaine</option>
<option value="2weeks">2 semaines</option>
</select>
</form>
<form action="javascript:;" id="coverage_form" class="order_form_item">
<input type="number" name="coverage_days" id="coverage_days_input" placeholder="Nb jours de couverture" min="1">
<button type="submit" class='btn--primary'>Calculer les besoins</button>
</form>
</div> </div>
<div id="suppliers_container"></div> <div id="suppliers_container"></div>
...@@ -117,8 +153,14 @@ ...@@ -117,8 +153,14 @@
<span class="pill_supplier_name"></span> <span class="pill_supplier_name"></span>
<i class="fas fa-times remove_supplier_icon"></i> <i class="fas fa-times remove_supplier_icon"></i>
</div> </div>
<div class="supplier_total_value_container"> <div class="supplier_data">
Total: <span class="supplier_total_value">0</span> <div class="supplier_total_value_container">
Total : <span class="supplier_total_value">0</span>
</div>
&nbsp;&nbsp;|&nbsp;&nbsp;
<div class="supplier_total_packages_container">
Nb colis : <span class="supplier_total_packages">0</span>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -126,6 +168,7 @@ ...@@ -126,6 +168,7 @@
<div id="order_pill_template"> <div id="order_pill_template">
<div class="pill order_pill btn btn--primary"> <div class="pill order_pill btn btn--primary">
<span class="pill_order_name"></span> <span class="pill_order_name"></span>
<i class="fas fa-times remove_order_icon"></i>
</div> </div>
</div> </div>
...@@ -136,7 +179,7 @@ ...@@ -136,7 +179,7 @@
<h4 class="new_order_date_planned"></h4> <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 link_as_button' style="display:none;" href="#">
Télécharger le fichier de commande Télécharger le fichier de commande
</a> </a>
</div> </div>
...@@ -156,6 +199,15 @@ ...@@ -156,6 +199,15 @@
<p>Voulez-vous quand même y accéder ?</p> <p>Voulez-vous quand même y accéder ?</p>
<hr/> <hr/>
</div> </div>
<div id="modal_remove_order">
<h3>Attention !</h3>
<p class="remove_order_modal_text">
Vous vous apprêtez à <b style="color: #d9534f;">supprimer</b> 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"> <div id="modal_remove_supplier">
<h3>Attention !</h3> <h3>Attention !</h3>
...@@ -193,6 +245,19 @@ ...@@ -193,6 +245,19 @@
<p>Êtez-vous sûr ?</p> <p>Êtez-vous sûr ?</p>
<hr/> <hr/>
</div> </div>
<div id="modal_end_supplier_product_association">
<h3>Attention !</h3>
<p>
Vous vous apprêtez à rendre le produit <span class="product_name"></span>
indisponible chez le fournisseur <span class="supplier_name"></span>.
</p>
<p>
L'association sera supprimée dès que vous aurez cliqué sur "Valider".<br/>
</p>
<p>Êtez-vous sûr ?</p>
<hr/>
</div>
<div id="modal_create_inventory"> <div id="modal_create_inventory">
<p> <p>
...@@ -244,6 +309,7 @@ ...@@ -244,6 +309,7 @@
var couchdb_dbname = '{{db}}'; var couchdb_dbname = '{{db}}';
var couchdb_server = '{{couchdb_server}}' + couchdb_dbname; var couchdb_server = '{{couchdb_server}}' + couchdb_dbname;
var odoo_server = '{{odoo_server}}'; var odoo_server = '{{odoo_server}}';
var metabase_url = '{{metabase_url}}';
</script> </script>
<script src="{% static "js/all_common.js" %}?v="></script> <script src="{% static "js/all_common.js" %}?v="></script>
<script type="text/javascript" src="{% static 'js/orders_helper.js' %}?v="></script> <script type="text/javascript" src="{% static 'js/orders_helper.js' %}?v="></script>
......
...@@ -83,16 +83,7 @@ ...@@ -83,16 +83,7 @@
<hr /> <hr />
<section class="set_member_to_movement"> <section class="set_member_to_movement">
<p>Avant de valider l'opération, merci de nous dire qui vous êtes :</p> <p>Avant de valider l'opération, merci de nous dire qui vous êtes :</p>
<form id="sm_search_member_form" action="javascript:;" method="post"> {% include "members/member_selection.html" %}
<input type="text" id="sm_search_member_input" value="" placeholder="Votre nom ou numéro..." required>
<button type="submit" class="btn--primary" id="sm_search_member_button">Recherche</button>
</form>
<div class="search_member_results_area" style="display:none;">
<div>
<p>Vous êtes (cliquez sur votre nom) :</p>
</div>
<div class="search_member_results"></div>
</div>
</section> </section>
<hr /> <hr />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment