我在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文档,这似乎把我搞糊涂了。另外,请转换函数作为示例,同时解释将更多的helpful.Thanks
发布于 2020-06-12 17:15:20
当我将一个odoo实例从版本7迁移到版本9时,我使用了Raphael Collet的这些幻灯片:
https://www.slideshare.net/openobject/odoo-from-v7-to-v8-the-new-api
这些解释了“旧的”和“新的”api之间的区别,我认为它们在v13中几乎是一样的。请注意,我检查的最后一个版本是v10,所以我不是很了解v13的最新情况。
发布于 2020-06-12 14:43:09
cr,uid和context,其中"moved“是self.env的一个字段(它们现在在self.env.cr,self.env.uid中可用)。因此,在迁移过程中,您只需删除参数,如果您正在使用这些参数,请使用self.env.*。
发布于 2020-06-12 17:36:44
https://github.com/OCA/maintainer-tools/wiki
您可以使用OCA/maintainer-tools的wiki。它有v7到v8,v8到v9,...,v12到v13等的迁移文档。
https://stackoverflow.com/questions/62336532
复制相似问题