Merge lp:~akretion-team/openobject-addons/hr-expense-small-improvements into lp:openobject-addons
Status: | Needs review |
---|---|
Proposed branch: | lp:~akretion-team/openobject-addons/hr-expense-small-improvements |
Merge into: | lp:openobject-addons |
Diff against target: |
143 lines (+34/-16) (has conflicts) 2 files modified
hr_expense/hr_expense.py (+27/-10) hr_expense/hr_expense_view.xml (+7/-6) Text conflict in hr_expense/hr_expense.py |
To merge this branch: | bzr merge lp:~akretion-team/openobject-addons/hr-expense-small-improvements |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Dony (Odoo) | Needs Information | ||
Review via email: mp+93440@code.launchpad.net |
Description of the change
This merge proposal contains a number of small usability and technical improvements in hr_expense. These improvements are all generic and have been implemented following my experience the use of hr_expense on a day-to-day basis at Anevia :
1. Usability improvement : Add 'total_amount' field in the form view of the expense lines, so that the employee has a better control when entering his expense note.
2. Usability improvement : Some fields of hr_expense_expense should always be read-only (date_valid, date_confirm, user_valid, ...) Other fields should be readonly when state != draft (currency_id, employee_id, ...). Some fields should be readonly only when state = invoice or paid (journal_id)
3. Technical improvement : function fields are stored, with the appropriate invalid functions, to get better performances.
I hope that this merge proposal will be accepted in trunk. Don't hesitate to ask me any question about this proposal.
Unmerged revisions
- 6606. By Alexis de Lattre
-
Clean-up my previous commit.
- 6605. By Alexis de Lattre
-
Merge with up-to-date addons-trunk revno 8422 and update to code accordingly.
Take into account the remarks of Olivier Dony :
- select=True are back (I though it was useless)
- remove the store for the "amount" field of expense (keep it only for expense lines, because the store is very simple for expense lines)
Remove field account_move_id, which is not used any more. - 6604. By Alexis de Lattre
-
[Usability] Add 'total_amount' field in the form view of the expense lines, so that the employee has a better control when entering his expense note.
Add the related on_change code. - 6603. By Alexis de Lattre
-
total_amount on hr.expense.line is now a stored field.
- 6602. By Alexis de Lattre
-
Journal field should be writable until the expense is invoiced.
- 6601. By Alexis de Lattre
-
'amount' field of hr.expense.expense is now store=True with invalidate function, for better performances.
- 6600. By Alexis de Lattre
-
Some fields of hr_expense_expense should always be read-only (date_valid, date_confirm, user_valid, ...)
Some fields should be readonly when state != draft (currency_id, employee_id, ...)
Remove useless Select=True
Coding style fixes
Hi Alexis,
Thanks for submitting your patch, and sorry for the review delay. I'm a bit surprised no-one from the community had a look at it yet though (we'll try to do something about that, will post about it later)
The changes concerning the readonly state of the fields look good, but I have a few questions about the rest:
- Is there any particular performance problem that triggered the need to store the function fields? In general it is better to avoid storing function fields that require complex store triggers, especially if they're not critical for searching and do not represent an identified performance issue. The main reason for this being to avoid bugs and keep the code smaller and simpler (that store "plumbing" is dull and requires extra boilerplate functions in case of complex triggers).
- Why did you drop all the "select=True" attributes of the fields? This attribute is still used to tell the ORM to create an index on the column, so they're actually very useful most of the time. Any specific reason?
+ Note: you might want to have a look at openerp. tools.float_ utils.float_ round() in order to properly round the total_amount that is returned by your on_change. See how it's used [1][2].
Wrapping up, it seems to me that if you keep the "select=True" attributes and remove all the storing plumbing, your patch will stay nice, minimalist and less risky, not even altering the database schema (which is best if you'd like to see it included in 7.0)
Thanks!
PS: you'll probably get a few conflicts if you update your branch with trunk, due to the way most views where changed for v7, but if it's annoying the few changes you have should be easy to reapply on top of the new code, discarding the conflicts.
[1] example use in account: http:// bazaar. launchpad. net/~openerp/ openobject- addons/ trunk/view/ head:/account/ account. py#L2092 bazaar. launchpad. net/~openerp/ openobject- server/ trunk/view/ head:/openerp/ tools/float_ utils.py# L32
[2] reference: http://