mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
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:
@@ -222,7 +222,6 @@ class AccountBankStatementLine(models.Model):
|
|||||||
aml_obj.with_context(check_move_validity=False).create(liquidity_aml_dict)
|
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.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
|
counterpart_moves = counterpart_moves | self.move_id
|
||||||
|
|
||||||
# Complete dicts to create both counterpart move lines and write-offs
|
# Complete dicts to create both counterpart move lines and write-offs
|
||||||
@@ -272,12 +271,6 @@ class AccountBankStatementLine(models.Model):
|
|||||||
|
|
||||||
return counterpart_moves
|
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):
|
def _prepare_move_line_for_currency(self, aml_dict, date):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
company_currency = self.journal_id.company_id.currency_id
|
company_currency = self.journal_id.company_id.currency_id
|
||||||
|
|||||||
@@ -42,8 +42,13 @@ class AccountReconciliation(models.AbstractModel):
|
|||||||
)
|
)
|
||||||
del aml_dict["counterpart_aml_id"]
|
del aml_dict["counterpart_aml_id"]
|
||||||
|
|
||||||
|
vals = {}
|
||||||
if datum.get("partner_id") is not None:
|
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")
|
ctx["default_to_check"] = datum.get("to_check")
|
||||||
moves = st_line.with_context(ctx).process_reconciliation(
|
moves = st_line.with_context(ctx).process_reconciliation(
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ odoo.define("account.ReconciliationClientAction", function (require) {
|
|||||||
change_filter: "_onAction",
|
change_filter: "_onAction",
|
||||||
change_offset: "_onAction",
|
change_offset: "_onAction",
|
||||||
change_partner: "_onAction",
|
change_partner: "_onAction",
|
||||||
|
change_ref: "_onAction",
|
||||||
add_proposition: "_onAction",
|
add_proposition: "_onAction",
|
||||||
remove_proposition: "_onAction",
|
remove_proposition: "_onAction",
|
||||||
update_proposition: "_onAction",
|
update_proposition: "_onAction",
|
||||||
|
|||||||
@@ -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
|
* Close the statement
|
||||||
* @returns {Promise<Number>} resolves to the res_id of the closed statements
|
* @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] = {
|
self.lines[handle] = {
|
||||||
id: res.st_line.id,
|
id: res.st_line.id,
|
||||||
partner_id: res.st_line.partner_id,
|
partner_id: res.st_line.partner_id,
|
||||||
|
ref: res.st_line.ref,
|
||||||
handle: handle,
|
handle: handle,
|
||||||
reconciled: false,
|
reconciled: false,
|
||||||
mode: "inactive",
|
mode: "inactive",
|
||||||
@@ -967,6 +975,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
|||||||
Promise.resolve(computeLinePromise).then(function () {
|
Promise.resolve(computeLinePromise).then(function () {
|
||||||
var values_dict = {
|
var values_dict = {
|
||||||
partner_id: line.st_line.partner_id,
|
partner_id: line.st_line.partner_id,
|
||||||
|
ref: line.st_line.ref,
|
||||||
counterpart_aml_dicts: _.map(
|
counterpart_aml_dicts: _.map(
|
||||||
_.filter(props, function (prop) {
|
_.filter(props, function (prop) {
|
||||||
return !isNaN(prop.id) && !prop.is_liquidity_line;
|
return !isNaN(prop.id) && !prop.is_liquidity_line;
|
||||||
|
|||||||
@@ -325,10 +325,31 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
self.fields.partner_id.insertAfter(
|
self.fields.partner_id.insertBefore(
|
||||||
self.$(".accounting_view caption .o_buttons")
|
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
|
var def3 = session
|
||||||
.user_has_group("analytic.group_analytic_tags")
|
.user_has_group("analytic.group_analytic_tags")
|
||||||
.then(function (has_group) {
|
.then(function (has_group) {
|
||||||
@@ -360,7 +381,7 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
|||||||
toggle: "popover",
|
toggle: "popover",
|
||||||
});
|
});
|
||||||
var def2 = this._super.apply(this, arguments);
|
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);
|
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
|
// Mode
|
||||||
this.$el.data("mode", state.mode).attr("data-mode", state.mode);
|
this.$el.data("mode", state.mode).attr("data-mode", state.mode);
|
||||||
this.$(".o_notebook li a").attr("aria-selected", false);
|
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
|
* 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",
|
type: "char",
|
||||||
name: "label",
|
name: "label",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "char",
|
||||||
|
name: "ref",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "float",
|
type: "float",
|
||||||
name: "amount",
|
name: "amount",
|
||||||
@@ -945,6 +987,9 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
|||||||
if (fieldName === "partner_id") {
|
if (fieldName === "partner_id") {
|
||||||
var partner_id = event.data.changes.partner_id;
|
var partner_id = event.data.changes.partner_id;
|
||||||
this.trigger_up("change_partner", {data: 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 {
|
} else {
|
||||||
if (event.data.changes.amount && isNaN(event.data.changes.amount)) {
|
if (event.data.changes.amount && isNaN(event.data.changes.amount)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -56,6 +56,16 @@
|
|||||||
.strike_amount {
|
.strike_amount {
|
||||||
text-decoration: line-through;
|
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 {
|
tbody tr:hover .cell_account_code::before {
|
||||||
content: "\f068";
|
content: "\f068";
|
||||||
font-family: FontAwesome;
|
font-family: FontAwesome;
|
||||||
|
|||||||
@@ -126,6 +126,9 @@
|
|||||||
<div class="o_reconciliation_line" t-att-data-mode="state.mode" tabindex="0">
|
<div class="o_reconciliation_line" t-att-data-mode="state.mode" tabindex="0">
|
||||||
<table class="accounting_view">
|
<table class="accounting_view">
|
||||||
<caption style="caption-side: top;">
|
<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">
|
<div class="float-right o_buttons">
|
||||||
<button
|
<button
|
||||||
t-attf-class="o_no_valid btn btn-secondary #{state.balance.type < 0 ? '' : 'd-none'}"
|
t-attf-class="o_no_valid btn btn-secondary #{state.balance.type < 0 ? '' : 'd-none'}"
|
||||||
|
|||||||
Reference in New Issue
Block a user