Skip to content

Commit 3bdd82f

Browse files
committed
[MIG] sale_timesheet_budget : Migration to 19.0.
1 parent c24f61b commit 3bdd82f

6 files changed

Lines changed: 42 additions & 23 deletions

File tree

sale_timesheet_budget/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Sale timesheet budget
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github
24-
:target: https://github.com/OCA/timesheet/tree/18.0/sale_timesheet_budget
24+
:target: https://github.com/OCA/timesheet/tree/19.0/sale_timesheet_budget
2525
:alt: OCA/timesheet
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-sale_timesheet_budget
27+
:target: https://translation.odoo-community.org/projects/timesheet-19-0/timesheet-19-0-sale_timesheet_budget
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -67,7 +67,7 @@ Bug Tracker
6767
Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/issues>`_.
6868
In case of trouble, please check there if your issue has already been reported.
6969
If you spotted it first, help us to smash it by providing a detailed and welcomed
70-
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20sale_timesheet_budget%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
70+
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20sale_timesheet_budget%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7171

7272
Do not contact contributors directly about support or help with technical issues.
7373

@@ -108,6 +108,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
108108

109109
|maintainer-victoralmau|
110110

111-
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/18.0/sale_timesheet_budget>`_ project on GitHub.
111+
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/19.0/sale_timesheet_budget>`_ project on GitHub.
112112

113113
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_timesheet_budget/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
{
44
"name": "Sale timesheet budget",
5-
"version": "18.0.1.0.0",
5+
"version": "19.0.1.0.0",
66
"category": "Timesheet",
77
"website": "https://github.com/OCA/timesheet",
88
"author": "Tecnativa, Odoo Community Association (OCA)",

sale_timesheet_budget/i18n/es.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: Odoo Server 14.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"POT-Creation-Date: 2022-06-27 11:03+0000\n"
10-
"PO-Revision-Date: 2026-05-10 09:27+0000\n"
10+
"PO-Revision-Date: 2026-04-16 21:45+0000\n"
1111
"Last-Translator: Ed-Spain <eduamoros@gmail.com>\n"
1212
"Language-Team: \n"
1313
"Language: es\n"

sale_timesheet_budget/models/project_project.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2022-2024 Tecnativa - Víctor Martínez
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33

4-
from odoo import _lt, api, fields, models
4+
from odoo import api, fields, models
55

66

77
class ProjectProject(models.Model):
@@ -17,12 +17,12 @@ class ProjectProject(models.Model):
1717

1818
@api.depends("budget_ids")
1919
def _compute_budget_amount(self):
20-
data = self.env["project.project.budget"].read_group(
20+
data = self.env["project.project.budget"]._read_group(
2121
domain=[("project_id", "in", self.ids)],
22-
fields=["project_id", "amount:sum"],
2322
groupby=["project_id"],
23+
aggregates=["amount:sum"],
2424
)
25-
mapped_data = {x["project_id"][0]: x["amount"] for x in data}
25+
mapped_data = {project.id: amount_sum for project, amount_sum in data}
2626
for item in self:
2727
item.budget_amount = mapped_data.get(item.id, 0)
2828

@@ -35,18 +35,24 @@ def action_profitability_budget_item(self):
3535

3636
def _get_profitability_labels(self):
3737
res = super()._get_profitability_labels()
38-
res["budgets"] = _lt("Budgets")
38+
res["budgets"] = self.env._("Budgets")
39+
return res
40+
41+
def _get_profitability_sequence_per_invoice_type(self):
42+
res = super()._get_profitability_sequence_per_invoice_type()
43+
res["budgets"] = 8
3944
return res
4045

4146
def _get_profitability_items(self, with_action=True):
4247
items = super()._get_profitability_items(with_action)
4348
if not self.budget_ids:
4449
return items
45-
last_sequence = len(items["revenues"]["data"])
4650
items["revenues"]["data"].append(
4751
{
4852
"id": "budgets",
49-
"sequence": last_sequence + 1,
53+
"sequence": self._get_profitability_sequence_per_invoice_type()[
54+
"budgets"
55+
],
5056
"invoiced": 0,
5157
"to_invoice": self.budget_amount,
5258
"action": {

sale_timesheet_budget/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Sale timesheet budget</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:f87109f6f4372bd1ff932d9dd90bd4c19896fda92a1e729aacd3678eea72c1e1
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/timesheet/tree/18.0/sale_timesheet_budget"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-sale_timesheet_budget"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/timesheet/tree/19.0/sale_timesheet_budget"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/timesheet-19-0/timesheet-19-0-sale_timesheet_budget"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module adds the “Budget” tab to the projects/sales orders to be
379379
able to set some additional lines (incomes/expenses) linked to a planned
380380
budget.</p>
@@ -419,7 +419,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
419419
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/timesheet/issues">GitHub Issues</a>.
420420
In case of trouble, please check there if your issue has already been reported.
421421
If you spotted it first, help us to smash it by providing a detailed and welcomed
422-
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20sale_timesheet_budget%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
422+
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20sale_timesheet_budget%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
423423
<p>Do not contact contributors directly about support or help with technical issues.</p>
424424
</div>
425425
<div class="section" id="credits">
@@ -451,7 +451,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
451451
promote its widespread use.</p>
452452
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
453453
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
454-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/18.0/sale_timesheet_budget">OCA/timesheet</a> project on GitHub.</p>
454+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/19.0/sale_timesheet_budget">OCA/timesheet</a> project on GitHub.</p>
455455
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
456456
</div>
457457
</div>

sale_timesheet_budget/tests/test_sale_timesheet_budget.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ def setUpClass(cls):
1919
"plan_id": cls.plan.id,
2020
}
2121
)
22-
cls.sale_order = cls.env["sale.order"].create(
23-
{
24-
"partner_id": cls.customer.id,
25-
"project_account_id": cls.analytic_account.id,
26-
}
27-
)
2822
cls.project = cls.env["project.project"].create(
2923
{
3024
"name": "Test project",
@@ -33,8 +27,27 @@ def setUpClass(cls):
3327
"allow_billable": True,
3428
}
3529
)
30+
cls.sale_order = cls.env["sale.order"].create(
31+
{
32+
"partner_id": cls.customer.id,
33+
"project_id": cls.project.id,
34+
}
35+
)
3636

3737
def test_project_budget(self):
38+
# Test project without budgets to cover early return in _get_profitability_items
39+
data_no_budget = self.project.get_panel_data()
40+
if "profitability_items" in data_no_budget:
41+
self.assertNotIn(
42+
"budgets",
43+
[
44+
item["id"]
45+
for item in data_no_budget["profitability_items"]["revenues"][
46+
"data"
47+
]
48+
],
49+
)
50+
3851
project_form = Form(self.project)
3952
with project_form.budget_ids.new() as budget_form:
4053
budget_form.sale_order_id = self.sale_order

0 commit comments

Comments
 (0)