diff --git a/addons/website_quote/controllers/main.py b/addons/website_quote/controllers/main.py index 7ec8733ac7e..eeb085c67a7 100644 --- a/addons/website_quote/controllers/main.py +++ b/addons/website_quote/controllers/main.py @@ -72,7 +72,7 @@ class sale_quote(http.Controller): if token != order.access_token: return request.website.render('website.404') attachments=sign and [('signature.png', sign.decode('base64'))] or [] - order_obj.signal_workflow(request.cr, SUPERUSER_ID, [order_id], 'order_confirm', context=request.context) + order_obj.action_button_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context) message = _('Order signed by %s') % (signer,) self.__message_post(message, order_id, type='comment', subtype='mt_comment', attachments=attachments) return True diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index 9be35a29fb1..380e83c76ed 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -64,8 +64,8 @@ class sale_quote_line(osv.osv): 'discount': 0.0, 'sequence': 10, } - def on_change_product_id(self, cr, uid, ids, product, context=None): - vals = {} + def on_change_product_id(self, cr, uid, ids, product, uom_id=None, context=None): + vals, domain = {}, [] product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) name = product_obj.name if product_obj.description_sale: @@ -75,8 +75,22 @@ class sale_quote_line(osv.osv): 'product_uom_id': product_obj.uom_id.id, 'website_description': product_obj and (product_obj.quote_description or product_obj.website_description) or '', 'name': name, + 'product_uom_id': uom_id or product_obj.uom_id.id, }) - return {'value': vals} + uom_obj = self.pool.get('product.uom') + if vals['product_uom_id'] != product_obj.uom_id.id: + selected_uom = uom_obj.browse(cr, uid, vals['product_uom_id'], context=context) + new_price = uom_obj._compute_price(cr, uid, product_obj.uom_id.id, vals['price_unit'], vals['product_uom_id']) + vals['price_unit'] = new_price + if not uom_id: + domain = {'product_uom_id': [('category_id', '=', product_obj.uom_id.category_id.id)]} + return {'value': vals, 'domain': domain} + + def product_uom_change(self, cr, uid, ids, product, uom_id, context=None): + context = context or {} + if not uom_id: + return {'value': {'price_unit': 0.0, 'uom_id': False}} + return self.on_change_product_id(cr, uid, ids, product, uom_id=uom_id, context=context) def _inject_quote_description(self, cr, uid, values, context=None): values = dict(values or {}) @@ -169,7 +183,7 @@ class sale_order(osv.osv): 'url': '/quote/%s' % (quote.id) } - def onchange_template_id(self, cr, uid, ids, template_id, partner=False, fiscal_position=False, context=None): + def onchange_template_id(self, cr, uid, ids, template_id, partner=False, fiscal_position=False, pricelist_id=False, context=None): if not template_id: return True @@ -177,6 +191,8 @@ class sale_order(osv.osv): context = dict(context or {}) context['lang'] = self.pool['res.partner'].browse(cr, uid, partner, context).lang + pricelist_obj = self.pool['product.pricelist'] + lines = [(5,)] quote_template = self.pool.get('sale.quote.template').browse(cr, uid, template_id, context=context) for line in quote_template.quote_line: @@ -185,11 +201,16 @@ class sale_order(osv.osv): line.product_uom_id.id, line.name, partner, False, True, time.strftime('%Y-%m-%d'), False, fiscal_position, True, context) data = res.get('value', {}) + if pricelist_id: + price = pricelist_obj.price_get(cr, uid, [pricelist_id], line.product_id.id, 1, context=context)[pricelist_id] + else: + price = line.price_unit + if 'tax_id' in data: data['tax_id'] = [(6, 0, data['tax_id'])] data.update({ 'name': line.name, - 'price_unit': line.price_unit, + 'price_unit': price, 'discount': line.discount, 'product_uom_qty': line.product_uom_qty, 'product_id': line.product_id.id, @@ -270,18 +291,34 @@ class sale_quote_option(osv.osv): _defaults = { 'quantity': 1, } - def on_change_product_id(self, cr, uid, ids, product, context=None): - vals = {} + + def on_change_product_id(self, cr, uid, ids, product, uom_id=None, context=None): + vals, domain = {}, [] product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) + name = product_obj.name + if product_obj.description_sale: + name += '\n' + product_obj.description_sale vals.update({ 'price_unit': product_obj.list_price, 'website_description': product_obj.product_tmpl_id.quote_description, - 'name': product_obj.name, - 'uom_id': product_obj.product_tmpl_id.uom_id.id, + 'name': name, + 'uom_id': uom_id or product_obj.uom_id.id, }) - if product_obj.description_sale: - vals['name'] += '\n'+product_obj.description_sale - return {'value': vals} + uom_obj = self.pool.get('product.uom') + if vals['uom_id'] != product_obj.uom_id.id: + selected_uom = uom_obj.browse(cr, uid, vals['uom_id'], context=context) + new_price = uom_obj._compute_price(cr, uid, product_obj.uom_id.id, + vals['price_unit'], vals['uom_id']) + vals['price_unit'] = new_price + if not uom_id: + domain = {'uom_id': [('category_id', '=', product_obj.uom_id.category_id.id)]} + return {'value': vals, 'domain': domain} + + def product_uom_change(self, cr, uid, ids, product, uom_id, context=None): + if not uom_id: + return {'value': {'price_unit': 0.0, 'uom_id': False}} + return self.on_change_product_id(cr, uid, ids, product, uom_id=uom_id, context=context) + class sale_order_option(osv.osv): _name = "sale.order.option" @@ -302,20 +339,34 @@ class sale_order_option(osv.osv): _defaults = { 'quantity': 1, } - def on_change_product_id(self, cr, uid, ids, product, context=None): - vals = {} + def on_change_product_id(self, cr, uid, ids, product, uom_id=None, context=None): + vals, domain = {}, [] if not product: return vals product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) + name = product_obj.name + if product_obj.description_sale: + name += '\n'+product_obj.description_sale vals.update({ 'price_unit': product_obj.list_price, 'website_description': product_obj and (product_obj.quote_description or product_obj.website_description), - 'name': product_obj.name, - 'uom_id': product_obj.product_tmpl_id.uom_id.id, + 'name': name, + 'uom_id': uom_id or product_obj.uom_id.id, }) - if product_obj.description_sale: - vals['name'] += '\n'+product_obj.description_sale - return {'value': vals} + uom_obj = self.pool.get('product.uom') + if vals['uom_id'] != product_obj.uom_id.id: + selected_uom = uom_obj.browse(cr, uid, vals['uom_id'], context=context) + new_price = uom_obj._compute_price(cr, uid, product_obj.uom_id.id, vals['price_unit'], vals['uom_id']) + vals['price_unit'] = new_price + if not uom_id: + domain = {'uom_id': [('category_id', '=', product_obj.uom_id.category_id.id)]} + return {'value': vals, 'domain': domain} + + def product_uom_change(self, cr, uid, ids, product, uom_id, context=None): + context = context or {} + if not uom_id: + return {'value': {'price_unit': 0.0, 'uom_id': False}} + return self.on_change_product_id(cr, uid, ids, product, uom_id=uom_id, context=context) class product_template(osv.Model): _inherit = "product.template" diff --git a/addons/website_quote/static/src/css/website_quotation.css b/addons/website_quote/static/src/css/website_quotation.css index defa37feef5..6d32f06ab96 100644 --- a/addons/website_quote/static/src/css/website_quotation.css +++ b/addons/website_quote/static/src/css/website_quotation.css @@ -6,7 +6,7 @@ } /* mobile preview: the left menu overlaps the quote */ -@media (max-width: 768px) { +@media (max-width: 992px) { .o_website_quote .bs-sidebar { position: relative; } @@ -42,11 +42,16 @@ padding-left: 30px; font-size: 90%; } -@media (max-width: 991px) { - .o_website_quote .bs-sidebar { - position: static; - } + +/* Table Styling */ +.wq-table { + table-layout: auto !important; } + +.wq-table th, .wq-table td { + border-top: none !important; + } + @media (min-width: 992px) { .o_website_quote .bs-sidebar .nav > .active > ul { display: block; diff --git a/addons/website_quote/views/website_quotation.xml b/addons/website_quote/views/website_quotation.xml index 55b90835578..95f1c9ceedb 100644 --- a/addons/website_quote/views/website_quotation.xml +++ b/addons/website_quote/views/website_quotation.xml @@ -13,7 +13,7 @@