This question has been flagged
1 Reply
8205 Views

guys,

I am newer to odoo development. i seen here py is totally different to me what i seen in py tutorials 

I looking via code to understand py in odoo

I got this code in reporting.

someone explain the below code :


def check_report(self, cr, uid, ids, context=None):

        if context is None:

            context = {}

         data = self.read(cr, uid, ids, context=context)[0]     

         datas = {

                 'ids': context.get('active_ids',[]),

                 'model': 'account.budget.classification',

                 'form': data

         }

         datas['form']['report']='analytic-full'

         return {    

             'type': 'ir.actions.report.xml',

             'report_name': 'account.budget',

             'datas': datas,

         }



and also please give any material to odoo py language. 

Avatar
Discard
Best Answer

Hello ram,

Here is explanation of your code.

def check_report(self, cr, uid, ids, context=None):

whenever report is generated records in report will send ids to this function

1) self is current model object

2) cr: database cursor object(You can use it to CURD operations in DB)

3) uid: current active user id

4) ids: current modules record ids which is being used to generate report.

5) context: record set(Record Data)


SO when ever report is generated record is passed to this function and using "read()" ORM method it will fetch particular record data of all fields which are exist in your db table for particular model.

and at last it will get response in "data" variable which will passed to your xml template file to render your response.


Let me know if you need additional detail.


Thanks & Regards,

Siddharth Gajjar


Avatar
Discard