user13416491
user13416491

Reputation:

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

Upvotes: 1

Views: 137

Answers (3)

Pyae
Pyae

Reputation: 519

https://github.com/OCA/maintainer-tools/wiki

You can use wiki of OCA/maintainer-tools. It has migration doc for v7 to v8, v8 to v9, ..., v12 to v13,etc.

Upvotes: 1

JustLudo
JustLudo

Reputation: 1790

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.

Upvotes: 1

bigbear3001
bigbear3001

Reputation: 544

cr, uid and context where "moved" to be a field of self.env (they are now available in self.env.cr, self.env.uid). so in migration you can just delete the parameters and if you are using them use self.env.*.

Upvotes: 1

Related Questions