Commit f2dff3c8 by François C.

Merge branch '7747-inventaire-par-article' into 'migration-v12'

several changes in inventaire par article app

See merge request !284
parents 6963f5a9 2123aa7b
Pipeline #4185 canceled with stage
...@@ -1918,9 +1918,19 @@ function display_products(params) { ...@@ -1918,9 +1918,19 @@ function display_products(params) {
cell.addClass('product_ref_cell'); cell.addClass('product_ref_cell');
} }
} }
} },
dom: 'lrtip', // Remove the search input from that table
});
/* In order to remove the accents in the input, we could attach a keyup event to the default
* search field generated by datatables, but then two search events would be triggered on keyup :
* the default datatable event, and ours.
* To fix this problem we create our own input search so that only our event fires.
*/
$(document).on('keyup', '#custom_products_table_filter input[type="search"]', function() {
products_table
.search(jQuery.fn.DataTable.ext.type.search.string(this.value))
.draw();
}); });
products_table.search('');
$('.main').show(); $('.main').show();
$('#main_content_footer').show(); $('#main_content_footer').show();
$('#do_inventory').show(); $('#do_inventory').show();
......
...@@ -397,6 +397,13 @@ class CagetteProducts(models.Model): ...@@ -397,6 +397,13 @@ class CagetteProducts(models.Model):
return api.search_read('product.product', cond, fields) return api.search_read('product.product', cond, fields)
@staticmethod @staticmethod
def get_all_active_products():
api = OdooAPI()
cond = [['active', '=', True]]
fields = ['id', 'uom_id', 'name', 'qty_available', 'barcode']
return api.search_read('product.product', cond, fields, limit=False)
@staticmethod
def get_vrac_products_from_cats(cats, withCandidate=False, fields=[]): def get_vrac_products_from_cats(cats, withCandidate=False, fields=[]):
api = OdooAPI() api = OdooAPI()
cond = [['active', '=', True], cond = [['active', '=', True],
......
.main, .barcode_search_area {
margin-top: 20px;
}
#barcode_selector {
border: 1px solid #555;
border-radius:15px;
}
.stock_edit_input { .stock_edit_input {
max-width: 50px; max-width: 100px;
} }
.dataTables_filter {
display: block !important; /* S'assure qu'elle est bien affichée */
}
\ No newline at end of file
...@@ -7,6 +7,7 @@ urlpatterns = [ ...@@ -7,6 +7,7 @@ urlpatterns = [
url(r'^simple_list$', views.get_simple_list), url(r'^simple_list$', views.get_simple_list),
url(r'^get_product_for_order_helper$', views.get_product_for_order_helper), url(r'^get_product_for_order_helper$', views.get_product_for_order_helper),
url(r'^get_product_data$', views.get_product_data), url(r'^get_product_data$', views.get_product_data),
url(r'^get_all_active_products$', views.get_all_active_products),
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),
......
...@@ -55,6 +55,14 @@ def get_product_for_order_helper(request): ...@@ -55,6 +55,14 @@ def get_product_for_order_helper(request):
else: else:
return JsonResponse(res, safe=False) return JsonResponse(res, safe=False)
def get_all_active_products(request):
products = CagetteProducts.get_all_active_products()
if not products:
return JsonResponse({"product": products}, status=404)
else:
return JsonResponse({"products": products})
def get_product_data(request): def get_product_data(request):
barcode = request.GET['barcode'] barcode = request.GET['barcode']
res = CagetteProduct.get_product_from_barcode(barcode) res = CagetteProduct.get_product_from_barcode(barcode)
...@@ -63,6 +71,12 @@ def get_product_data(request): ...@@ -63,6 +71,12 @@ def get_product_data(request):
return JsonResponse({"product": res}, status=404) return JsonResponse({"product": res}, status=404)
p = res[0] p = res[0]
add_shelf_sortorder(p)
return JsonResponse({"product": p})
def add_shelf_sortorder(p):
if p['shelf_id'] is not False: if p['shelf_id'] is not False:
shelfs_sortorder = Shelfs.get_shelfs_sortorder([p['shelf_id'][0]]) shelfs_sortorder = Shelfs.get_shelfs_sortorder([p['shelf_id'][0]])
...@@ -73,7 +87,6 @@ def get_product_data(request): ...@@ -73,7 +87,6 @@ def get_product_data(request):
else: else:
p['shelf_sortorder'] = 'X' p['shelf_sortorder'] = 'X'
return JsonResponse({"product": p})
def get_products_stdprices(request): def get_products_stdprices(request):
ids = json.loads(request.body.decode()) ids = json.loads(request.body.decode())
......
<div id="custom_products_table_wrapper" class="dataTables_wrapper no-footer">
<div id="custom_products_table_filter" class="dataTables_filter">
<label for="custom_product_search_input">Recherche :
<input type="search" id="custom_product_search_input" class="form-control" placeholder="" aria-controls="products_table"/>
</label>
</div>
</div>
\ No newline at end of file
...@@ -125,6 +125,7 @@ ...@@ -125,6 +125,7 @@
<div class="main" style="display:none;"> <div class="main" style="display:none;">
<div class="table_area"> <div class="table_area">
{% include "common/custom_search_input_replacing_datatable_default.html" %}
<table id="products_table" class="display" cellspacing="0" width="100%"></table> <table id="products_table" class="display" cellspacing="0" width="100%"></table>
</div> </div>
</div> </div>
......
...@@ -15,17 +15,12 @@ ...@@ -15,17 +15,12 @@
{% block content %} {% block content %}
<div class="header txtcenter"> <div class="header txtcenter">
<h1>Informations sur les produits du magasin</h1> <h1>Inventaire par produits</h1>
</div>
<div class="barcode_search_area txtcenter">
<p><i>Passez un produit sous la douchette ! Si rien ne se passe, cliquez sur le champ ci-dessous puis ré-essayez.</i></p>
<input type="text" id="barcode_selector" name="barcode_selector" placeholder="Codebarre">
<button type="button" class="btn--primary" id="button_barcode_selector" name="button">Recherche</button>
</div> </div>
<div class="main"> <div class="main">
<table id="products_table" class="display" cellspacing="0" ></table> {% include "common/custom_search_input_replacing_datatable_default.html" %}
<table id="products_table" class="display" cellspacing="0" ></table>
</div> </div>
<script src="{% static "js/all_common.js" %}?v=1651853225"></script> <script src="{% static "js/all_common.js" %}?v=1651853225"></script>
......
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