Merge lp:~jfb-tempo-consulting/unifield-server/US-8276 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5977
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-8276
Merge into: lp:unifield-server
Diff against target: 98 lines (+19/-4)
3 files modified
bin/addons/product/product.py (+2/-1)
bin/osv/orm.py (+16/-3)
bin/osv/query.py (+1/-0)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-8276
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+401174@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/addons/product/product.py'
--- bin/addons/product/product.py 2020-08-11 12:55:22 +0000
+++ bin/addons/product/product.py 2021-04-15 08:08:23 +0000
@@ -470,7 +470,8 @@
470 ret.joins['"product_product"'] = [('"stock_mission_report_line_location"', 'id', 'product_id', 'LEFT JOIN')]470 ret.joins['"product_product"'] = [('"stock_mission_report_line_location"', 'id', 'product_id', 'LEFT JOIN')]
471 ret.where_clause.append(' "stock_mission_report_line_location"."remote_instance_id" is NULL AND "stock_mission_report_line_location"."location_id" in %s ')471 ret.where_clause.append(' "stock_mission_report_line_location"."remote_instance_id" is NULL AND "stock_mission_report_line_location"."location_id" in %s ')
472 ret.where_clause_params.append(tuple(location_ids))472 ret.where_clause_params.append(tuple(location_ids))
473 ret.having = ' GROUP BY "product_product"."id" HAVING sum("stock_mission_report_line_location"."quantity") >0 '473 ret.having_group_by = ' GROUP BY "product_product"."id" '
474 ret.having = ' HAVING sum("stock_mission_report_line_location"."quantity") >0 '
474 if filter_in_any_product_list:475 if filter_in_any_product_list:
475 ret.tables.append('"product_list_line"')476 ret.tables.append('"product_list_line"')
476 ret.joins['"product_product"'] = [('"product_list_line"', 'id', 'name', 'INNER JOIN')]477 ret.joins['"product_product"'] = [('"product_list_line"', 'id', 'name', 'INNER JOIN')]
477478
=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py 2021-02-02 10:20:51 +0000
+++ bin/osv/orm.py 2021-04-15 08:08:23 +0000
@@ -4842,6 +4842,7 @@
4842 translation = 04842 translation = 0
4843 if order_spec:4843 if order_spec:
4844 order_by_elements = []4844 order_by_elements = []
4845 order_by_elements_nodir = []
4845 self._check_qorder(order_spec)4846 self._check_qorder(order_spec)
4846 for order_part in order_spec.split(','):4847 for order_part in order_spec.split(','):
4847 translatable = False4848 translatable = False
@@ -4890,6 +4891,8 @@
4890 trans_name = '"ir_translation%s"' % translation4891 trans_name = '"ir_translation%s"' % translation
4891 init_field = '"%s"."%s"' % (self._table, order_field)4892 init_field = '"%s"."%s"' % (self._table, order_field)
4892 order_by_elements.append('COALESCE(%s."value", %s) %s' % (trans_name, init_field, order_direction))4893 order_by_elements.append('COALESCE(%s."value", %s) %s' % (trans_name, init_field, order_direction))
4894 if query.having:
4895 order_by_elements_nodir.append('COALESCE(%s."value", %s)' % (trans_name, init_field))
4893 left_join_clause = 'LEFT JOIN "ir_translation" %s' % trans_name4896 left_join_clause = 'LEFT JOIN "ir_translation" %s' % trans_name
4894 on_clause = 'ON %s.res_id = "%s".id AND %s.name = \'%s,%s\' AND %s.type = \'model\' AND %s.lang = \'%s\'' % (4897 on_clause = 'ON %s.res_id = "%s".id AND %s.name = \'%s,%s\' AND %s.type = \'model\' AND %s.lang = \'%s\'' % (
4895 trans_name, trans_table, trans_name, trans_obj_name, order_field, trans_name, trans_name, context.get('lang', 'en_US'))4898 trans_name, trans_table, trans_name, trans_obj_name, order_field, trans_name, trans_name, context.get('lang', 'en_US'))
@@ -4905,6 +4908,8 @@
49054908
4906 init_field = self._inherits_join_calc(order_field, query)4909 init_field = self._inherits_join_calc(order_field, query)
4907 order_by_elements.append('COALESCE(%s."value", %s) %s' % (trans_name, init_field, order_direction))4910 order_by_elements.append('COALESCE(%s."value", %s) %s' % (trans_name, init_field, order_direction))
4911 if query.having:
4912 order_by_elements_nodir.append('COALESCE(%s."value", %s)' % (trans_name, init_field))
4908 left_join_clause = 'LEFT JOIN "ir_translation" %s' % trans_name4913 left_join_clause = 'LEFT JOIN "ir_translation" %s' % trans_name
4909 on_clause = 'ON %s.res_id = "%s".id AND %s.name = \'%s,%s\' AND %s.type = \'model\' AND %s.lang = \'%s\'' % (4914 on_clause = 'ON %s.res_id = "%s".id AND %s.name = \'%s,%s\' AND %s.type = \'model\' AND %s.lang = \'%s\'' % (
4910 trans_name, parent_obj._table, trans_name, parent_obj._name, order_field, trans_name, trans_name, context.get('lang', 'en_US'))4915 trans_name, parent_obj._table, trans_name, parent_obj._name, order_field, trans_name, trans_name, context.get('lang', 'en_US'))
@@ -4924,11 +4929,18 @@
4924 if isinstance(end_inner_clause, list):4929 if isinstance(end_inner_clause, list):
4925 for clause in end_inner_clause:4930 for clause in end_inner_clause:
4926 order_by_elements.append("%s %s" % (clause, order_direction))4931 order_by_elements.append("%s %s" % (clause, order_direction))
4932 if query.having:
4933 order_by_elements_nodir.append(clause)
4927 else:4934 else:
4928 order_by_elements.append("%s %s" % (end_inner_clause, order_direction))4935 order_by_elements.append("%s %s" % (end_inner_clause, order_direction))
4936 if query.having:
4937 order_by_elements_nodir.append(end_inner_clause)
4929 if order_by_elements:4938 if order_by_elements:
4930 order_by_clause = ",".join(order_by_elements)4939 order_by_clause = ",".join(order_by_elements)
49314940
4941 if order_by_elements_nodir:
4942 query.having_group_by = '%s, %s' % (query.having_group_by, ','.join(order_by_elements_nodir))
4943
4932 return order_by_clause and (' ORDER BY %s ' % order_by_clause) or '', from_order_clause4944 return order_by_clause and (' ORDER BY %s ' % order_by_clause) or '', from_order_clause
49334945
4934 def _search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):4946 def _search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
@@ -4947,7 +4959,7 @@
49474959
4948 query = self._where_calc(cr, user, args, context=context)4960 query = self._where_calc(cr, user, args, context=context)
4949 self._apply_ir_rules(cr, user, query, 'read', context=context)4961 self._apply_ir_rules(cr, user, query, 'read', context=context)
4950 if order == 'NO_ORDER':4962 if order == 'NO_ORDER' or count:
4951 order_by=''4963 order_by=''
4952 from_order_clause = []4964 from_order_clause = []
4953 else:4965 else:
@@ -4970,11 +4982,12 @@
4970 return res[0][0]4982 return res[0][0]
4971 else:4983 else:
4972 count_query = ''.join(('SELECT "%s".id FROM ' % self._table,4984 count_query = ''.join(('SELECT "%s".id FROM ' % self._table,
4973 from_clause, where_str, query.having, limit_str, offset_str))4985 from_clause, where_str, query.having_group_by, query.having, limit_str, offset_str))
4974 cr.execute(count_query, where_clause_params)4986 cr.execute(count_query, where_clause_params)
4975 return cr.rowcount4987 return cr.rowcount
4988
4976 select_query = ''.join(('SELECT "%s".id FROM ' % self._table,4989 select_query = ''.join(('SELECT "%s".id FROM ' % self._table,
4977 from_clause, where_str, query.having, order_by,limit_str, offset_str))4990 from_clause, where_str, query.having_group_by, query.having, order_by,limit_str, offset_str))
4978 cr.execute(select_query, where_clause_params)4991 cr.execute(select_query, where_clause_params)
4979 res = cr.fetchall()4992 res = cr.fetchall()
4980 return [x[0] for x in res]4993 return [x[0] for x in res]
49814994
=== modified file 'bin/osv/query.py'
--- bin/osv/query.py 2020-06-08 14:18:17 +0000
+++ bin/osv/query.py 2021-04-15 08:08:23 +0000
@@ -53,6 +53,7 @@
53 self.where_clause_params = where_clause_params or []53 self.where_clause_params = where_clause_params or []
5454
55 self.having = ''55 self.having = ''
56 self.having_group_by = ''
56 # holds table joins done explicitly, supporting outer joins. The JOIN57 # holds table joins done explicitly, supporting outer joins. The JOIN
57 # condition should not be in `where_clause`. The dict is used as follows:58 # condition should not be in `where_clause`. The dict is used as follows:
58 # self.joins = {59 # self.joins = {

Subscribers

People subscribed via source and target branches