Search code examples
pythonodoo

Migrate from odoo 7.0 to odoo 13.0


I have a function defined in odoo 7.0 as below.

def x_fnction(self, cr, uid, data, context=None):

    id = data.get('id', False)
    if data:
        charges = []
        in_charge = data['start_date']
        end_date = data['end_date']
        bs_query = """SELECT "End_Date","idcust","ekic","price","Start_Date",id FROM status WHERE ((("End_Date" >= '%s')  OR  "End_Date" IS NULL )  AND  ("Start_Date" <= '%s')  AND  ("id_EK_Customer" = %s)  AND  ("Is_Active" in ('Y','N'))) ORDER BY "Start_Date" """ % (
        start_date, end_date, id)
        cr.execute(bs_query)
        records = cr.dictfetchall()
        if not billing_status_records:
            return []
        total_variable_charges_incl_gst = 0
        for billing_status_record in billing_status_records:
            icp_id = billing_status_record['id_EK_ICP']
            billing_variable_charge = 0
            dbc_query = """SELECT "flow" FROM charges WHERE (("id_bill" = %s)  AND  ("status" = 'B')) ORDER BY "date" desc limit 1""" % (
                billing_status_record['id'])
            cr.execute(dbc_query)
            max_billed_date = cr.fetchone()
            if max_billed_date:
                min_unbilled_charge_read_date = datetime.strptime(max_billed_date[0],
                                                                  '%Y-%m-%d').date() + timedelta(days=1)
            else:
                min_unbilled_charge_read_date = billing_status_record['Start_Date']
            start_date = max(start_date, str(min_unbilled_charge_read_date))


            dbc_query = """select * from some_table
            WHERE ((ec."ekp" = %s)  AND  (ec."date" >= '%s')  AND  (ec."flow" <= '%s')  AND  (ec."enerf" != 'I'))""" % (
            icp_id, start_date, end_date)

            cr.execute(dbc_query)
            daily_billing_charges_data = cr.dictfetchall()


    return data

I just want to understand the cr, uid and other arguments in 13 version when compared with 7 version. I can understand it must be in python 3.6 version too. Can someone brief me the differences in this scenario with good documentation? I followed the odoo documentation as well and it seems confusing me. Also please convert the function as an example while explaining will be more helpful.Thanks


Solution

  • When I migrated an odoo instance from version 7 to version 9 I used these slides by Raphael Collet:

    https://www.slideshare.net/openobject/odoo-from-v7-to-v8-the-new-api

    These explain the differences between the "old" and "new" api's. I think they will be pretty much equal in v13. Note that the last version I checked out was v10 so I'm not up-to-date enough to talk about v13.