Commit c44d1805 by François C.

Order helper customize (ref interne ou fournisseur, link to odoo order at the end)

parent 7aed7ac5
Pipeline #2607 failed with stage
in 1 minute 19 seconds
......@@ -473,7 +473,7 @@
font-weight: bold;
}
.mail_example_container {
.mail_example_container, #after_order_ending_part {
display: flex;
flex-direction: column;
align-items: center;
......
......@@ -1349,6 +1349,11 @@ function create_orders() {
new_order_template.find(".download_order_file_button").attr('id', `download_attachment_${new_order.id_po}`);
$('#created_orders_area').append(new_order_template.html());
if (display_odoo_order_link == 1) {
let odoo_link = $('<a>').addClass('btn--primary').text('Accéder à la commande dans Odoo')
.attr('href', `${odoo_server}/web#id=${new_order.id_po}&view_type=form&model=purchase.order&menu_id=252&action=353`);
$('#after_order_ending_part').append(odoo_link);
}
}
// Prepare buttons to download order attachment
......@@ -1532,6 +1537,7 @@ function _compute_product_data(product) {
// Store temporarily product package qties
p_package_qties.push(p_supplierinfo.package_qty);
p_price.push(p_supplierinfo.price);
item.product_code = p_supplierinfo.product_code;
}
item.purchase_qty = purchase_qty;
......@@ -1610,7 +1616,6 @@ function prepare_datatable_data(product_ids = []) {
data.push(full_item);
}
return data;
}
......@@ -1618,24 +1623,10 @@ function prepare_datatable_data(product_ids = []) {
* @returns Array of formatted data for datatable columns setup
*/
function prepare_datatable_columns() {
let columns = [
{
data: "id",
title: `<div id="table_header_select_all" class="txtcenter">
<!--<span class="select_all_text">Sélectionner</span>-->
<label for="select_all_products_cb">Tout</label>
<input type="checkbox" class="select_product_cb" id="select_all_products_cb" name="select_all_products_cb" value="all">
</div>`,
className: "dt-body-center",
orderable: false,
render: function (data) {
return `<input type="checkbox" class="select_product_cb" id="select_product_${data}" value="${data}">`;
},
width: "4%"
},
{
const internal_ref_column = {
data: "default_code",
title: "Ref",
title: "Réf",
width: "5%",
render: function (data, type, full) {
if (data === false) {
......@@ -1651,7 +1642,24 @@ function prepare_datatable_columns() {
return data;
}
}
};
let columns = [
{
data: "id",
title: `<div id="table_header_select_all" class="txtcenter">
<!--<span class="select_all_text">Sélectionner</span>-->
<label for="select_all_products_cb">Tout</label>
<input type="checkbox" class="select_product_cb" id="select_all_products_cb" name="select_all_products_cb" value="all">
</div>`,
className: "dt-body-center",
orderable: false,
render: function (data) {
return `<input type="checkbox" class="select_product_cb" id="select_product_${data}" value="${data}">`;
},
width: "4%"
},
{
data: "name",
title: "Produit"
......@@ -1671,6 +1679,33 @@ function prepare_datatable_columns() {
];
// add Internal Ref if needed
if (product_reference == 'interne') {
columns.splice(1, 0, internal_ref_column);
}
// add Supplier Ref if needed
if (product_reference == 'fournisseur') {
columns.splice(1, 0, {
data: "product_code",
title: "Réf. F",
width: "5%",
render: function (data, type, full) {
if (data === false) {
return "";
} else if (data.includes("[input]")) {
let val = data.replace("[input]", "");
return `<div class="custom_cell_content">
<input type="text" class="product_supplier_ref_input" id="${full.id}_ref_input" value="${val}">
</div>`;
} else {
return data;
}
}
});
}
let conso = {
data: "daily_conso",
title: "Conso moy /jour",
......
......@@ -25,7 +25,9 @@ def helper(request):
'nb_past_days_to_compute_sales_average': OdooAPI().get_system_param('lacagette_products.nb_past_days_to_compute_sales_average'),
'nb_of_consecutive_non_sale_days_considered_as_break': OdooAPI().get_system_param('lacagette_products.nb_of_consecutive_non_sale_days_considered_as_break'),
'consumption_average_unit': getattr(settings, 'CONSUMPTION_AVERAGE_UNIT', 'day'),
'open_days_per_week': getattr(settings, 'OPEN_DAYS_PER_WEEK', 6)
'open_days_per_week': getattr(settings, 'OPEN_DAYS_PER_WEEK', 6),
'product_reference': getattr(settings, 'ORDERS_HELPER_PRODUCT_REF', 'interne'),
'display_odoo_order_link': getattr(settings, 'ORDERS_HELPER_DISPLAY_ORDER_LINK', 0)
}
template = loader.get_template('orders/helper.html')
......
......@@ -439,6 +439,14 @@
'day' is default. All consumption figures are qty/day. This parameter is for display only.
- ORDERS_HELPER_PRODUCT_REF = 'fournisseur'
By default = 'interne'
- ORDERS_HELPER_DISPLAY_ORDER_LINK = 1
By default = 0
### New members space
- USE_NEW_MEMBERS_SPACE = True
......
<div id="after_order_ending_part"> </div>
\ No newline at end of file
......@@ -148,19 +148,11 @@
</div>
<div id="created_orders_area"></div>
<br/><br/><hr/><br/>
<div class="mail_example_container">
<p class="mail_type_text">Mail type :</p>
<div class="mail_example">
Objet : Cde Cagette JJ/MM<br/>
<br/>
Bonjour XXXXXXX,<br/>
<br/>
Voici la commande de La Cagette pour le XX/XX/XX.<br/>
<br/>
Merci d'avance,<br/>
Bonne journée
</div>
</div>
{% if company_code == "lacagette" %}
{% include "orders/mail_type_cagette.html" %}
{% else %}
{% include "orders/default_ending_part.html" %}
{% endif%}
</div>
<div id="templates" style="display:none;">
......@@ -197,7 +189,7 @@
<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 link_as_button' style="display:none;" href="#">
Télécharger le fichier de commande
Télécharger le fichier Excel de commande
</a>
</div>
</div>
......@@ -371,6 +363,8 @@
var metabase_url = '{{metabase_url}}';
let consumption_average_unit = '{{consumption_average_unit}}';
let open_days_per_week = {{open_days_per_week}};
const product_reference = '{{product_reference}}';
const display_odoo_order_link = {{display_odoo_order_link}};
</script>
<script src="{% static "js/all_common.js" %}?v=1671550230"></script>
<script type="text/javascript" src="{% static 'js/orders_helper.js' %}?v=1671550230"></script>
......
<div class="mail_example_container">
<p class="mail_type_text">Mail type :</p>
<div class="mail_example">
Objet : Cde Cagette JJ/MM<br/>
<br/>
Bonjour XXXXXXX,<br/>
<br/>
Voici la commande de La Cagette pour le XX/XX/XX.<br/>
<br/>
Merci d'avance,<br/>
Bonne journée
</div>
</div>
\ No newline at end of file
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