diff --git a/budget_control/models/base_budget_move.py b/budget_control/models/base_budget_move.py index c5663b80..665a2c8c 100644 --- a/budget_control/models/base_budget_move.py +++ b/budget_control/models/base_budget_move.py @@ -242,39 +242,43 @@ def _compute_commit(self): def _compute_json_budget_popover(self): FloatConverter = self.env["ir.qweb.field.float"] - # FIXME: How can we do with multi analytic account in 1 line. for rec in self: - # analytic = rec[self._budget_analytic_field] - # if not analytic: - # rec.json_budget_popover = False - # continue - # # Budget Period is required, even a False one - # budget_period = self.env["budget.period"]._get_eligible_budget_period( - # date=rec.date_commit - # ) - # analytic = analytic.with_context(budget_period_ids=[budget_period.id]) + analytic_distribution = rec[self._budget_analytic_field] + analytic_account = rec._convert_analytics( + analytic_distribution=analytic_distribution + ) + if not analytic_account: + rec.json_budget_popover = False + continue + # Budget Period is required, even a False one + budget_period = self.env["budget.period"]._get_eligible_budget_period( + date=rec.date_commit + ) rec.json_budget_popover = dumps( { "title": _("Budget Figure"), "icon": "fa-info-circle", "popoverTemplate": "budget_control.budgetPopOver", - # "analytic": analytic, - "analytic_ids": [1, 2], - "budget": FloatConverter.value_to_html( - 10, {"decimal_precision": "Product Price"} - ), - "consumed": FloatConverter.value_to_html( - 20, {"decimal_precision": "Product Price"} - ), - "balance": FloatConverter.value_to_html( - 30, {"decimal_precision": "Product Price"} - ), - # "consumed": FloatConverter.value_to_html( - # analytic.amount_consumed, {"decimal_precision": "Product Price"} - # ), - # "balance": FloatConverter.value_to_html( - # analytic.amount_balance, {"decimal_precision": "Product Price"} - # ), + "analytic": [ + { + "id": aa.id, + "name": aa.display_name, + "budget": FloatConverter.value_to_html( + aa.amount_budget, {"decimal_precision": "Product Price"} + ), + "consumed": FloatConverter.value_to_html( + aa.amount_consumed, + {"decimal_precision": "Product Price"}, + ), + "balance": FloatConverter.value_to_html( + aa.amount_balance, + {"decimal_precision": "Product Price"}, + ), + } + for aa in analytic_account.with_context( + budget_period_ids=[budget_period.id] + ) + ], } ) diff --git a/budget_control/static/src/xml/budget_popover.xml b/budget_control/static/src/xml/budget_popover.xml index 7dc85fbc..9dfbd9e1 100644 --- a/budget_control/static/src/xml/budget_popover.xml +++ b/budget_control/static/src/xml/budget_popover.xml @@ -1,36 +1,38 @@ -
-

- AA1 -

- - - - - - - - - - - - - - - -
- Planned - - -
- Used - - - -
- Available - - = -
-
+ + +
+ +
+ + + + + + + + + + + + + + + +
+ Planned + + +
+ Used + + - +
+ Available + + = +
+
+