Comments (13)
@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.
from account-budgeting.
@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.
from account-budgeting.
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.
- Find the well known mis.report.instance that has the budget calculation, and in that one, find the well known column (mis.report.instance.period) that has the available values => lets name it's id
period_available_id
. - Find the KPI for which you want the available budget, using
get_kpis_by_account_id()
, and find the one that has thebudgetable
flag set. There should be only one, otherwise there is an ambiguity in your budget. Lets call itbudgetable_kpi
- Use
_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.
from account-budgeting.
@sbidoul the discussion moved here, the module can be here or in https://github.com/OCA/mis-builder-contrib ?
from account-budgeting.
@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?
from account-budgeting.
@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
}
from account-budgeting.
Got this, def _add_column_actuals_alt()
from account-budgeting.
Hm, indeed evaluate
is the simplified api. I need to dig a little bit to give you an example. No time today, though.
from account-budgeting.
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,
)
from account-budgeting.
@sbidoul
As I try to dig into the code, a little more progress, it is quite complex for me.
Am I correct that,
- evaluate() is only used to get account.move.line and alternate move.line values
- For budget item, we may need to use self.env['mis.budget.item']._query_kpi_data() to get the amount.
To get the available amount (sum column) we can get from combine the two.
from account-budgeting.
@sbidoul Thank you so much for taking your valuable time to explain. This helps a lot!
Got it about maintainers. I will do that.
from account-budgeting.
@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.
from account-budgeting.
Closed as moved to PR #32
from account-budgeting.
Related Issues (16)
- Migration to version 9.0 HOT 2
- Migration to version 10.0
- Migration to version 11.0
- Migration to version 12.0
- This repository seem to not have gitignore file. HOT 4
- Bug when creating a budget (Button SAVE) HOT 1
- Migration to version 13.0 HOT 1
- [12.0][ADD] budget_control [WIP] HOT 1
- [12.0][ADD] budget activity [TODO]
- Migration to version 14.0
- Blocked access to General Settings and all Settings applications menu's, when installed on Odoo Community 12.0
- Migration to version 15.0 HOT 1
- Migration to version 16.0
- Migration to version 17.0
- Invoicing -> Accounting - where is it ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from account-budgeting.