Code review comment for lp:~openerp-community/openobject-addons/lpistone_6.0_lp784499

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hi Leonardo,

Thanks for the bug report and the merge proposal!

There is one thing that could be improved in your patch: instead of using a direct SQL query and having to manually filter on the company, it would be much better to rely on the use of ORM methods, which do perform the appropriate filtering (due to the record rules defined in ir.rules).
This way you don't hardcode the filtering, and you also avoid bypassing the ORM, which is not recommended.

If the initial code had done the same, there would have been no bug, so let's use this opportunity to improve it :-)

E.g:
  account_ids = self.pool.get('account.account').search(cr, uid,[('parent_id', '=', False)], context=context, limit=1)
  return account_ids[0] if account_ids else False

review: Needs Fixing

« Back to merge proposal