Commit 191b57a5 by Damien Moulard

Merge branch 'aide_a_la_commande' into dev_cooperatic

parents 32fe6120 e94b0ad6
Pipeline #1147 passed with stage
in 1 minute 20 seconds
...@@ -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;
...@@ -154,6 +154,10 @@ ...@@ -154,6 +154,10 @@
cursor: pointer; cursor: pointer;
} }
.product_not_from_supplier:hover {
background-color: #c7cace;
}
.product_name, .supplier_name, .product_npa { .product_name, .supplier_name, .product_npa {
font-weight: bold; font-weight: bold;
} }
......
...@@ -187,7 +187,7 @@ function check_products_data() { ...@@ -187,7 +187,7 @@ function check_products_data() {
"Vérfication des informations produits...", "Vérfication des informations produits...",
{ {
globalPosition:"top left", globalPosition:"top left",
className: "warning" className: "info"
} }
); );
...@@ -823,6 +823,8 @@ function create_orders() { ...@@ -823,6 +823,8 @@ 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) => {
$('#created_orders_area').empty();
// 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;
...@@ -1037,12 +1039,11 @@ function _compute_product_data(product) { ...@@ -1037,12 +1039,11 @@ function _compute_product_data(product) {
let days_covered = 0; let days_covered = 0;
if (product.daily_conso !== 0) { if (product.daily_conso !== 0) {
qty_not_covered = product.daily_conso * order_doc.coverage_days - product.qty_available - product.incoming_qty - purchase_qty; qty_not_covered = product.daily_conso * order_doc.coverage_days - product.qty_available - product.incoming_qty - purchase_qty;
days_covered = qty_not_covered / product.daily_conso;
qty_not_covered = -Math.ceil(qty_not_covered); // round up, so if a value is not fully covered display it qty_not_covered = -Math.ceil(qty_not_covered); // round up, so if a value is not fully covered display it
qty_not_covered = (qty_not_covered > 0) ? 0 : qty_not_covered; // only display qty not covered (neg value) qty_not_covered = (qty_not_covered > 0) ? 0 : qty_not_covered; // only display qty not covered (neg value)
days_covered = -Math.ceil(days_covered); days_covered = (product.qty_available + product.incoming_qty + purchase_qty) / product.daily_conso;
days_covered = Math.floor(days_covered);
} }
item.qty_not_covered = qty_not_covered; item.qty_not_covered = qty_not_covered;
...@@ -1469,7 +1470,7 @@ function display_total_values() { ...@@ -1469,7 +1470,7 @@ function display_total_values() {
let order_total_value = 0; let order_total_value = 0;
for (let supplier of selected_suppliers) { for (let supplier of selected_suppliers) {
$(`#pill_supplier_${supplier.id}`).find('.supplier_total_value').text(supplier.total_value); $(`#pill_supplier_${supplier.id}`).find('.supplier_total_value').text(parseFloat(supplier.total_value).toFixed(2));
order_total_value += supplier.total_value; order_total_value += supplier.total_value;
} }
...@@ -1637,6 +1638,10 @@ function init_pouchdb_sync() { ...@@ -1637,6 +1638,10 @@ function init_pouchdb_sync() {
$(document).ready(function() { $(document).ready(function() {
if (coop_is_connected()) {
$('#new_order_form').show();
$('#existing_orders_area').show();
fingerprint = new Fingerprint({canvas: true}).get(); fingerprint = new Fingerprint({canvas: true}).get();
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
...@@ -1876,4 +1881,7 @@ $(document).ready(function() { ...@@ -1876,4 +1881,7 @@ $(document).ready(function() {
alert('Erreur lors de la récupération des articles, rechargez la page plus tard'); alert('Erreur lors de la récupération des articles, rechargez la page plus tard');
} }
}); });
} else {
$('#not_connected_content').show();
}
}); });
...@@ -148,7 +148,8 @@ class CagetteProduct(models.Model): ...@@ -148,7 +148,8 @@ class CagetteProduct(models.Model):
'product_purchase_ok': product["purchase_ok"], 'product_purchase_ok': product["purchase_ok"],
'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) res = api.create('product.supplierinfo', f)
...@@ -503,8 +504,8 @@ class CagetteProducts(models.Model): ...@@ -503,8 +504,8 @@ class CagetteProducts(models.Model):
sales_average_params = { sales_average_params = {
'ids': ptids, 'ids': ptids,
# 'from': '2019-04-10', 'from': '2019-04-10',
# 'to': '2019-08-10', 'to': '2019-08-10',
} }
sales = CagetteProducts.get_template_products_sales_average(sales_average_params) sales = CagetteProducts.get_template_products_sales_average(sales_average_params)
......
...@@ -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,10 +40,12 @@ ...@@ -34,10 +40,12 @@
<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>
<div class="rights_buttons">
<button type="button" class='btn--primary' id="do_inventory" style="display:none;"> <button type="button" class='btn--primary' id="do_inventory" style="display:none;">
Faire un inventaire Faire un inventaire
</button> </button>
</div> </div>
</div>
<div class="header txtcenter"> <div class="header txtcenter">
<h1>Aide à la commande</h1> <h1>Aide à la commande</h1>
......
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