Closed kittiu closed 4 years ago
@sbidoul the discussion moved here, the module can be here or in https://github.com/OCA/mis-builder-contrib ?
@kittiu I like the idea of logging commitments explicitly. This allows for good traceability and handling of corner cases.
Regarding the repository choice it does not matter much to me. What matter more for me is knowing who is stepping in to care of the maintenance of modules.
@kittiu I like the idea of logging commitments explicitly. This allows for good traceability and handling of corner cases.
Thank you, please come to comment. At this moment, I will try to make use of mis_builder as much. :) would need your support on mis_builder knowledge.
Regarding the repository choice it does not matter much to me. What matter more for me is knowing who is stepping in to care of the maintenance of modules.
I am not sure what you mean by this. We do have PSC/maintainer for this repo, right?
@sbidoul from the evaluate(), I could get kpi's figure form account.move.line, i..e, exp by time period.
How can I get figure from Budget, Commit and Available?
company = self.env.ref('base.main_company')
report = self.env.ref('mis_builder_demo.mis_report_expenses')
aep = report._prepare_aep(company)
r = report.evaluate(
aep,
date_from='2014-01-01',
date_to='2020-12-31',
)
print(r)
{
'sum': <function _sum at 0x7f743688e0d0>,
'min': <function _min at 0x7f7436896a60>,
'max': <function _max at 0x7f7436896ae8>,
'len': <built-in function len>,
'avg': <function _avg at 0x7f74368969d8>,
'time': <module 'time' (built-in)>,
'datetime': <module 'datetime' from '/usr/lib/python3.6/datetime.py'>,
'dateutil': <module 'dateutil' from '/home/kittiu/.virtualenvs/odoo12/lib/python3.6/site-packages/dateutil/__init__.py'>,
'AccountingNone': AccountingNone,
'SimpleArray': <class 'odoo.addons.mis_builder.models.simple_array.SimpleArray_1'>,
'date_from': datetime.date(2014, 1, 1),
'date_to': datetime.date(2020, 12, 31),
'exp': 31591.5,
'equip': AccountingNone,
'other': AccountingNone,
'total': 31591.5
}
Got this, def _add_column_actuals_alt()
Hm, indeed evaluate
is the simplified api. I need to dig a little bit to give you an example. No time today, though.
Thank you, no worry if you are busy. :) I am getting the better result for commitment by adding aml_model and target_move=None.
r = report.evaluate(
aep,
date_from='2014-01-01',
date_to='2020-12-31',
aml_model='purchase.budget.commit',
target_move=None,
)
@sbidoul As I try to dig into the code, a little more progress, it is quite complex for me. Am I correct that,
To get the available amount (sum column) we can get from combine the two.
@kittiu I'll try to answer your questions.
We do have PSC/maintainer for this repo, right?
This repo is part of the Accounting PSC which covers a huge amount of modules.
For such a vast domain one cannot really expect to have the PSC members to do active maintenance on everything. So it's better if some people declare themselves has maintainer on addons they care about and do more active maintenance work. That's the purpose of the maintainer role and the maintainers
key in the manifest.
Regarding computation, I indeed sent you on the wrong track with the evaluate
method, which is too limited for what you want to do.
A better starting point is the compute()
method of mis.report.instance
, which prepares the data for preview, or the lower level ._compute_matrix()
method which gives you a more detailed data structure.
So the geneal algorithm goes as follow.
period_available_id
.get_kpis_by_account_id()
, and find the one that has the budgetable
flag set. There should be only one, otherwise there is an ambiguity in your budget. Lets call it budgetable_kpi
_compute_matrix()
(possibly with a context containing analytic filters) and navigate the matrix to find the value you need with something like this: for row in kpi_matrix.iter_rows():
if row.kpi == budgetable_kpi:
for cell in row.iter_cells():
if cell.subcol.col.key == period_available.id:
return cell.val or 0.0
So yeah, it's a bit complex. OTOH the subject matter is not an easy one either :)
I'm open to discuss a higher level API that would make these kind of calculations easier.
@sbidoul Thank you so much for taking your valuable time to explain. This helps a lot! Got it about maintainers. I will do that.
@sbidoul So far, your recommendation fit into what I try to achieve quite nicely, thanks to mis_builder.
As the check_budget() will be called quite often, i.e., every time a document is validate. I have one concern on _compute_matrix(), as it return the whole result set, which we only need only result of some kpi and some period. I worry about performance
Do you have answer to this yet (i..e, filters)?
Thank you!
Note: I have some good progress, and soon can push the first demo.
Closed as moved to PR https://github.com/OCA/account-budgeting/pull/32
These module is built on top of already great budgeting capability of mis_buider_budget, but add more features to
Remarks: this is based on my experiences doing budget management with an organization, but for this I wanted to make it more lightweight and generic enough for most use. Feedback are greatly appreciated.
Design Goals
Goal 1: Budget Commitment
This one can be quite easy, by adding a new table to log all the commitment, i.e., budget.commit. I am looking into create followings addons one for each type of document.
Goal 2: Budget Control
This part will deal with calling available mis_builder's API to find out available budget, and give warning.
Goal 3: Budgeting with more Analytic Dimensions: (TBD)
N/A
Goal 4: Budget Planning and Budget Revision: (TBD)
For big organization, there will be preparation process, when organization discuss for next year budgeting. Normally it will occur, i.e, 2-3 months ahead of the budget year. Expected procedure can be,