Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0] account_reconcile_oca: forward ports from v16 #760

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .oca/oca-port/blacklist/account_reconcile_oca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"pull_requests": {
"orphaned_commits": "Not needed",
"OCA/account-reconcile#500": "Not needed",
"OCA/account-reconcile#662": "Not needed",
"OCA/account-reconcile#702": "Already in v17",
"OCA/account-reconcile#758": "Cherry picked features"
}
}
15 changes: 15 additions & 0 deletions account_reconcile_oca/models/account_bank_statement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
from odoo.tools.safe_eval import safe_eval


class AccountBankStatement(models.Model):
Expand All @@ -13,3 +14,17 @@
)
action["res_id"] = self.id
return action

def action_open_statement_lines(self):
"""Open in reconciling view directly"""
self.ensure_one()

Check warning on line 20 in account_reconcile_oca/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement.py#L20

Added line #L20 was not covered by tests
if not self:
return {}
action = self.env["ir.actions.act_window"]._for_xml_id(

Check warning on line 23 in account_reconcile_oca/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement.py#L22-L23

Added lines #L22 - L23 were not covered by tests
"account_reconcile_oca.action_bank_statement_line_reconcile"
)
action["domain"] = [("statement_id", "=", self.id)]
action["context"] = safe_eval(

Check warning on line 27 in account_reconcile_oca/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement.py#L26-L27

Added lines #L26 - L27 were not covered by tests
action["context"], locals_dict={"active_id": self._context.get("active_id")}
)
return action

Check warning on line 30 in account_reconcile_oca/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_reconcile_oca/models/account_bank_statement.py#L30

Added line #L30 was not covered by tests
139 changes: 66 additions & 73 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,46 @@ def _check_line_changed(self, line):
!= line.get("partner_id")
)

def _get_manual_delete_vals(self):
return {
"manual_reference": False,
"manual_account_id": False,
"manual_amount": False,
"manual_exchange_counterpart": False,
"manual_in_currency_id": False,
"manual_in_currency": False,
"manual_name": False,
"manual_partner_id": False,
"manual_line_id": False,
"manual_move_id": False,
"manual_move_type": False,
"manual_kind": False,
"manual_original_amount": False,
"manual_currency_id": False,
"analytic_distribution": False,
}

def _process_manual_reconcile_from_line(self, line):
self.manual_account_id = line["account_id"][0]
self.manual_amount = line["amount"]
self.manual_currency_id = line["currency_id"]
self.manual_in_currency_id = line.get("line_currency_id")
self.manual_in_currency = line.get("line_currency_id") and line[
"currency_id"
] != line.get("line_currency_id")
self.manual_amount_in_currency = line.get("currency_amount")
self.manual_name = line["name"]
self.manual_exchange_counterpart = line.get("is_exchange_counterpart", False)
self.manual_partner_id = line.get("partner_id") and line["partner_id"][0]
manual_line = self.env["account.move.line"].browse(line["id"]).exists()
self.manual_line_id = manual_line
self.analytic_distribution = line.get("analytic_distribution", {})
if self.manual_line_id:
self.manual_move_id = self.manual_line_id.move_id
self.manual_move_type = self.manual_line_id.move_id.move_type
self.manual_kind = line["kind"]
self.manual_original_amount = line.get("original_amount", 0.0)

@api.onchange("manual_reference", "manual_delete")
def _onchange_manual_reconcile_reference(self):
self.ensure_one()
Expand All @@ -302,53 +342,10 @@ def _onchange_manual_reconcile_reference(self):
continue
if line["reference"] == self.manual_reference:
if self.manual_delete:
self.update(
{
"manual_reference": False,
"manual_account_id": False,
"manual_amount": False,
"manual_exchange_counterpart": False,
"manual_in_currency_id": False,
"manual_in_currency": False,
"manual_name": False,
"manual_partner_id": False,
"manual_line_id": False,
"manual_move_id": False,
"manual_move_type": False,
"manual_kind": False,
"manual_original_amount": False,
"manual_currency_id": False,
"analytic_distribution": False,
"manual_amount_in_currency": False,
}
)
self.update(self._get_manual_delete_vals())
continue
else:
self.manual_account_id = line["account_id"][0]
self.manual_amount = line["amount"]
self.manual_currency_id = line["currency_id"]
self.manual_in_currency_id = line.get("line_currency_id")
self.manual_in_currency = line.get("line_currency_id") and line[
"currency_id"
] != line.get("line_currency_id")
self.manual_amount_in_currency = line.get("currency_amount")
self.manual_name = line["name"]
self.manual_exchange_counterpart = line.get(
"is_exchange_counterpart", False
)
self.manual_partner_id = (
line.get("partner_id") and line["partner_id"][0]
)
manual_line = (
self.env["account.move.line"].browse(line["id"]).exists()
)
self.manual_line_id = manual_line
self.analytic_distribution = line.get("analytic_distribution", {})
if self.manual_line_id:
self.manual_move_id = self.manual_line_id.move_id
self.manual_move_type = self.manual_line_id.move_id.move_type
self.manual_kind = line["kind"]
self.manual_original_amount = line.get("original_amount", 0.0)
self._process_manual_reconcile_from_line(line)
new_data.append(line)
self.update({"manual_delete": False})
self.reconcile_data_info = self._recompute_suspense_line(
Expand All @@ -369,6 +366,26 @@ def _onchange_manual_amount_in_currency(self):
)
self._onchange_manual_reconcile_vals()

