[IMP] partner_statement: remove "blocked" feature

If someone comes from v17 or older Odoo versions, and they still have "blocked" lines, there are three options for them:

- Develop glue module with another module that contains "blocked" field.
- Don't use this commit.
- Solve the "blocked" lines.

Good luck!
This commit is contained in:
Miquel Raïch
2025-07-25 14:16:02 +02:00
parent b426816b11
commit 693d25345a
12 changed files with 34 additions and 244 deletions

View File

@@ -1,5 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models
from . import report
from . import wizard

View File

@@ -1 +0,0 @@
from . import account_move_line

View File

@@ -1,13 +0,0 @@
from odoo import fields, models
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
# === Misc Information === #
blocked = fields.Boolean(
string="No Follow-up",
default=False,
help="You can check this box to mark this journal item "
"as a litigation with the associated partner",
)

View File

@@ -88,7 +88,7 @@ class ActivityStatement(models.AbstractModel):
) as pc ON pc.credit_move_id = l.id
WHERE l.partner_id IN %(partners)s
AND aa.id not in %(excluded_accounts_ids)s
AND l.date < %(date_start)s AND not l.blocked
AND l.date < %(date_start)s
AND m.state IN ('posted')
AND aa.account_type = %(account_type)s
AND (
@@ -181,7 +181,7 @@ class ActivityStatement(models.AbstractModel):
THEN %(payment_ref)s
ELSE m.ref
END as case_ref,
l.blocked, l.currency_id, l.company_id,
l.currency_id, l.company_id,
sum(CASE WHEN (l.currency_id is not null AND l.amount_currency > 0.0)
THEN l.amount_currency
ELSE l.debit
@@ -213,7 +213,7 @@ class ActivityStatement(models.AbstractModel):
CASE WHEN (aj.type IN ('sale', 'purchase'))
THEN l.name
ELSE '/'
END, case_ref, l.blocked, l.currency_id, l.company_id
END, case_ref, l.currency_id, l.company_id
""",
locals(),
),
@@ -226,7 +226,7 @@ class ActivityStatement(models.AbstractModel):
f"""
SELECT {sub}.partner_id, {sub}.move_id, {sub}.date, {sub}.date_maturity,
{sub}.name, {sub}.case_ref as ref, {sub}.debit, {sub}.credit, {sub}.ids,
{sub}.debit-{sub}.credit as amount, {sub}.blocked,
{sub}.debit-{sub}.credit as amount,
COALESCE({sub}.currency_id, c.currency_id) AS currency_id
FROM {sub}
JOIN res_company c ON (c.id = {sub}.company_id)
@@ -250,7 +250,7 @@ class ActivityStatement(models.AbstractModel):
Q2 AS ({})
SELECT partner_id, move_id, date, date_maturity, ids,
COALESCE(name, '') as name, COALESCE(ref, '') as ref,
debit, credit, amount, blocked, currency_id
debit, credit, amount, currency_id
FROM Q2
ORDER BY date, date_maturity, move_id""".format(
self._display_activity_lines_sql_q1(
@@ -280,7 +280,7 @@ class ActivityStatement(models.AbstractModel):
self._cr.mogrify(
f"""
SELECT l.id as rel_id, m.name AS move_id, l.partner_id, l.date, l.name,
l.blocked, l.currency_id, l.company_id, {sub}.id,
l.currency_id, l.company_id, {sub}.id,
CASE WHEN l.ref IS NOT NULL
THEN l.ref
ELSE m.ref
@@ -319,7 +319,7 @@ class ActivityStatement(models.AbstractModel):
THEN l.ref
ELSE m.ref
END, {sub}.id,
l.blocked, l.currency_id, l.balance, l.amount_currency, l.company_id
l.currency_id, l.balance, l.amount_currency, l.company_id
""",
locals(),
),
@@ -342,7 +342,7 @@ class ActivityStatement(models.AbstractModel):
Q6 AS ({})
SELECT partner_id, currency_id, move_id, date, date_maturity, debit,
credit, amount, open_amount, COALESCE(name, '') as name,
COALESCE(ref, '') as ref, blocked, id
COALESCE(ref, '') as ref, id
FROM Q6
ORDER BY date, date_maturity, move_id""".format(
self._display_activity_lines_sql_q1(

View File

@@ -105,16 +105,10 @@ class ActivityStatementXslx(models.AbstractModel):
]
def _get_currency_line_row_data(self, partner, currency, data, line):
if line.get("blocked"):
format_tcell_left = FORMATS["format_tcell_left_blocked"]
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
format_distributed = FORMATS["format_distributed_blocked"]
current_money_format = FORMATS["current_money_format_blocked"]
else:
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
format_distributed = FORMATS["format_distributed"]
current_money_format = FORMATS["current_money_format"]
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
format_distributed = FORMATS["format_distributed"]
current_money_format = FORMATS["current_money_format"]
name_to_show = (
line.get("name", "") == "/" or not line.get("name", "")
) and line.get("ref", "")
@@ -434,23 +428,6 @@ class ActivityStatementXslx(models.AbstractModel):
FORMATS["current_money_format"] = workbook.add_format(
{"align": "right", "num_format": money_string}
)
bg_grey = "#ADB5BD"
FORMATS["format_tcell_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)
FORMATS["format_tcell_left_blocked"].set_bg_color(bg_grey)
FORMATS["format_tcell_date_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_date_left"]
)
FORMATS["format_tcell_date_left_blocked"].set_bg_color(bg_grey)
FORMATS["format_distributed_blocked"] = copy_format(
workbook, FORMATS["format_distributed"]
)
FORMATS["format_distributed_blocked"].set_bg_color(bg_grey)
FORMATS["current_money_format_blocked"] = copy_format(
workbook, FORMATS["current_money_format"]
)
FORMATS["current_money_format_blocked"].set_bg_color(bg_grey)
row_pos = self._write_currency_lines(
row_pos, sheet, partner, currency, data
)

View File

@@ -64,36 +64,12 @@ class DetailedActivityStatementXslx(models.AbstractModel):
]
def _get_currency_line_row_data(self, partner, currency, data, line):
if line.get("blocked") and not line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_blocked"]
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
format_distributed = FORMATS["format_distributed_blocked"]
current_money_format = FORMATS["current_money_format_blocked"]
elif (
line.get("reconciled_line")
and not line.get("blocked")
and not line.get("outside-date-rank")
):
if line.get("reconciled_line") and not line.get("outside-date-rank"):
format_tcell_left = FORMATS["format_tcell_left_reconciled"]
format_tcell_date_left = FORMATS["format_tcell_date_left_reconciled"]
format_distributed = FORMATS["format_distributed_reconciled"]
current_money_format = FORMATS["current_money_format_reconciled"]
elif (
line.get("blocked")
and line.get("reconciled_line")
and not line.get("outside-date-rank")
):
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_blocked_reconciled"
]
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
current_money_format = FORMATS["current_money_format_blocked_reconciled"]
elif (
line.get("reconciled_line")
and not line.get("blocked")
and line.get("outside-date-rank")
):
elif line.get("reconciled_line") and line.get("outside-date-rank"):
format_tcell_left = FORMATS[
"format_tcell_left_reconciled_outside-date-rank"
]
@@ -106,23 +82,6 @@ class DetailedActivityStatementXslx(models.AbstractModel):
current_money_format = FORMATS[
"current_money_format_reconciled_outside-date-rank"
]
elif (
line.get("blocked")
and line.get("reconciled_line")
and line.get("outside-date-rank")
):
format_tcell_left = FORMATS[
"format_tcell_left_blocked_reconciled_outside-date-rank"
]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_blocked_reconciled_outside-date-rank"
]
format_distributed = FORMATS[
"format_distributed_blocked_reconciled_outside-date-rank"
]
current_money_format = FORMATS[
"current_money_format_blocked_reconciled_outside-date-rank"
]
else:
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
@@ -242,23 +201,11 @@ class DetailedActivityStatementXslx(models.AbstractModel):
]
def _get_currency_prior_line_row_data(self, partner, currency, data, line):
if line.get("blocked") and not line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_blocked"]
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
format_distributed = FORMATS["format_distributed_blocked"]
current_money_format = FORMATS["current_money_format_blocked"]
elif line.get("reconciled_line") and not line.get("blocked"):
if line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_reconciled"]
format_tcell_date_left = FORMATS["format_tcell_date_left_reconciled"]
format_distributed = FORMATS["format_distributed_reconciled"]
current_money_format = FORMATS["current_money_format_reconciled"]
elif line.get("blocked") and line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_blocked_reconciled"
]
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
current_money_format = FORMATS["current_money_format_blocked_reconciled"]
else:
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
@@ -396,23 +343,11 @@ class DetailedActivityStatementXslx(models.AbstractModel):
]
def _get_currency_ending_line_row_data(self, partner, currency, data, line):
if line.get("blocked") and not line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_blocked"]
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
format_distributed = FORMATS["format_distributed_blocked"]
current_money_format = FORMATS["current_money_format_blocked"]
elif line.get("reconciled_line") and not line.get("blocked"):
if line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_reconciled"]
format_tcell_date_left = FORMATS["format_tcell_date_left_reconciled"]
format_distributed = FORMATS["format_distributed_reconciled"]
current_money_format = FORMATS["current_money_format_reconciled"]
elif line.get("blocked") and line.get("reconciled_line"):
format_tcell_left = FORMATS["format_tcell_left_blocked_reconciled"]
format_tcell_date_left = FORMATS[
"format_tcell_date_left_blocked_reconciled"
]
format_distributed = FORMATS["format_distributed_blocked_reconciled"]
current_money_format = FORMATS["current_money_format_blocked_reconciled"]
else:
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
@@ -639,24 +574,7 @@ class DetailedActivityStatementXslx(models.AbstractModel):
FORMATS["current_money_format"] = workbook.add_format(
{"align": "right", "num_format": money_string}
)
bg_grey = "#ADB5BD"
fc_red = "#DC3545"
FORMATS["format_tcell_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)
FORMATS["format_tcell_left_blocked"].set_bg_color(bg_grey)
FORMATS["format_tcell_date_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_date_left"]
)
FORMATS["format_tcell_date_left_blocked"].set_bg_color(bg_grey)
FORMATS["format_distributed_blocked"] = copy_format(
workbook, FORMATS["format_distributed"]
)
FORMATS["format_distributed_blocked"].set_bg_color(bg_grey)
FORMATS["current_money_format_blocked"] = copy_format(
workbook, FORMATS["current_money_format"]
)
FORMATS["current_money_format_blocked"].set_bg_color(bg_grey)
FORMATS["format_tcell_left_reconciled"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)
@@ -678,24 +596,6 @@ class DetailedActivityStatementXslx(models.AbstractModel):
)
FORMATS["current_money_format_reconciled"].set_italic(True)
FORMATS["current_money_format_reconciled"].set_font_size(10)
FORMATS["format_tcell_left_blocked_reconciled"] = copy_format(
workbook, FORMATS["format_tcell_left_reconciled"]
)
FORMATS["format_tcell_left_blocked_reconciled"].set_bg_color(bg_grey)
FORMATS["format_tcell_date_left_blocked_reconciled"] = copy_format(
workbook, FORMATS["format_tcell_date_left_reconciled"]
)
FORMATS["format_tcell_date_left_blocked_reconciled"].set_bg_color(
bg_grey
)
FORMATS["format_distributed_blocked_reconciled"] = copy_format(
workbook, FORMATS["format_distributed_reconciled"]
)
FORMATS["format_distributed_blocked_reconciled"].set_bg_color(bg_grey)
FORMATS["current_money_format_blocked_reconciled"] = copy_format(
workbook, FORMATS["current_money_format_reconciled"]
)
FORMATS["current_money_format_blocked_reconciled"].set_bg_color(bg_grey)
FORMATS["format_tcell_left_reconciled_outside-date-rank"] = copy_format(
workbook, FORMATS["format_tcell_left_reconciled"]
)
@@ -720,38 +620,6 @@ class DetailedActivityStatementXslx(models.AbstractModel):
FORMATS[
"current_money_format_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS["format_tcell_left_blocked_reconciled_outside-date-rank"] = (
copy_format(
workbook, FORMATS["format_tcell_left_blocked_reconciled"]
)
)
FORMATS[
"format_tcell_left_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS[
"format_tcell_date_left_blocked_reconciled_outside-date-rank"
] = copy_format(
workbook, FORMATS["format_tcell_date_left_blocked_reconciled"]
)
FORMATS[
"format_tcell_date_left_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS["format_distributed_blocked_reconciled_outside-date-rank"] = (
copy_format(
workbook, FORMATS["format_distributed_blocked_reconciled"]
)
)
FORMATS[
"format_distributed_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
FORMATS["current_money_format_blocked_reconciled_outside-date-rank"] = (
copy_format(
workbook, FORMATS["current_money_format_blocked_reconciled"]
)
)
FORMATS[
"current_money_format_blocked_reconciled_outside-date-rank"
].set_font_color(fc_red)
row_pos = self._write_currency_prior_lines(
row_pos, sheet, partner, currency, data
)

View File

@@ -34,7 +34,7 @@ class OutstandingStatement(models.AbstractModel):
self._cr.mogrify(
"""
SELECT l.id, m.name AS move_id, l.partner_id, l.date, l.name,
l.blocked, l.currency_id, l.company_id,
l.currency_id, l.company_id,
CASE WHEN l.ref IS NOT NULL
THEN l.ref
ELSE m.ref
@@ -94,7 +94,7 @@ class OutstandingStatement(models.AbstractModel):
THEN l.ref
ELSE m.ref
END,
l.blocked, l.currency_id, l.balance, l.amount_currency, l.company_id
l.currency_id, l.balance, l.amount_currency, l.company_id
""",
locals(),
),
@@ -107,7 +107,7 @@ class OutstandingStatement(models.AbstractModel):
f"""
SELECT {sub}.partner_id, {sub}.currency_id, {sub}.move_id,
{sub}.date, {sub}.date_maturity, {sub}.debit, {sub}.credit,
{sub}.name, {sub}.ref, {sub}.blocked, {sub}.company_id,
{sub}.name, {sub}.ref, {sub}.company_id,
CASE WHEN {sub}.currency_id is not null
THEN {sub}.open_amount_currency
ELSE {sub}.open_amount
@@ -127,7 +127,7 @@ class OutstandingStatement(models.AbstractModel):
{sub}.date_maturity, {sub}.name, {sub}.ref, {sub}.debit,
{sub}.credit, {sub}.debit-{sub}.credit AS amount,
COALESCE({sub}.currency_id, c.currency_id) AS currency_id,
{sub}.open_amount, {sub}.blocked, {sub}.id
{sub}.open_amount, {sub}.id
FROM {sub}
JOIN res_company c ON (c.id = {sub}.company_id)
WHERE c.id = %(company_id)s AND {sub}.open_amount != 0.0
@@ -150,7 +150,7 @@ class OutstandingStatement(models.AbstractModel):
Q3 AS ({})
SELECT partner_id, currency_id, move_id, date, date_maturity, debit,
credit, amount, open_amount, COALESCE(name, '') as name,
COALESCE(ref, '') as ref, blocked, id
COALESCE(ref, '') as ref, id
FROM Q3
ORDER BY date, date_maturity, move_id""".format(
self._display_outstanding_lines_sql_q1(

View File

@@ -54,16 +54,10 @@ class OutstandingStatementXslx(models.AbstractModel):
]
def _get_currency_line_row_data(self, partner, currency, data, line):
if line.get("blocked"):
format_tcell_left = FORMATS["format_tcell_left_blocked"]
format_tcell_date_left = FORMATS["format_tcell_date_left_blocked"]
format_distributed = FORMATS["format_distributed_blocked"]
current_money_format = FORMATS["current_money_format_blocked"]
else:
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
format_distributed = FORMATS["format_distributed"]
current_money_format = FORMATS["current_money_format"]
format_tcell_left = FORMATS["format_tcell_left"]
format_tcell_date_left = FORMATS["format_tcell_date_left"]
format_distributed = FORMATS["format_distributed"]
current_money_format = FORMATS["current_money_format"]
name_to_show = (
line.get("name", "") == "/" or not line.get("name", "")
) and line.get("ref", "")
@@ -352,23 +346,6 @@ class OutstandingStatementXslx(models.AbstractModel):
FORMATS["current_money_format"] = workbook.add_format(
{"align": "right", "num_format": money_string}
)
bg_grey = "#ADB5BD"
FORMATS["format_tcell_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_left"]
)
FORMATS["format_tcell_left_blocked"].set_bg_color(bg_grey)
FORMATS["format_tcell_date_left_blocked"] = copy_format(
workbook, FORMATS["format_tcell_date_left"]
)
FORMATS["format_tcell_date_left_blocked"].set_bg_color(bg_grey)
FORMATS["format_distributed_blocked"] = copy_format(
workbook, FORMATS["format_distributed"]
)
FORMATS["format_distributed_blocked"].set_bg_color(bg_grey)
FORMATS["current_money_format_blocked"] = copy_format(
workbook, FORMATS["current_money_format"]
)
FORMATS["current_money_format_blocked"].set_bg_color(bg_grey)
row_pos = self._write_currency_lines(
row_pos, sheet, partner, currency, data
)

View File

@@ -102,7 +102,7 @@ class ReportStatementCommon(models.AbstractModel):
(pc.id IS NOT NULL AND
pc.max_date <= %(date_end)s) OR
(pd.id IS NULL AND pc.id IS NULL)
) AND l.date <= %(date_end)s AND not l.blocked
) AND l.date <= %(date_end)s
AND m.state IN ('posted')
AND aa.account_type = %(account_type)s
AND CASE
@@ -473,8 +473,7 @@ class ReportStatementCommon(models.AbstractModel):
line["currency_id"], currencies, 0.0, 0.0
)
line_currency = currency_dict[line["currency_id"]]
if not line["blocked"]:
line_currency["amount_due"] += line["open_amount"]
line_currency["amount_due"] += line["open_amount"]
line["balance"] = line_currency["amount_due"]
line["date"] = format_date(
line["date"], date_formats.get(partner_id, default_fmt)
@@ -496,12 +495,10 @@ class ReportStatementCommon(models.AbstractModel):
)
line_currency = currency_dict[line["currency_id"]]
if not is_activity:
if not line["blocked"]:
line_currency["amount_due"] += line[amount_field]
line_currency["amount_due"] += line[amount_field]
line["balance"] = line_currency["amount_due"]
else:
if not line["blocked"]:
line_currency["ending_balance"] += line[amount_field]
line_currency["ending_balance"] += line[amount_field]
line["balance"] = line_currency["ending_balance"]
line["outside-date-rank"] = False
line["date"] = format_date(
@@ -523,8 +520,7 @@ class ReportStatementCommon(models.AbstractModel):
line2["applied_amount"] = line2["open_amount"]
if line2["date"] >= date_start and line2["date"] <= date_end:
line2["outside-date-rank"] = False
if not line2["blocked"]:
line["applied_amount"] += line2["open_amount"]
line["applied_amount"] += line2["open_amount"]
else:
line2["outside-date-rank"] = True
line2["date"] = format_date(
@@ -542,8 +538,7 @@ class ReportStatementCommon(models.AbstractModel):
)
if is_activity:
line["open_amount"] = line["amount"] + line["applied_amount"]
if not line["blocked"]:
line_currency["amount_due"] += line["open_amount"]
line_currency["amount_due"] += line["open_amount"]
if is_detailed:
for line_currency in currency_dict.values():
@@ -551,8 +546,7 @@ class ReportStatementCommon(models.AbstractModel):
for line in ending_lines.get(partner_id, []):
line_currency = currency_dict[line["currency_id"]]
if not line["blocked"]:
line_currency["amount_due"] += line["open_amount"]
line_currency["amount_due"] += line["open_amount"]
line["balance"] = line_currency["amount_due"]
line["date"] = format_date(
line["date"], date_formats.get(partner_id, default_fmt)

View File

@@ -14,13 +14,6 @@
}
}
.statement-blocked {
background-color: $gray-500 !important;
td:last-child {
background-color: $gray-500 !important;
}
}
.statement-reconciled {
font-size: smaller;
font-style: italic !important;

View File

@@ -37,7 +37,7 @@
<tr
t-foreach="currency['lines']"
t-as="line"
t-att-class="('statement-blocked ' if line['blocked'] else '') + ('statement-reconciled ' if line['reconciled_line'] else '') + ('statement-outside-date-rank' if line['outside-date-rank'] else '')"
t-att-class="('statement-reconciled ' if line['reconciled_line'] else '') + ('statement-outside-date-rank' if line['outside-date-rank'] else '')"
>
<td>
<span

View File

@@ -21,11 +21,7 @@
</tr>
</thead>
<tbody>
<tr
t-foreach="currency[line_type]"
t-as="line"
t-att-class="'statement-blocked' if line['blocked'] else ''"
>
<tr t-foreach="currency[line_type]" t-as="line" t-att-class="''">
<td>
<span t-out="line['move_id']" />
</td>