从odoo 7.0迁移到odoo 13.0

2024-04-29 19:39:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我在odoo 7.0中定义了一个函数,如下所示

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

我只想了解13版本与7版本相比的cr、uid和其他参数。 我能理解它也必须是python 3.6版本。 有人能用好的文档向我简要介绍一下这个场景中的差异吗? 我也遵循了odoo文档,它似乎让我感到困惑。 另外,请将函数转换为示例,同时解释将更有帮助。谢谢


Tags: andiddatadatestatusrecordquerystart
3条回答

cr、uid和上下文,其中“移动”为self.env的字段(它们现在在self.env.cr、self.env.uid中可用)。因此,在迁移过程中,您只需删除参数,如果正在使用它们,则使用self.env.*

当我将一个odoo实例从版本7迁移到版本9时,我使用了Raphael Collet的以下幻灯片:

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

这些解释了“旧”和“新”api之间的区别。我认为在v13中,它们将几乎相等。请注意,我签出的最后一个版本是v10,因此我还没有更新到足以讨论v13的版本

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

您可以使用OCA/maintainer工具的wiki。它有v7到v8、v8到v9、…、v12到v13等的迁移文档

相关问题 更多 >