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

[18.0][MIG] mis_builder_budget: Migration to 18.0 #653

Open
wants to merge 3 commits into
base: 18.0
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^mis_builder/|
^mis_builder_budget/|
^mis_builder_demo/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
Expand Down
11 changes: 6 additions & 5 deletions mis_builder_budget/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ MIS Builder Budget
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmis--builder-lightgray.png?logo=github
:target: https://github.com/OCA/mis-builder/tree/17.0/mis_builder_budget
:target: https://github.com/OCA/mis-builder/tree/18.0/mis_builder_budget
:alt: OCA/mis-builder
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/mis-builder-17-0/mis-builder-17-0-mis_builder_budget
:target: https://translation.odoo-community.org/projects/mis-builder-18-0/mis-builder-18-0-mis_builder_budget
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/mis-builder&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/mis-builder&target_branch=18.0
:alt: Try me on Runboat

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

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

Expand All @@ -229,6 +229,7 @@ Contributors
- Benjamin Willig <[email protected]>
- Artem Kostyuk <[email protected]>
- Dzung Tran <[email protected]>
- Chau Le <[email protected]>

Maintainers
-----------
Expand All @@ -251,6 +252,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbidoul|

This module is part of the `OCA/mis-builder <https://github.com/OCA/mis-builder/tree/17.0/mis_builder_budget>`_ project on GitHub.
This module is part of the `OCA/mis-builder <https://github.com/OCA/mis-builder/tree/18.0/mis_builder_budget>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions mis_builder_budget/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "MIS Builder Budget",
"summary": "Create budgets for MIS reports",
"version": "17.0.1.2.0",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/mis-builder",
Expand All @@ -21,7 +21,7 @@
"security/mis_budget_by_account.xml",
"views/mis_budget_by_account.xml",
],
"installable": False,
"installable": True,
"development_status": "Production/Stable",
"maintainers": ["sbidoul"],
}
4 changes: 2 additions & 2 deletions mis_builder_budget/models/mis_budget_abstract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2017-2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models


class MisBudgetAbstract(models.AbstractModel):
Expand Down Expand Up @@ -31,7 +31,7 @@ def copy(self, default=None):
if default is None:
default = {}
if "name" not in default:
default["name"] = _("%s (copy)") % self.name
default["name"] = self.env._("%s (copy)", self.name)
return super().copy(default=default)

@api.onchange("date_range_id")
Expand Down
18 changes: 11 additions & 7 deletions mis_builder_budget/models/mis_budget_by_account_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ class MisBudgetByAccountItem(models.Model):
store=True,
currency_field="company_currency_id",
)
company_id = fields.Many2one(
"res.company",
related="account_id.company_id",
readonly=True,
store=True,
)
company_id = fields.Many2one("res.company", compute="_compute_company_id")
company_currency_id = fields.Many2one(
"res.currency",
related="account_id.company_id.currency_id",
related="account_id.company_currency_id",
string="Company Currency",
help="Utility field to express amount currency",
store=True,
Expand All @@ -58,6 +53,15 @@ class MisBudgetByAccountItem(models.Model):
),
]

@api.depends_context("company")
@api.depends("account_id")
def _compute_company_id(self):
for rec in self:
if self.env.company in rec.account_id.company_ids:
rec.company_id = self.env.company
else:
rec.company_id = rec.account_id.company_ids[0]

@api.depends("debit", "credit")
def _compute_balance(self):
for rec in self:
Expand Down
10 changes: 6 additions & 4 deletions mis_builder_budget/models/mis_budget_item_abstract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2017-2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -62,12 +62,14 @@ def _check_dates(self):
# date_from <= date_to
if rec.date_from > rec.date_to:
raise ValidationError(
_("%s start date must not be after end date") % (rec.display_name,)
self.env._(
"%s start date must not be after end date", rec.display_name
)
)
# within budget dates
if rec.date_from < rec.budget_date_from or rec.date_to > rec.budget_date_to:
raise ValidationError(
_(
self.env._(
"%(rec_name)s is not within budget %(budget_name)s date range.",
rec_name=rec.display_name,
budget_name=rec.budget_id.display_name,
Expand All @@ -78,7 +80,7 @@ def _check_dates(self):
res = self.search(domain, limit=1)
if res:
raise ValidationError(
_(
self.env._(
"%(rec_name)s overlaps %(res_name)s in budget %(budget_name)s",
rec_name=rec.display_name,
res_name=res.display_name,
Expand Down
13 changes: 7 additions & 6 deletions mis_builder_budget/models/mis_report_kpi_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ class MisReportKpiExpression(models.Model):
_inherit = "mis.report.kpi.expression"

@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
args = args or []
def _search_display_name(self, operator, value):
domain = super()._search_display_name(operator, value)

if "default_budget_id" in self.env.context:
report_id = (
self.env["mis.budget"]
.browse(self.env.context["default_budget_id"])
.report_id.id
)
if report_id:
args += [("kpi_id.report_id", "=", report_id)]
if "." in name:
args += [("subkpi_id.report_id", "=", report_id)]
return super().name_search(name, args, operator, limit)
domain += [("kpi_id.report_id", "=", report_id)]
if "." in value:
domain += [("subkpi_id.report_id", "=", report_id)]
return domain
1 change: 1 addition & 0 deletions mis_builder_budget/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Benjamin Willig \<<[email protected]>\>
- Artem Kostyuk \<<[email protected]>\>
- Dzung Tran \<<[email protected]>\>
- Chau Le \<<[email protected]>\>
7 changes: 4 additions & 3 deletions mis_builder_budget/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">MIS Builder Budget</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b49fe673329ce72edaf0467f04f6fe7b06edc9e82a11c22b5a57071407a0521c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mis-builder/tree/17.0/mis_builder_budget"><img alt="OCA/mis-builder" src="https://img.shields.io/badge/github-OCA%2Fmis--builder-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mis-builder-17-0/mis-builder-17-0-mis_builder_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/mis-builder&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mis-builder/tree/18.0/mis_builder_budget"><img alt="OCA/mis-builder" src="https://img.shields.io/badge/github-OCA%2Fmis--builder-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mis-builder-18-0/mis-builder-18-0-mis_builder_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/mis-builder&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Create budgets for MIS reports.</p>
<p>This module lets you create budgets for any MIS report. Several budgets
can be created for a given report template (ie one budget per year).
Expand Down Expand Up @@ -563,7 +563,7 @@ <h1><a class="toc-backref" href="#toc-entry-16">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/mis-builder/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/mis-builder/issues/new?body=module:%20mis_builder_budget%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/mis-builder/issues/new?body=module:%20mis_builder_budget%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -582,6 +582,7 @@ <h2><a class="toc-backref" href="#toc-entry-19">Contributors</a></h2>
<li>Benjamin Willig &lt;<a class="reference external" href="mailto:benjamin.willig&#64;acsone.eu">benjamin.willig&#64;acsone.eu</a>&gt;</li>
<li>Artem Kostyuk &lt;<a class="reference external" href="mailto:a.kostyuk&#64;mobilunity.com">a.kostyuk&#64;mobilunity.com</a>&gt;</li>
<li>Dzung Tran &lt;<a class="reference external" href="mailto:dungtd&#64;trobz.com">dungtd&#64;trobz.com</a>&gt;</li>
<li>Chau Le &lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -595,7 +596,7 @@ <h2><a class="toc-backref" href="#toc-entry-20">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/sbidoul"><img alt="sbidoul" src="https://github.com/sbidoul.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mis-builder/tree/17.0/mis_builder_budget">OCA/mis-builder</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mis-builder/tree/18.0/mis_builder_budget">OCA/mis-builder</a> project on GitHub.</p>
<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>
</div>
</div>
Expand Down
16 changes: 7 additions & 9 deletions mis_builder_budget/views/mis_budget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@
<field name="date_to" />
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
<!-- Chatter -->
<chatter />
</form>
</field>
</record>
Expand All @@ -68,23 +66,23 @@
</search>
</field>
</record>
<record model="ir.ui.view" id="mis_budget_tree_view">
<field name="name">mis.budget.tree (in mis_builder_budget)</field>
<record model="ir.ui.view" id="mis_budget_list_view">
<field name="name">mis.budget.list (in mis_builder_budget)</field>
<field name="model">mis.budget</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="report_id" />
<field name="date_from" />
<field name="date_to" />
<field name="state" />
</tree>
</list>
</field>
</record>
<record model="ir.actions.act_window" id="mis_budget_act_window">
<field name="name">MIS Budgets (by KPIs)</field>
<field name="res_model">mis.budget</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
Expand Down
16 changes: 7 additions & 9 deletions mis_builder_budget/views/mis_budget_by_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@
<field name="allow_items_overlap" />
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
<!-- Chatter -->
<chatter />
</form>
</field>
</record>
Expand All @@ -72,22 +70,22 @@
</search>
</field>
</record>
<record model="ir.ui.view" id="mis_budget_by_account_tree_view">
<field name="name">mis.budget.by.account.tree (in mis_builder_budget)</field>
<record model="ir.ui.view" id="mis_budget_by_account_list_view">
<field name="name">mis.budget.by.account.list (in mis_builder_budget)</field>
<field name="model">mis.budget.by.account</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="date_from" />
<field name="date_to" />
<field name="state" />
</tree>
</list>
</field>
</record>
<record model="ir.actions.act_window" id="mis_budget_by_account_act_window">
<field name="name">MIS Budgets (by accounts)</field>
<field name="res_model">mis.budget.by.account</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
Expand Down
13 changes: 5 additions & 8 deletions mis_builder_budget/views/mis_budget_by_account_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
</search>
</field>
</record>
<record model="ir.ui.view" id="mis_budget_by_account_item_tree_view">
<record model="ir.ui.view" id="mis_budget_by_account_item_list_view">
<field name="name">
mis.budget.by.account.item.tree (in mis_builder_budget)
mis.budget.by.account.item.list (in mis_builder_budget)
</field>
<field name="model">mis.budget.by.account.item</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="budget_id" column_invisible="1" />
<field name="budget_date_from" column_invisible="1" />
<field name="budget_date_to" column_invisible="1" />
<list editable="bottom">
<field name="name" />
<field name="account_id" />
<field
Expand All @@ -38,13 +35,13 @@
<field name="debit" />
<field name="credit" />
<field name="balance" />
</tree>
</list>
</field>
</record>
<record model="ir.actions.act_window" id="mis_budget_by_account_item_act_window">
<field name="name">MIS Budget Items (by accounts)</field>
<field name="res_model">mis.budget.by.account.item</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="domain">[('budget_id', '=', active_id)]</field>
<field name="context">{'default_budget_id': active_id}</field>
</record>
Expand Down
14 changes: 5 additions & 9 deletions mis_builder_budget/views/mis_budget_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,23 @@
</search>
</field>
</record>
<record model="ir.ui.view" id="mis_budget_item_tree_view">
<field name="name">mis.budget.item.tree (in mis_builder_budget)</field>
<record model="ir.ui.view" id="mis_budget_item_list_view">
<field name="name">mis.budget.item.list (in mis_builder_budget)</field>
<field name="model">mis.budget.item</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="budget_id" column_invisible="1" />
<field name="report_id" column_invisible="1" />
<field name="budget_date_from" column_invisible="1" />
<field name="budget_date_to" column_invisible="1" />
<list editable="bottom">
<field name="kpi_expression_id" />
<field name="date_range_id" />
<field name="date_from" />
<field name="date_to" />
<field name="amount" />
</tree>
</list>
</field>
</record>
<record model="ir.actions.act_window" id="mis_budget_item_act_window">
<field name="name">MIS Budget Items (by KPIs)</field>
<field name="res_model">mis.budget.item</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="domain">[('budget_id', '=', active_id)]</field>
<field name="context">{'default_budget_id': active_id}</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion mis_builder_budget/views/mis_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field name="inherit_id" ref="mis_builder.mis_report_view_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='kpi_ids']/tree/field[@name='expression']"
expr="//field[@name='kpi_ids']/list/field[@name='expression']"
position="after"
>
<field name="budgetable" />
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
odoo-test-helper
odoo-addon-mis_builder @ git+https://github.com/chaule97/mis-builder.git@refs/pull/1/head#subdirectory=mis_builder
Loading