Skip to content

Commit e5159df

Browse files
[16.0][ADD] account_liquidity_forecast_sale
1 parent d5900ff commit e5159df

File tree

15 files changed

+876
-0
lines changed

15 files changed

+876
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
===============================
2+
Account Liquidity Forecast Sale
3+
===============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:32303c30dc7d9ce2c82299004c2f99409472e2163d9b65b72098273c9a5c047a
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
20+
:target: https://github.com/OCA/account-financial-reporting/tree/16.0/account_liquidity_forecast_sale
21+
:alt: OCA/account-financial-reporting
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/account-financial-reporting-16-0/account-financial-reporting-16-0-account_liquidity_forecast_sale
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module extends the functionality of account_liquidity_forecast by enabling the option
32+
of adding the Requests for Quotation on the report. The report uses Date Order (date_order)
33+
field on the Request for Quotation.
34+
35+
To launch the report wizard, navigate to Accounting/Invoicing > Reporting > Liquidity Forecast.
36+
A configuration wizard will open, allowing you to define the parameters for the report.
37+
38+
This module adds a new option:
39+
40+
- Select "Include draft SO": If checked, the report will include draft Sale Orders.
41+
42+
**Table of contents**
43+
44+
.. contents::
45+
:local:
46+
47+
Bug Tracker
48+
===========
49+
50+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
51+
In case of trouble, please check there if your issue has already been reported.
52+
If you spotted it first, help us to smash it by providing a detailed and welcomed
53+
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_liquidity_forecast_sale%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
54+
55+
Do not contact contributors directly about support or help with technical issues.
56+
57+
Credits
58+
=======
59+
60+
Authors
61+
~~~~~~~
62+
63+
* ForgeFlow
64+
65+
Contributors
66+
~~~~~~~~~~~~
67+
68+
* `ForgeFlow <https://www.forgeflow.com>`__:
69+
70+
* Mateu Griful
71+
72+
Maintainers
73+
~~~~~~~~~~~
74+
75+
This module is maintained by the OCA.
76+
77+
.. image:: https://odoo-community.org/logo.png
78+
:alt: Odoo Community Association
79+
:target: https://odoo-community.org
80+
81+
OCA, or the Odoo Community Association, is a nonprofit organization whose
82+
mission is to support the collaborative development of Odoo features and
83+
promote its widespread use.
84+
85+
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/16.0/account_liquidity_forecast_sale>`_ project on GitHub.
86+
87+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import report
2+
from . import wizards
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com)
2+
{
3+
"name": "Account Liquidity Forecast Sale",
4+
"version": "16.0.1.0.0",
5+
"category": "Reporting",
6+
"summary": "Account Liquidity Forecast Sale",
7+
"author": "ForgeFlow," "Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/account-financial-reporting",
9+
"depends": ["account_liquidity_forecast", "sale"],
10+
"data": [
11+
"wizards/account_liquidity_forecast_wizard_views.xml",
12+
],
13+
"installable": True,
14+
"application": True,
15+
"auto_install": False,
16+
"license": "AGPL-3",
17+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `ForgeFlow <https://www.forgeflow.com>`__:
2+
3+
* Mateu Griful
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This module extends the functionality of account_liquidity_forecast by enabling the option
2+
of adding the Requests for Quotation on the report. The report uses Date Order (date_order)
3+
field on the Request for Quotation.
4+
5+
To launch the report wizard, navigate to Accounting/Invoicing > Reporting > Liquidity Forecast.
6+
A configuration wizard will open, allowing you to define the parameters for the report.
7+
8+
This module adds a new option:
9+
10+
- Select "Include draft SO": If checked, the report will include draft Sale Orders.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import liquidity_forecast
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import _, models
5+
6+
7+
class LiquidityForecastReport(models.AbstractModel):
8+
_inherit = "report.account_liquidity_forecast.liquidity_forecast"
9+
10+
def _prepare_liquidity_forecast_lines_period(
11+
self, data, liquidity_forecast_lines, period, periods
12+
):
13+
res = super()._prepare_liquidity_forecast_lines_period(
14+
data, liquidity_forecast_lines, period, periods
15+
)
16+
include_so_draft = data.get("include_so_draft", False)
17+
if include_so_draft:
18+
self._prepare_cash_flow_lines_sale_draft(
19+
data, liquidity_forecast_lines, period, periods
20+
)
21+
return res
22+
23+
def _prepare_cash_flow_lines_sale_draft(
24+
self, data, liquidity_forecast_lines, period, periods
25+
):
26+
domain = self.get_so_domain(period)
27+
28+
draft_sale_orders = self.env["sale.order"].search(domain)
29+
if not draft_sale_orders:
30+
return
31+
32+
sale_lines = draft_sale_orders.mapped("order_line")
33+
if not sale_lines:
34+
return
35+
36+
code = "cash_flow_line_out_sale_draft"
37+
existing_lines = [
38+
line for line in liquidity_forecast_lines if line["code"] == code
39+
]
40+
41+
if existing_lines:
42+
flow_line = existing_lines[0]
43+
else:
44+
flow_line = {
45+
"code": code,
46+
"type": "amount",
47+
"level": "detail",
48+
"model": "sale.order.line",
49+
"title": _("Draft Sale Orders"),
50+
"sequence": 3500,
51+
"periods": {
52+
p["sequence"]: {"amount": 0.0, "domain": []} for p in periods
53+
},
54+
}
55+
liquidity_forecast_lines.append(flow_line)
56+
57+
total = sum(sale_line.price_subtotal for sale_line in sale_lines)
58+
flow_line["periods"][period["sequence"]]["amount"] += total
59+
flow_line["periods"][period["sequence"]]["domain"] = [
60+
("id", "in", sale_lines.ids)
61+
]
62+
63+
def get_so_domain(self, period):
64+
domain = [
65+
("state", "in", ["draft", "sent"]),
66+
("date_order", "<=", period["date_to"]),
67+
]
68+
if period["sequence"] > 0:
69+
domain.append(("date_order", ">=", period["date_from"]))
70+
return domain

0 commit comments

Comments
 (0)