How to create custom accounting report

Public Channel / Odoo Experience 2016

By Cedric Snauwaert - Odoo Developer

Share on Social Networks

Share Link

Use permanent link to share in social media

Share with a friend

Please login to send this presentation by email!

Embed in your website

Select page to start with

7. This is the basic interface to implement.

13. Further Customization 3

6. How to create your custom reports 2

11. Also create a report_context . Report contexts are transient models that are instanciated once per report and per user. You need to create a new context model per custom report. Its interface should be:

16. Thank you. #odooexperience EXPERIENCE 2016

1. How to create custom accounting reports Cédric Snauwaert • Senior Software Developer EXPERIENCE 2016

3. Financial Reports Vs Custom Reports 1 Features Comparison

9. @api.model get_lines(self, context_id, line_id=None): ● The order of the list is the order in which the lines will be displayed in the report ● Each line of the list is a dictionary structure with specific keys This method should return the list of lines of the report. The line_id parameter is set when unfolding a line in the report, in this case this method should only return a subset of the lines corresponding to line_id and its domain, nothing else.

2. Financial Reports vs Custom Reports 1 How to create your custom report Further customization Q&A 2 3 4

8. @api.model get_report_type(self): account.report.type has many fields that modify how mechanics of a specific report work. Many account.report.type have already been created in the account_reports module but you can always create more combinations or extend the model to add your own type (this will require more work, see further customization) This method should return an account.report.type object.

12. Last steps ● Change the dictionary methods of the account.report.context.common object ○ _report_name_to_report_model(): Add an item name_of_your_report: name_of_the_model ○ _report_model_to_report_context(): Add an item name_of_the_model: name_of_the_context_model ● Create the client action and menuitem for your report. A few last steps before it is in full working order:

4. Financial Custom ● Very easy to create (XML) ● Ready to use ● Only works with account_move_line ● Only with sums over a period ● More advanced (Python) ● Possibilities are much more open Features Comparison

14. Search view ● Create a new account.report.type , eg. ‘journal_filter’. ● Add fields to your context object that correspond to the filters you want to add. Eg. journal_id = fields.Many2one(‘account.journal’) ● Adapt the get_lines method in your custom report class ● Modify the ‘accountReports.searchView’ template by adding a dropdown for your filter. ● Bind events to your dropdown in the render_searchview_buttons() function of the account_report_generic widget. You can customize the search view of your report and adapt it to fit your needs.

5. Financial Custom ● Profit and Loss ● Balance Sheet ● Cash Summary ● Aged Partner Balances ● Most localizations reports ● Bank Reconciliation ● General Ledger ● Generic Tax Report ● Belgian Partner VAT Listing ● Follow-ups Some examples of reports

10. @api.model get_lines(self, context_id, line_id=None): ● id: id of the line. Referenced for footnote, unfolding, etc. ● name: what will be displayed. ● type: type of the line, this will determine what action is available when clicking on the line. (currently supported: account_id, line, tax_id, unreconciled_aml, bank_statement_id, partner_id, move_line_id, too_many, payment). ● footnotes: {column_number: footnote_id} if there are footnotes for the line. ● unfoldable: True if line can be unfolded. ● unfolded: True if the line has already been unfolded. ● columns: a list of column values. ● level: determine the layout. ● action_id: action that will be triggered when clicking on the line. ● colspan: use this if you want the name to span over many columns. Dictionaries for each line can contain the following informations:

15. Line type To trigger an action, use the ‘o_account_reports_web_action’ class and then : ● Use data-res-model and data-active-id to open the form view of the object. ● Use data-res-model and data-action-domain to open the list view with given domain. ● Use data-action-name to trigger that action. You’ve got the option to add the data-force-context attribute to force the current context to be passed on with the action (only relevant if the action goes to another accounting report). ● Use data-action-id to trigger that action. You can add your own line type and change the way it will appear on the report as well as what actions will be available for that line type. To do that, inherit and modify the ‘account.report_financial_line’ template.

Views

  • 16 Total Views
  • 1 Website Views
  • 15 Embeded Views

Actions

  • 0 Social Shares
  • 0 Likes
  • 0 Dislikes
  • 0 Comments

Share count

  • 0 Facebook
  • 0 Twitter
  • 0 LinkedIn
  • 0 Google+

Embeds 1

  • 5 onlinesync.odoo.com