account_reconciliation_widget: ability to edit ref

'ref' of account.move can now be customized in the reconciliation widget
'name' of account.move is displayed for information
This commit is contained in:
Alexis de Lattre
2022-08-01 17:42:02 +02:00
parent 2927fd9fee
commit 5875616665
7 changed files with 77 additions and 11 deletions

View File

@@ -222,7 +222,6 @@ class AccountBankStatementLine(models.Model):
aml_obj.with_context(check_move_validity=False).create(liquidity_aml_dict)
self.sequence = self.statement_id.line_ids.ids.index(self.id) + 1
self.move_id.ref = self._get_move_ref(self.statement_id.name)
counterpart_moves = counterpart_moves | self.move_id
# Complete dicts to create both counterpart move lines and write-offs
@@ -272,12 +271,6 @@ class AccountBankStatementLine(models.Model):
return counterpart_moves
def _get_move_ref(self, move_ref):
ref = move_ref or ""
if self.ref:
ref = move_ref + " - " + self.ref if move_ref else self.ref
return ref
def _prepare_move_line_for_currency(self, aml_dict, date):
self.ensure_one()
company_currency = self.journal_id.company_id.currency_id

View File

@@ -42,8 +42,13 @@ class AccountReconciliation(models.AbstractModel):
)
del aml_dict["counterpart_aml_id"]
vals = {}
if datum.get("partner_id") is not None:
st_line.write({"partner_id": datum["partner_id"]})
vals["partner_id"] = datum["partner_id"]
if datum.get("ref") is not None:
vals["ref"] = datum["ref"]
if vals:
st_line.write(vals)
ctx["default_to_check"] = datum.get("to_check")
moves = st_line.with_context(ctx).process_reconciliation(

View File

@@ -21,6 +21,7 @@ odoo.define("account.ReconciliationClientAction", function (require) {
change_filter: "_onAction",
change_offset: "_onAction",
change_partner: "_onAction",
change_ref: "_onAction",
add_proposition: "_onAction",
remove_proposition: "_onAction",
update_proposition: "_onAction",

View File

@@ -298,6 +298,13 @@ odoo.define("account.ReconciliationModel", function (require) {
);
});
},
// eslint-disable-next-line no-unused-vars
changeRef: function (handle, ref, preserveMode) {
var line = this.getLine(handle);
line.st_line.ref = ref;
return Promise.resolve();
},
/**
* Close the statement
* @returns {Promise<Number>} resolves to the res_id of the closed statements
@@ -479,6 +486,7 @@ odoo.define("account.ReconciliationModel", function (require) {
self.lines[handle] = {
id: res.st_line.id,
partner_id: res.st_line.partner_id,
ref: res.st_line.ref,
handle: handle,
reconciled: false,
mode: "inactive",
@@ -967,6 +975,7 @@ odoo.define("account.ReconciliationModel", function (require) {
Promise.resolve(computeLinePromise).then(function () {
var values_dict = {
partner_id: line.st_line.partner_id,
ref: line.st_line.ref,
counterpart_aml_dicts: _.map(
_.filter(props, function (prop) {
return !isNaN(prop.id) && !prop.is_liquidity_line;

View File

@@ -325,10 +325,31 @@ odoo.define("account.ReconciliationRenderer", function (require) {
}
),
};
self.fields.partner_id.insertAfter(
self.$(".accounting_view caption .o_buttons")
self.fields.partner_id.insertBefore(
self.$(".accounting_view caption .caption-input")
);
});
// Ref
var def5 = this._makeRefRecord(this._initialState.st_line.ref).then(
function (recordID) {
self.fields.ref = new basic_fields.FieldChar(
self,
"ref",
self.model.get(recordID),
{
mode: "edit",
attrs: {
placeholder:
self._initialState.st_line.ref || _t("Reference"),
},
}
);
self.fields.ref.prependTo(
self.$(".accounting_view caption .caption-input")
);
}
);
var def3 = session
.user_has_group("analytic.group_analytic_tags")
.then(function (has_group) {
@@ -360,7 +381,7 @@ odoo.define("account.ReconciliationRenderer", function (require) {
toggle: "popover",
});
var def2 = this._super.apply(this, arguments);
return Promise.all([def1, def2, def3, def4]);
return Promise.all([def1, def2, def3, def4, def5]);
},
// --------------------------------------------------------------------------
@@ -402,6 +423,12 @@ odoo.define("account.ReconciliationRenderer", function (require) {
self.$el.attr("data-partner", state.st_line.partner_id);
});
// Ref
this._makeRefRecord(state.st_line.ref).then(function (recordID) {
self.fields.ref.reset(self.model.get(recordID));
self.$el.attr("data-ref", state.st_line.ref);
});
// Mode
this.$el.data("mode", state.mode).attr("data-mode", state.mode);
this.$(".o_notebook li a").attr("aria-selected", false);
@@ -662,6 +689,17 @@ odoo.define("account.ReconciliationRenderer", function (require) {
});
},
_makeRefRecord: function (ref) {
var field = {
type: "char",
name: "ref",
};
if (ref) {
field.value = ref;
}
return this.model.makeRecord("account.bank.statement.line", [field], {});
},
/**
* Create account_id, tax_ids, analytic_account_id, analytic_tag_ids, label and amount fields
*
@@ -714,6 +752,10 @@ odoo.define("account.ReconciliationRenderer", function (require) {
type: "char",
name: "label",
},
{
type: "char",
name: "ref",
},
{
type: "float",
name: "amount",
@@ -945,6 +987,9 @@ odoo.define("account.ReconciliationRenderer", function (require) {
if (fieldName === "partner_id") {
var partner_id = event.data.changes.partner_id;
this.trigger_up("change_partner", {data: partner_id});
} else if (fieldName === "ref") {
var ref = event.data.changes.ref;
this.trigger_up("change_ref", {data: ref});
} else {
if (event.data.changes.amount && isNaN(event.data.changes.amount)) {
return;

View File

@@ -56,6 +56,16 @@
.strike_amount {
text-decoration: line-through;
}
.move_name {
font-size: 80%;
margin-left: 1em;
display: flex;
align-items: center;
}
.caption-input {
margin-left: 1em;
display: inline-flex;
}
tbody tr:hover .cell_account_code::before {
content: "\f068";
font-family: FontAwesome;

View File

@@ -126,6 +126,9 @@
<div class="o_reconciliation_line" t-att-data-mode="state.mode" tabindex="0">
<table class="accounting_view">
<caption style="caption-side: top;">
<div class="caption-input">
<span class="move_name"><t t-esc="state.st_line.name" /></span>
</div>
<div class="float-right o_buttons">
<button
t-attf-class="o_no_valid btn btn-secondary #{state.balance.type &lt; 0 ? '' : 'd-none'}"