diff --git a/account_reconciliation_widget/models/account_bank_statement.py b/account_reconciliation_widget/models/account_bank_statement.py index d7d3975a..1a942e12 100644 --- a/account_reconciliation_widget/models/account_bank_statement.py +++ b/account_reconciliation_widget/models/account_bank_statement.py @@ -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 diff --git a/account_reconciliation_widget/models/reconciliation_widget.py b/account_reconciliation_widget/models/reconciliation_widget.py index 8a5bae60..d07e623c 100644 --- a/account_reconciliation_widget/models/reconciliation_widget.py +++ b/account_reconciliation_widget/models/reconciliation_widget.py @@ -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( diff --git a/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_action.js b/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_action.js index 7aeb9dbe..e0bae4b9 100644 --- a/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_action.js +++ b/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_action.js @@ -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", diff --git a/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_model.js b/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_model.js index d238b1ab..c7156f1c 100644 --- a/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_model.js +++ b/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_model.js @@ -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} 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; diff --git a/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_renderer.js b/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_renderer.js index 1dc17e08..94420573 100644 --- a/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_renderer.js +++ b/account_reconciliation_widget/static/src/js/reconciliation/reconciliation_renderer.js @@ -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; diff --git a/account_reconciliation_widget/static/src/scss/account_reconciliation.scss b/account_reconciliation_widget/static/src/scss/account_reconciliation.scss index f776eebe..f8efda6e 100644 --- a/account_reconciliation_widget/static/src/scss/account_reconciliation.scss +++ b/account_reconciliation_widget/static/src/scss/account_reconciliation.scss @@ -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; diff --git a/account_reconciliation_widget/static/src/xml/account_reconciliation.xml b/account_reconciliation_widget/static/src/xml/account_reconciliation.xml index 668421af..3871adb0 100644 --- a/account_reconciliation_widget/static/src/xml/account_reconciliation.xml +++ b/account_reconciliation_widget/static/src/xml/account_reconciliation.xml @@ -126,6 +126,9 @@
+
+ +