OCA / product-variant

GNU Affero General Public License v3.0
58 stars 262 forks source link

[11.0] sale_variant_configurator: pricelist error #148

Closed cubells closed 2 years ago

cubells commented 5 years ago

If pricelist discount_policy is equal to 'without_discount', and you search for a template in sale order line, then an error is raised because this line:

https://github.com/OCA/product-variant/blob/11.0/sale_variant_configurator/models/sale_order.py#L143

generate a list of tuples with a product.product recordset null, as product_id field is empty at this moment:

https://github.com/OCA/product-variant/blob/11.0/product_variant_configurator/models/pricelist.py#L21

To reproduce the error only have to change the discount_policy of the pricelist of the sale order and search for a template with variants in the sale order line.

The log I've got:

2019-06-26 16:49:49,911 25905 ERROR database odoo.sql_db: bad query: b"SELECT item.id FROM product_pricelist_item AS item LEFT JOIN product_category AS categ ON item.categ_id = categ.id WHERE (item.product_tmpl_id IS NULL OR item.product_tmpl_id = any(ARRAY[false]))AND (item.product_id IS NULL OR item.product_id = any(ARRAY[false]))AND (item.categ_id IS NULL OR item.categ_id = any('{}')) AND (item.pricelist_id = 1) AND (item.date_start IS NULL OR item.date_start<='2019-06-26 16:28:12') AND (item.date_end IS NULL OR item.date_end>='2019-06-26 16:28:12')ORDER BY item.applied_on, item.min_quantity desc, categ.parent_left desc" ERROR: operator does not exist: integer = boolean LINE 1: ...m.product_tmpl_id IS NULL OR item.product_tmpl_id = any(ARRA... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

2019-06-26 16:49:49,912 25905 ERROR database odoo.http: Exception during JSON request handling. Traceback (most recent call last): File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 653, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/home/cubells/Dades/git/odoo11/src/core/odoo/tools/pycompat.py", line 87, in reraise raise value File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 695, in dispatch result = self._call_function(self.params) File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, *kwargs) File "/home/cubells/Dades/git/odoo11/src/core/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, kw) File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 939, in call return self.method(*args, *kw) File "/home/cubells/Dades/git/odoo11/src/core/odoo/http.py", line 517, in response_wrap response = f(args, kw) File "/home/cubells/Dades/git/odoo11/src/core/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/cubells/Dades/git/odoo11/src/core/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/cubells/Dades/git/odoo11/src/core/odoo/api.py", line 689, in call_kw return call_kw_multi(method, model, args, kwargs) File "/home/cubells/Dades/git/odoo11/src/core/odoo/api.py", line 680, in call_kw_multi result = method(recs, *args, *kwargs) File "/home/cubells/Dades/git/odoo11/src/core/odoo/models.py", line 5222, in onchange record._onchange_eval(name, field_onchange[name], result) File "/home/cubells/Dades/git/odoo11/src/core/odoo/models.py", line 5039, in _onchange_eval method_res = method(self) File "/home/cubells/Dades/git/odoo11/src/other-addons/sale_variant_configurator/models/sale_order.py", line 143, in product_uom_change self._update_price_configurator() File "/home/cubells/Dades/git/odoo11/src/other-addons/sale_variant_configurator/models/sale_order.py", line 123, in _update_price_configurator self.price_extra + self._get_display_price(product_tmpl), File "/home/cubells/Dades/git/odoo11/src/core/addons/sale/models/sale.py", line 1042, in _get_display_price final_price, rule_id = self.order_id.pricelist_id.with_context(product_context).get_product_price_rule(self.product_id, self.product_uom_qty or 1.0, self.order_id.partner_id) File "/home/cubells/Dades/git/odoo11/src/core/addons/product/models/product_pricelist.py", line 276, in get_product_price_rule return self._compute_price_rule([(product, quantity, partner)], date=date, uom_id=uom_id)[product.id] File "/home/cubells/Dades/git/odoo11/src/other-addons/product_variant_configurator/models/pricelist.py", line 21, in _compute_price_rule products_qty_partner, date=date, uom_id=uom_id, File "/home/cubells/Dades/git/odoo11/src/core/addons/product/models/product_pricelist.py", line 155, in _compute_price_rule (prod_tmpl_ids, prod_ids, categ_ids, self.id, date, date)) File "/home/cubells/Dades/git/odoo11/src/core/odoo/sql_db.py", line 155, in wrapper return f(self, args, **kwargs) File "/home/cubells/Dades/git/odoo11/src/core/odoo/sql_db.py", line 232, in execute res = self._obj.execute(query, params) psycopg2.errors.UndefinedFunction: operator does not exist: integer = boolean LINE 1: ...m.product_tmpl_id IS NULL OR item.product_tmpl_id = any(ARRA... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

pedrobaeza commented 5 years ago

Do you have a patch for this?

cubells commented 5 years ago

I'm trying to find the best solution for this.

pedrobaeza commented 5 years ago

OK, let me know

cubells commented 5 years ago

Fixed in https://github.com/OCA/product-variant/pull/149

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.