Python中文
首页
教程
问答
标签
搜索
登录
注册
从odoo 7.0迁移到odoo 13.0
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我在odoo 7.0中定义了一个函数,如下所示</p> <pre><code>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 </code></pre> <p>我只想了解13版本与7版本相比的cr、uid和其他参数。 我能理解它也必须是python 3.6版本。 有人能用好的文档向我简要介绍一下这个场景中的差异吗? 我也遵循了odoo文档,它似乎让我感到困惑。 另外,请将函数转换为示例,同时解释将更有帮助。谢谢</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>cr、uid和上下文,其中“移动”为self.env的字段(它们现在在self.env.cr、self.env.uid中可用)。因此,在迁移过程中,您只需删除参数,如果正在使用它们,则使用<code>self.env.*</code></p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何用if条件捕获函数返回值
8 回答
如何用if语句判断列表中是否存在该索引?
4 回答
如何用if语句向量化numpy数组中的最大值?
4 回答
如何用IF语句有条件地保存零碎的结果?
5 回答
如何用if语句测试异常对象?
2 回答
如何用IF语句编写二元函数
8 回答
如何用igraph在python中创建顶点权重的图?
5 回答
如何用ijson和python解析json
1 回答
如何用iloc求子矩阵
8 回答
如何用Imagemagick或PIL绘制高质量的图像笔划(边框)?
9 回答
如何用importlib在python中动态导入模块?
6 回答
如何用import语句重写python内置函数?
2 回答
如何用imshow混合裁剪的强度并显示正确的混合强度?
7 回答
如何用in dictionary解析havin dictionary中的json文件
8 回答
如何用in-Django URL替换%20
1 回答
如何用in\op正确构造查询
7 回答
如何用inbuild对象替换文件
5 回答
如何用inheritan类实现flask restful
3 回答
如何用intersphinx正确地编写对外部文档的交叉引用?
6 回答
如何用int修改LpVariable?
10 回答