Commit 83db0aad by François C.

Merge branch 'dev_cooperatic' into '#1925-ACL-multiple-down-key-cause-error'

# Conflicts:
#   orders/static/js/orders_helper.js
parents 6065759d 46d9ed42
dev_cooperatic #5673_bug_calendrier_echange_service 3832-makeups-and-member-status-update 4081 4444_improve_presence_recording 4709 4778-reception-dont-get-finished-orders 4809-remove-shelf-value-col-to-reduce-server-load 4880-rapports-reception-faux 4950-douchage-appli-reception 5474-et-5462-Voir-les-rattrapages-choisis-dans-admin-bdm-et-corrige-lenteur-affichage-admin-rattrapages 5641-reception-trier-a-la-maj-prix-dans-ordre-de-pointage-quantites 6286_bug_encaissement_souscription_cheque_espece 6813-marking-parent-gone-when-unpairing-binom-does-not-unsuscribe-parent-from-shift-template 6832--certaines-absences-engendrent-une-erreur 7723-7559-change-purchase-order-workflow-django-side 7731-third-party-side-brinks-pos-export-not-working 7747-inventaire-par-article 7800-make-test-solution-work 7819-prevent-adding-product-already-in-order 7848-cannot-validate-qty-with-decimal-on-kg-product 7918_bug_quantites_stade_demande_prix adaptation_supercafoutch adaptation_supercoop adaptation_supercoop_supercafoutch adpatation_chouette assistance_import_article coop_dev_necessitant_modules_bdm_odoo_modifies correctif_nb_rattrapages_creation_binome_avec_ajout_automatique_au_point_negatif dev_principale export_capital_detenu fix_bug_process_picking fusion_custom_graoucoop graoucoop_backup graoucoop_prod graoucoop_tmp hot_fix_shelf_labels_auto_print impression_etiquettes_rayons integration_lien_precommandes_dans_espace_membre lacagette_prod local_branch meal-voucher-and-label-printer-software-bug migration-v12 pour_graoucoop_prod pour_version_prod_cagette refonte_espace_membre_sc retouches_tickets_supercoop sc-setup-stock-app supercafoutch-preprod supercafoutch-prod-20221003 supercafoutch_prod ticket_4146 supercafoutch_20250120_151258 supercafoutch_20250120_150340 supercafoutch_20240909_080630 supercafoutch_20240609_115709 supercafoutch_20240212_082431 supercafoutch_20240107_181851 supercafoutch_prod_until_240107 supercafoutch-prod-20221003 supercafoutch-230911 supercafoutch-230824 supercafoutch-230823 supercafoutch-230823-the-true-one migration-v12-tag lacagette_20240310_074751 lacagette_20240107_122554 lacagette_20240107_120916 graoucoop_20240609_122614 cagette_testtag cagette-230814 cagette-230630
2 merge requests!164Intégration des dév. Cooperatic pour la Cagette,!1111925 pressing multiple times on down arrow throw js error
Pipeline #1745 passed with stage
in 1 minute 37 seconds
...@@ -705,6 +705,8 @@ function save_products_npa_minimal_stock(product, inputs) { ...@@ -705,6 +705,8 @@ function save_products_npa_minimal_stock(product, inputs) {
actions.minimal_stock = input.val() actions.minimal_stock = input.val()
} }
}); });
openModal();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/products/update_npa_and_minimal_stock", url: "/products/update_npa_and_minimal_stock",
...@@ -715,6 +717,20 @@ function save_products_npa_minimal_stock(product, inputs) { ...@@ -715,6 +717,20 @@ function save_products_npa_minimal_stock(product, inputs) {
success: () => { success: () => {
const index = products.findIndex(p => p.id == product.id); const index = products.findIndex(p => p.id == product.id);
products[index].minimal_stock = actions.minimal_stock;
if (actions.npa.length > 0) {
// Remove NPA products
products.splice(index, 1);
update_main_screen();
debounceFunction(update_cdb_order);
}
check_products_data()
.then(() => {
update_cdb_order();
update_main_screen();
closeModal();
// Give time for modal to fade // Give time for modal to fade
setTimeout(function() { setTimeout(function() {
$(".actions_buttons_area .right_action_buttons").notify( $(".actions_buttons_area .right_action_buttons").notify(
...@@ -726,15 +742,7 @@ function save_products_npa_minimal_stock(product, inputs) { ...@@ -726,15 +742,7 @@ function save_products_npa_minimal_stock(product, inputs) {
} }
); );
}, 500); }, 500);
products[index].minimal_stock = actions.minimal_stock; });
if (actions.npa.length > 0) {
// Remove NPA products
products.splice(index, 1);
update_main_screen();
debounceFunction(update_cdb_order);
}
closeModal();
}, },
error: function(data) { error: function(data) {
let msg = "erreur serveur lors de la sauvegarde". let msg = "erreur serveur lors de la sauvegarde".
......
...@@ -189,34 +189,51 @@ class ExportPOS(View): ...@@ -189,34 +189,51 @@ class ExportPOS(View):
kept_sessions_id.append(s['id']) kept_sessions_id.append(s['id'])
key = y + '-' + m + '-' + d key = y + '-' + m + '-' + d
if not (key in totals): if not (key in totals):
totals[key] = {'CB': 0, 'CSH': 0, 'CHQ': 0, 'TOTAL': 0} totals[key] = {'CB': 0,
'CSH': 0,
'CHQ': 0,
'CB_DEJ': 0,
'CHQ_DEJ': 0,
'TOTAL': 0}
sub_total = 0 sub_total = 0
cb = chq = csh = 0 cb = chq = csh = cbd = chqd = 0
for p in s['payments']: for p in s['payments']:
# p['name'] is a sequence generated string
# Test order is important as CHEQDEJ contains CHEQ for ex.
# p['journal'] could be used but easier to change in Odoo interface
sub_amount = round(p['total_amount'], 2)
if 'CSH' in p['name']: if 'CSH' in p['name']:
csh = round(p['total_amount'], 2) csh = sub_amount
elif 'CHEQDEJ' in p['name']:
chqd = sub_amount
elif 'CHEQ' in p['name']: elif 'CHEQ' in p['name']:
chq = round(p['total_amount'], 2) chq = sub_amount
elif 'CBDEJ' in p['name']:
cbd = sub_amount
elif 'CB' in p['name']: elif 'CB' in p['name']:
cb = round(p['total_amount'], 2) cb = sub_amount
sub_total += round(p['total_amount'], 2) sub_total += sub_amount
totals[key]['CB'] += cb totals[key]['CB'] += cb
totals[key]['CSH'] += csh totals[key]['CSH'] += csh
totals[key]['CHQ'] += chq totals[key]['CHQ'] += chq
totals[key]['CB_DEJ'] += cbd
totals[key]['CHQ_DEJ'] += chqd
totals[key]['TOTAL'] += round(sub_total, 2) totals[key]['TOTAL'] += round(sub_total, 2)
details_lines.append([mois, s['mm_dates']['min'], s['mm_dates']['min'], s['caisse'], s['name'], details_lines.append([mois, s['mm_dates']['min'], s['mm_dates']['min'], s['caisse'], s['name'],
cb, csh, chq, sub_total]) cb, csh, chq, cbd, chqd, sub_total])
wb = Workbook() wb = Workbook()
ws1 = wb.create_sheet("Totaux " + mois, 0) ws1 = wb.create_sheet("Totaux " + mois, 0)
ws2 = wb.create_sheet("Détails " + mois, 1) ws2 = wb.create_sheet("Détails " + mois, 1)
ws1.append(['date', 'CB', 'CSH', 'CHQ', 'Total']) ws1.append(['date', 'CB', 'CSH', 'CHQ', 'CB_DEJ', 'CHQ_DEJ', 'Total'])
for day in sorted(totals): for day in sorted(totals):
cb = totals[day]['CB'] cb = totals[day]['CB']
csh = totals[day]['CSH'] csh = totals[day]['CSH']
chq = totals[day]['CHQ'] chq = totals[day]['CHQ']
cbd = totals[day]['CB_DEJ']
chqd = totals[day]['CHQ_DEJ']
total = totals[day]['TOTAL'] total = totals[day]['TOTAL']
ws1.append([day, cb, csh, chq, total]) ws1.append([day, cb, csh, chq, cbd, chqd, total])
ws2.append(['mois', 'min_date', 'max_date', 'Caisse', 'session', 'CB', 'CSH','CHQ', 'total']) ws2.append(['mois', 'min_date', 'max_date', 'Caisse', 'session', 'CB', 'CSH','CHQ', 'CB_DEJ', 'CHQ_DEJ', 'total'])
for row in details_lines: for row in details_lines:
ws2.append(row) ws2.append(row)
wb_name = 'export_sessions__' + mois + '.xlsx' wb_name = 'export_sessions__' + mois + '.xlsx'
......
...@@ -14,38 +14,29 @@ class CagetteSales(models.Model): ...@@ -14,38 +14,29 @@ class CagetteSales(models.Model):
def get_sales(self, date_from, date_to): def get_sales(self, date_from, date_to):
res = [] res = []
# Get pos sessions # Get pos orders
cond = [['stop_at', '>=', date_from], ['stop_at', '<=', date_to], ['state', '=', "closed"]] cond = [['date_order', '>=', date_from], ['date_order', '<=', date_to]]
fields = [] fields = ['partner_id', 'statement_ids', 'name']
sessions = self.o_api.search_read('pos.session', cond, fields) orders = self.o_api.search_read('pos.order', cond, fields)
# Get bank statements of these sessions # Get bank statements of these sessions
statements = [] statements = []
for s in sessions: statements_partners = {}
statements = statements + s["statement_ids"] statements_orders = {}
for o in orders:
statements = statements + o["statement_ids"]
for s in o["statement_ids"]:
statements_partners[s] = o["partner_id"][1]
statements_orders[s] = o["name"]
# Get payment lines # Get payment lines
cond = [['statement_id', 'in', statements]] cond = [['id', 'in', statements]]
fields = ["partner_id", "amount", "journal_id", "create_date", "date"] fields = ["amount", "journal_id", "create_date"]
payments = self.o_api.search_read('account.bank.statement.line', cond, fields, order="create_date ASC", limit=50000) payments = self.o_api.search_read('account.bank.statement.line', cond, fields, order="create_date ASC", limit=50000)
item = None
try: try:
for payment in payments: for payment in payments:
# POS session can contain payments from another day (closing session on next morning, ...) res.append({
if payment["date"] >= date_from and payment["date"] <= date_to: "partner": statements_partners[payment["id"]],
# If the consecutive payment in the results is from the same partner on the same day, we consider it's the same basket
if item is not None and item["partner_id"][0] == payment["partner_id"][0] and item["date"] == payment["date"]:
res[len(res)-1]["total_amount"] += round(float(payment["amount"]), 2)
res[len(res)-1]["payments"].append({
"amount": round(float(payment["amount"]), 2),
"journal_id": payment["journal_id"]
})
else:
item = {
"partner_id": payment["partner_id"],
"create_date": payment["create_date"], "create_date": payment["create_date"],
"date": payment["date"], "pos_order_name": statements_orders[payment["id"]],
"total_amount": round(float(payment["amount"]), 2), "total_amount": round(float(payment["amount"]), 2),
"payments": [ "payments": [
{ {
...@@ -53,10 +44,8 @@ class CagetteSales(models.Model): ...@@ -53,10 +44,8 @@ class CagetteSales(models.Model):
"journal_id": payment["journal_id"] "journal_id": payment["journal_id"]
} }
] ]
} })
res.append(item)
except Exception as e: except Exception as e:
pass coop_logger.error("get_sales %s", str(e))
return res return res
...@@ -38,20 +38,23 @@ function display_orders(orders) { ...@@ -38,20 +38,23 @@ function display_orders(orders) {
columns:[ columns:[
{ {
data:"create_date", data:"create_date",
title:"Date de vente", title:"Date enregistrement",
width: "10%" width: "10%"
}, },
{ {
data:"partner_id", data:"pos_order_name",
title:"Ref. Caisse",
width: "10%"
},
{
data:"partner",
title:"Membre", title:"Membre",
width: "50%", width: "40%"
render: function (data) {
return data[1];
}
}, },
{ {
data:"total_amount", data:"total_amount",
title: "Montant du panier", title: "Montant dû",
className:"dt-body-center", className:"dt-body-center",
render: function (data) { render: function (data) {
return parseFloat(data).toFixed(2) + ' €'; return parseFloat(data).toFixed(2) + ' €';
......
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