[IMP] account_reconcile_oca: Allow to select all lines at once
parent
7a27012bdd
commit
90262374d8
|
@ -52,6 +52,13 @@ msgstr ""
|
|||
msgid "Add Bank Statement Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_reconcile_oca
|
||||
#. odoo-javascript
|
||||
#: code:addons/account_reconcile_oca/static/src/xml/reconcile.xml:0
|
||||
#, python-format
|
||||
msgid "Add all"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_reconcile_oca
|
||||
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_bank_statement_line__aggregate_id
|
||||
msgid "Aggregate"
|
||||
|
|
|
@ -6,7 +6,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2025-01-29 18:52+0000\n"
|
||||
"PO-Revision-Date: 2025-02-12 08:24+0000\n"
|
||||
"Last-Translator: \"Pedro M. Baeza\" <pedro.baeza@tecnativa.com>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: es\n"
|
||||
|
@ -58,6 +58,13 @@ msgstr "Añadir apunte contable"
|
|||
msgid "Add Bank Statement Line"
|
||||
msgstr "Añadir línea de extracto bancario"
|
||||
|
||||
#. module: account_reconcile_oca
|
||||
#. odoo-javascript
|
||||
#: code:addons/account_reconcile_oca/static/src/xml/reconcile.xml:0
|
||||
#, python-format
|
||||
msgid "Add all"
|
||||
msgstr "Añadir todo"
|
||||
|
||||
#. module: account_reconcile_oca
|
||||
#: model:ir.model.fields,field_description:account_reconcile_oca.field_account_bank_statement_line__aggregate_id
|
||||
msgid "Aggregate"
|
||||
|
|
|
@ -132,16 +132,17 @@ class AccountAccountReconcile(models.Model):
|
|||
@api.onchange("add_account_move_line_id")
|
||||
def _onchange_add_account_move_line(self):
|
||||
if self.add_account_move_line_id:
|
||||
data = self.reconcile_data_info
|
||||
if self.add_account_move_line_id.id not in data["counterparts"]:
|
||||
data["counterparts"].append(self.add_account_move_line_id.id)
|
||||
else:
|
||||
del data["counterparts"][
|
||||
data["counterparts"].index(self.add_account_move_line_id.id)
|
||||
]
|
||||
self.reconcile_data_info = self._recompute_data(data)
|
||||
self._add_account_move_line(self.add_account_move_line_id)
|
||||
self.add_account_move_line_id = False
|
||||
|
||||
def _add_account_move_line(self, move_line, keep_current=False):
|
||||
data = self.reconcile_data_info
|
||||
if move_line.id not in data["counterparts"]:
|
||||
data["counterparts"].append(move_line.id)
|
||||
elif not keep_current:
|
||||
del data["counterparts"][data["counterparts"].index(move_line.id)]
|
||||
self.reconcile_data_info = self._recompute_data(data)
|
||||
|
||||
@api.onchange("manual_reference", "manual_delete")
|
||||
def _onchange_manual_reconcile_reference(self):
|
||||
self.ensure_one()
|
||||
|
@ -187,6 +188,13 @@ class AccountAccountReconcile(models.Model):
|
|||
)
|
||||
data_record.unlink()
|
||||
|
||||
def add_multiple_lines(self, domain):
|
||||
res = super().add_multiple_lines(domain)
|
||||
lines = self.env["account.move.line"].search(domain)
|
||||
for line in lines:
|
||||
self._add_account_move_line(line, keep_current=True)
|
||||
return res
|
||||
|
||||
|
||||
class AccountAccountReconcileData(models.TransientModel):
|
||||
_name = "account.account.reconcile.data"
|
||||
|
|
|
@ -194,37 +194,40 @@ class AccountBankStatementLine(models.Model):
|
|||
@api.onchange("add_account_move_line_id")
|
||||
def _onchange_add_account_move_line_id(self):
|
||||
if self.add_account_move_line_id:
|
||||
data = self.reconcile_data_info["data"]
|
||||
new_data = []
|
||||
is_new_line = True
|
||||
pending_amount = 0.0
|
||||
currency = self._get_reconcile_currency()
|
||||
for line in data:
|
||||
if line["kind"] != "suspense":
|
||||
pending_amount += self._get_amount_currency(line, currency)
|
||||
if self.add_account_move_line_id.id in line.get(
|
||||
"counterpart_line_ids", []
|
||||
):
|
||||
is_new_line = False
|
||||
else:
|
||||
new_data.append(line)
|
||||
if is_new_line:
|
||||
reconcile_auxiliary_id, lines = self._get_reconcile_line(
|
||||
self.add_account_move_line_id,
|
||||
"other",
|
||||
is_counterpart=True,
|
||||
max_amount=currency.round(pending_amount),
|
||||
move=True,
|
||||
)
|
||||
new_data += lines
|
||||
self.reconcile_data_info = self._recompute_suspense_line(
|
||||
new_data,
|
||||
self.reconcile_data_info["reconcile_auxiliary_id"],
|
||||
self.manual_reference,
|
||||
)
|
||||
self.can_reconcile = self.reconcile_data_info.get("can_reconcile", False)
|
||||
self._add_account_move_line(self.add_account_move_line_id)
|
||||
self.add_account_move_line_id = False
|
||||
|
||||
def _add_account_move_line(self, move_line, keep_current=False):
|
||||
data = self.reconcile_data_info["data"]
|
||||
new_data = []
|
||||
is_new_line = True
|
||||
pending_amount = 0.0
|
||||
currency = self._get_reconcile_currency()
|
||||
for line in data:
|
||||
if line["kind"] != "suspense":
|
||||
pending_amount += self._get_amount_currency(line, currency)
|
||||
if move_line.id in line.get("counterpart_line_ids", []):
|
||||
is_new_line = False
|
||||
if keep_current:
|
||||
new_data.append(line)
|
||||
else:
|
||||
new_data.append(line)
|
||||
if is_new_line:
|
||||
reconcile_auxiliary_id, lines = self._get_reconcile_line(
|
||||
move_line,
|
||||
"other",
|
||||
is_counterpart=True,
|
||||
max_amount=currency.round(pending_amount),
|
||||
move=True,
|
||||
)
|
||||
new_data += lines
|
||||
self.reconcile_data_info = self._recompute_suspense_line(
|
||||
new_data,
|
||||
self.reconcile_data_info["reconcile_auxiliary_id"],
|
||||
self.manual_reference,
|
||||
)
|
||||
self.can_reconcile = self.reconcile_data_info.get("can_reconcile", False)
|
||||
|
||||
def _recompute_suspense_line(self, data, reconcile_auxiliary_id, manual_reference):
|
||||
can_reconcile = True
|
||||
total_amount = 0
|
||||
|
@ -1260,3 +1263,10 @@ class AccountBankStatementLine(models.Model):
|
|||
or self.journal_id.currency_id
|
||||
or self.company_id.currency_id
|
||||
)
|
||||
|
||||
def add_multiple_lines(self, domain):
|
||||
res = super().add_multiple_lines(domain)
|
||||
lines = self.env["account.move.line"].search(domain)
|
||||
for line in lines:
|
||||
self._add_account_move_line(line, keep_current=True)
|
||||
return res
|
||||
|
|
|
@ -124,3 +124,6 @@ class AccountReconcileAbstract(models.AbstractModel):
|
|||
if is_counterpart:
|
||||
vals["counterpart_line_ids"] = line.ids
|
||||
return [vals]
|
||||
|
||||
def add_multiple_lines(self, domain):
|
||||
self.ensure_one()
|
||||
|
|
|
@ -8,6 +8,15 @@ export class ReconcileMoveLineController extends ListController {
|
|||
data[this.props.parentField] = [record.resId, record.display_name];
|
||||
this.props.parentRecord.update(data);
|
||||
}
|
||||
async clickAddAll() {
|
||||
await this.props.parentRecord.save();
|
||||
await this.orm.call(this.props.parentRecord.resModel, "add_multiple_lines", [
|
||||
this.props.parentRecord.resIds,
|
||||
this.model.root.domain,
|
||||
]);
|
||||
await this.props.parentRecord.load();
|
||||
this.props.parentRecord.model.notify();
|
||||
}
|
||||
}
|
||||
|
||||
ReconcileMoveLineController.template = `account_reconcile_oca.ReconcileMoveLineController`;
|
||||
|
|
|
@ -10,6 +10,7 @@ export const ReconcileMoveLineView = {
|
|||
...listView,
|
||||
Controller: ReconcileMoveLineController,
|
||||
Renderer: ReconcileMoveLineRenderer,
|
||||
buttonTemplate: "reconcile_move_line.ListView.Buttons",
|
||||
};
|
||||
|
||||
registry.category("views").add("reconcile_move_line", ReconcileMoveLineView);
|
||||
|
|
|
@ -31,7 +31,7 @@ export class AccountReconcileMatchWidget extends Component {
|
|||
controlPanel: {
|
||||
// Hiding the control panel buttons
|
||||
"top-left": false,
|
||||
"bottom-left": false,
|
||||
"bottom-left": true,
|
||||
layoutActions: false,
|
||||
},
|
||||
},
|
||||
|
@ -49,6 +49,7 @@ export class AccountReconcileMatchWidget extends Component {
|
|||
searchViewId: false,
|
||||
parentRecord: this.props.record,
|
||||
parentField: this.props.name,
|
||||
showButtons: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,4 +200,7 @@
|
|||
<attribute name="parentField">props.parentField</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
<t t-name="reconcile_move_line.ListView.Buttons">
|
||||
<button class="btn btn-primary" t-on-click="clickAddAll">Add all</button>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
Loading…
Reference in New Issue