Commit 8a14e906 by François C.

Add change product shelf function

parent 7dfcbf2f
Pipeline #2188 passed with stage
in 1 minute 32 seconds
...@@ -505,10 +505,13 @@ class Shelf(models.Model): ...@@ -505,10 +505,13 @@ class Shelf(models.Model):
class Shelfs(models.Model): class Shelfs(models.Model):
def get_all(): def get_all(precision='full'):
res = [] res = []
try: try:
api = OdooAPI() api = OdooAPI()
if precision == 'simple':
res = api.search_read('product.shelfs', [], ['name', 'sort_order'], order='sort_order asc')
else:
res = api.execute('product.shelfs', 'get', {}) res = api.execute('product.shelfs', 'get', {})
except Exception as e: except Exception as e:
coop_logger.error("Rayons, get_all : %s", str(e)) coop_logger.error("Rayons, get_all : %s", str(e))
...@@ -529,3 +532,18 @@ class Shelfs(models.Model): ...@@ -529,3 +532,18 @@ class Shelfs(models.Model):
except Exception as e: except Exception as e:
coop_logger.error("Rayons, get_shelfs_sortorder : %s", str(e)) coop_logger.error("Rayons, get_shelfs_sortorder : %s", str(e))
return res return res
@staticmethod
def make_products_shelf_links(data):
res = {}
try:
api = OdooAPI()
res['done'] = []
for elt in data:
f = {'shelf_id': elt['shelf_id']}
if api.update('product.product', [elt['product_id']], f):
res['done'].append(elt['product_id'])
except Exception as e:
res['error'] = str(e)
coop_logger.error("Rayons, make_products_shelf_links : %s", str(e))
return res
\ No newline at end of file
...@@ -139,6 +139,13 @@ table.dataTable { ...@@ -139,6 +139,13 @@ table.dataTable {
padding: 5px; padding: 5px;
} }
#header_container_left {
float: left;
}
#change_shelf_btn {
float: right;
}
div#container_edition { div#container_edition {
padding: 8px; padding: 8px;
background-color: #e7e9ed; background-color: #e7e9ed;
...@@ -288,3 +295,8 @@ hr { ...@@ -288,3 +295,8 @@ hr {
opacity: 1; opacity: 1;
} }
/* Change shelf modal */
.shelf_selection {
max-width: 240px;
}
...@@ -9,8 +9,9 @@ urlpatterns = [ ...@@ -9,8 +9,9 @@ urlpatterns = [
url(r'^shelf_view/([0-9]+)$', views.shelf_view), url(r'^shelf_view/([0-9]+)$', views.shelf_view),
url(r'^shelf_inventory/([0-9]+)$', views.shelf_inventory), url(r'^shelf_inventory/([0-9]+)$', views.shelf_inventory),
url(r'^inventory_process_state/([0-9]+)$', views.inventory_process_state), url(r'^inventory_process_state/([0-9]+)$', views.inventory_process_state),
url(r'^all$', views.all), url(r'^all/?([a-z]*)$', views.all),
url(r'^get_shelves_extra_data$', views.get_shelves_extra_data), url(r'^get_shelves_extra_data$', views.get_shelves_extra_data),
url(r'^change_products_shelfs$', views.change_products_shelfs),
url(r'^(?P<shelf_id>\d+)$', views.shelf_data), url(r'^(?P<shelf_id>\d+)$', views.shelf_data),
url(r'^(?P<shelf_id>\d+)/products$', views.products), url(r'^(?P<shelf_id>\d+)/products$', views.products),
url(r'^(?P<shelf_id>\d+)/add_product$', views.add_product), url(r'^(?P<shelf_id>\d+)/add_product$', views.add_product),
......
...@@ -71,9 +71,9 @@ def set_begin_inventory_datetime(request, shelf_id): ...@@ -71,9 +71,9 @@ def set_begin_inventory_datetime(request, shelf_id):
return JsonResponse({'res': res}) return JsonResponse({'res': res})
def all(request): def all(request, precision):
"""Get all shelves data""" """Get all shelves data"""
return JsonResponse({'res': Shelfs.get_all()}) return JsonResponse({'res': Shelfs.get_all(precision)})
def get_shelves_extra_data(request): def get_shelves_extra_data(request):
"""Get data that need calculation, so long execution time""" """Get data that need calculation, so long execution time"""
...@@ -130,6 +130,19 @@ def inventory_process_state(request, shelf_id): ...@@ -130,6 +130,19 @@ def inventory_process_state(request, shelf_id):
else: else:
return JsonResponse({'res': res}) return JsonResponse({'res': res})
def change_products_shelfs(request):
res = {}
try:
data = json.loads(request.body.decode())
res = Shelfs.make_products_shelf_links(data)
except Exception as e:
res['error'] = str(e)
coop_logger.error("change_products_shelfs : %s", str(e))
if 'error' in res:
return JsonResponse(res, status=500)
else:
return JsonResponse({'res': res})
def do_shelf_inventory(request): def do_shelf_inventory(request):
"""Process shelf inventory""" """Process shelf inventory"""
""" """
......
...@@ -91,6 +91,9 @@ ...@@ -91,6 +91,9 @@
<div class="container_products" id="container_left"> <div class="container_products" id="container_left">
<h4 id="header_container_left">Produits à compter</h4> <h4 id="header_container_left">Produits à compter</h4>
<button style="display:none;" id="change_shelf_btn" class="btn btn--primary">
Changer de rayon
</button>
<table id="table_to_process" class="display" cellspacing="0"></table> <table id="table_to_process" class="display" cellspacing="0"></table>
</div> </div>
<div class="container_products" id="container_right"> <div class="container_products" id="container_right">
...@@ -167,6 +170,19 @@ ...@@ -167,6 +170,19 @@
<input autocomplete="off" type="text" placeholder="Code barre du produit" class="add_product_input"> <input autocomplete="off" type="text" placeholder="Code barre du produit" class="add_product_input">
<hr /> <hr />
</div> </div>
<div id="change_shelf_form">
<h3>Changement de rayons</h3>
<hr />
<table>
<thead>
<tr>
<th>Produit</th>
<th>Rayon</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
......
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