Files
odoo-docs/static/js/reconciliation.js
Lulu Grimalkin (lugr) 912dde6d26 [ADD] Inventory: add stock valuation cheat sheet
An adaptation of the venerable business memento from 8.0 to the new
inventory valuation mechanics of Odoo 19.0 by scavenging and cobbling
together of the scripts `entries.js` and `coa-valuation.js`. The shared
data is kept in a separate file.

Additionally, we remove the old inventory valuation documentation.

Task ID: 5107300

closes odoo/documentation#14906

Signed-off-by: Felicia Kuan (feku) <feku@odoo.com>
2025-10-23 17:06:20 +00:00

73 lines
2.5 KiB
JavaScript

(function () {
// NOTE: used by accounting cheat_sheet.rst
document.addEventListener('DOMContentLoaded', function () {
var $rec = $('#reconciliation .reconciliation-example');
if (!$rec.length) { return; }
var state = 0;
var operations = [
function reconcile2() {
$rec.addClass('reconcile2');
return 1;
},
function reconcile1() {
$rec.addClass('reconcile1');
return 2;
},
function unreconcile() {
$rec.removeClass('reconcile1 reconcile2');
$1.add($2).removeClass('reconciled');
setTimeout(update_btn, 0);
return 0;
}
];
var $buttons = $('<div class="buttons">').on('click', 'button', function () {
this.disabled = true;
state = operations[state]();
}).appendTo($rec);
var $1 = $rec.find('td:contains("Invoice 1"), td:contains("Partial payment 1/2"), td:contains("Partial payment 2/2")')
.parent()
.addClass('invoice1');
var $2 = $rec.find('td:contains("Invoice 2"), td:contains("Payment 2")')
.parent()
.addClass('invoice2');
// will be called multiple times (each tr + each td), only take trs in
// account
$rec.on('animationend webkitAnimationEnd MSAnimationEnd', function (e) {
switch (e.originalEvent.target) {
case $1[0]:
$1.addClass('reconciled');
break;
case $2[0]:
$2.addClass('reconciled');
break;
}
update_btn();
});
update_btn();
function update_btn() {
var $reconcile = $('<button class="btn btn-secondary" type="button">')
.text("Next Reconcile")
.appendTo($buttons.empty())
switch (state) {
case 0:
$reconcile.text("Reconcile");
break;
case 1:
break;
case 2:
$reconcile.prop('disabled', true);
$('<button class="btn btn-primary" type="button">')
.text("Unreconcile")
.appendTo($buttons);
break;
default:
throw new Error("Unknown button state " + state);
}
}
});
})();