[FIX] website_sale: log if no pricelist

The pricelist field is not a mandatory field on the partner. A default
value is usually defined for any new partner created. However, if the
pricelist is manually removed from the partner, errors (tracebacks) will
occur in the eCommerce when no pricelist is found.

We cannot make the field mandatory, as it could potentially break the
workflow of some users which are not using eCommerce. Therefore, we
simply log an error message to help debugging.

opw-673453
This commit is contained in:
Nicolas Martinelli 2016-04-26 10:14:56 +02:00
parent 61c808b774
commit f5eae92f12
1 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import logging
import werkzeug
from openerp import SUPERUSER_ID
@ -11,6 +12,8 @@ from openerp.addons.web.controllers.main import login_redirect
PPG = 20 # Products Per Page
PPR = 4 # Products Per Row
_logger = logging.getLogger(__name__)
class table_compute(object):
def __init__(self):
self.table = {}
@ -111,6 +114,8 @@ def get_pricelist():
else:
partner = pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
pricelist = partner.property_product_pricelist
if not pricelist:
_logger.error('Fail to find pricelist for partner "%s" (id %s)', partner.name, partner.id)
return pricelist
class website_sale(http.Controller):