def _get_manual_reconcile_vals(self):
return {
"name": self.manual_name,
"partner_id": (
self.manual_partner_id
and [self.manual_partner_id.id, self.manual_partner_id.display_name]
or (self.partner_name and (False, self.partner_name))
or False
),
"account_id": (
[self.manual_account_id.id, self.manual_account_id.display_name]
if self.manual_account_id
else [False, _("Undefined")]
),
"amount": self.manual_amount,
"credit": -self.manual_amount if self.manual_amount < 0 else 0.0,
"debit": self.manual_amount if self.manual_amount > 0 else 0.0,
"analytic_distribution": self.analytic_distribution,
}

@api.onchange(
"manual_account_id",
"manual_partner_id",
Expand All @@ -383,35 +400,11 @@ def _onchange_manual_reconcile_vals(self):
for line in data:
if line["reference"] == self.manual_reference:
if self._check_line_changed(line):
line.update(
{
"name": self.manual_name,
"partner_id": self.manual_partner_id
and [
self.manual_partner_id.id,
self.manual_partner_id.display_name,
]
or (self.partner_name and (False, self.partner_name))
or False,
"account_id": [
self.manual_account_id.id,
self.manual_account_id.display_name,
]
if self.manual_account_id
else [False, _("Undefined")],
"amount": self.manual_amount,
"credit": -self.manual_amount
if self.manual_amount < 0
else 0.0,
"debit": self.manual_amount
if self.manual_amount > 0
else 0.0,
"analytic_distribution": self.analytic_distribution,
"kind": line["kind"]
if line["kind"] != "suspense"
else "other",
}
line_vals = self._get_manual_reconcile_vals()
line_vals["kind"] = (
line["kind"] if line["kind"] != "suspense" else "other"
)
line.update(line_vals)
if line["kind"] == "liquidity":
self._update_move_partner()
if self.manual_line_id and self.manual_line_id.id == line.get(
Expand Down
6 changes: 6 additions & 0 deletions account_reconcile_oca/static/src/scss/reconcile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
opacity: 100;
}
}
.row {
// We need to add this in order to make remove horizontal scroll
margin: 0;
}
margin: 0 0 0;
min-width: fit-content;
width: 100%;
Expand All @@ -36,10 +40,12 @@
padding: 0;
position: relative;
border-right: 1px solid $o-gray-300;
overflow: auto;
}
.o_account_reconcile_oca_info {
width: 70%;
height: 100%;
overflow: auto;
}
.o_form_view {
.o_form_statusbar.o_account_reconcile_oca_statusbar {
Expand Down
17 changes: 16 additions & 1 deletion account_reconcile_oca/views/account_bank_statement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,22 @@
</form>
</field>
</record>

<record id="view_bank_statement_form" model="ir.ui.view">
<field name="model">account.bank.statement</field>
<field
name="inherit_id"
ref="account_statement_base.view_bank_statement_form"
/>
<field name="arch" type="xml">
<xpath
expr="//button[contains(@context,'search_default_statement_id')]"
position="attributes"
>
<attribute name="type">object</attribute>
<attribute name="name">action_open_statement_lines</attribute>
</xpath>
</field>
</record>
<record id="account_bank_statement_action_edit" model="ir.actions.act_window">
<field name="name">Edit Bank Statement</field>
<field name="res_model">account.bank.statement</field>
Expand Down
Loading