diff --git a/addons/web/static/test/evals.js b/addons/web/static/test/evals.js
index 15cdf221a6a..82c634b04b3 100644
--- a/addons/web/static/test/evals.js
+++ b/addons/web/static/test/evals.js
@@ -784,7 +784,7 @@ odoo.define_section('eval.contexts', ['web.pyeval'], function (test) {
"product_id": 4,
"name": "[PC1] Basic PC",
"quantity": 1,
- "uos_id": 1,
+ "uom_id": 1,
"price_unit": 100,
"account_id": 853,
"discount": 0,
diff --git a/addons/website_event_sale/models/sale_order.py b/addons/website_event_sale/models/sale_order.py
index eae042c1a18..a38a1738882 100644
--- a/addons/website_event_sale/models/sale_order.py
+++ b/addons/website_event_sale/models/sale_order.py
@@ -18,16 +18,12 @@ class sale_order(osv.Model):
domain += [('event_ticket_id', '=', context.get("event_ticket_id"))]
return self.pool.get('sale.order.line').search(cr, SUPERUSER_ID, domain, context=context)
- def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, line_id=None, context=None):
- values = super(sale_order, self)._website_product_id_change(cr, uid, ids, order_id, product_id, qty=qty, line_id=line_id, context=None)
+ def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, context=None):
+ values = super(sale_order, self)._website_product_id_change(cr, uid, ids, order_id, product_id, qty=qty, context=None)
event_ticket_id = None
if context.get("event_ticket_id"):
event_ticket_id = context.get("event_ticket_id")
- elif line_id:
- line = self.pool.get('sale.order.line').browse(cr, SUPERUSER_ID, line_id, context=context)
- if line.event_ticket_id:
- event_ticket_id = line.event_ticket_id.id
else:
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
if product.event_ticket_ids:
@@ -59,6 +55,7 @@ class sale_order(osv.Model):
line = OrderLine.browse(cr, uid, line_id, context=context)
ticket = line.event_ticket_id
old_qty = int(line.product_uom_qty)
+ context = dict(context, event_ticket_id=ticket.id)
else:
line, ticket = None, None
ticket_ids = Ticket.search(cr, uid, [('product_id', '=', product_id)], limit=1, context=context)
diff --git a/addons/website_event_sale/static/src/js/website.tour.event_sale.js b/addons/website_event_sale/static/src/js/website.tour.event_sale.js
index c756a4a3ae8..089e2521a8e 100644
--- a/addons/website_event_sale/static/src/js/website.tour.event_sale.js
+++ b/addons/website_event_sale/static/src/js/website.tour.event_sale.js
@@ -82,6 +82,10 @@ base.ready().done(function () {
$("select[name='country_id']").val("21");
},
},
+ {
+ title: "Check that the subtotal is 5500.0",
+ element: '#order_total_untaxed .oe_currency_value:contains("5500.0")',
+ },
{
title: "Select `Wire Transfer` payment method",
element: '#payment_method label:has(img[title="Wire Transfer"]) input',
diff --git a/addons/website_portal_sale/data/demo.xml b/addons/website_portal_sale/data/demo.xml
index ed45d2d10b0..799240fc5d9 100644
--- a/addons/website_portal_sale/data/demo.xml
+++ b/addons/website_portal_sale/data/demo.xml
@@ -18,7 +18,6 @@
Laptop E5023
3
- 3
2950.00
@@ -28,7 +27,6 @@
Pen drive, 16GB
5
- 5
145.00
@@ -38,7 +36,6 @@
Headset USB
2
- 2
65.00
@@ -49,7 +46,6 @@
- manual
@@ -60,7 +56,6 @@
Service on demand
24
- 24
75.00
@@ -70,7 +65,6 @@
On Site Assistance
30
- 30
38.25
diff --git a/addons/website_quote/controllers/main.py b/addons/website_quote/controllers/main.py
index 0050cc04303..c88209948df 100644
--- a/addons/website_quote/controllers/main.py
+++ b/addons/website_quote/controllers/main.py
@@ -152,8 +152,6 @@ class sale_quote(http.Controller):
'name': option.name,
'order_id': order.id,
'product_id' : option.product_id.id,
- 'product_uos_qty': option.quantity,
- 'product_uos': option.uom_id.id,
'product_uom_qty': option.quantity,
'product_uom': option.uom_id.id,
'discount': option.discount,
diff --git a/addons/website_sale/__openerp__.py b/addons/website_sale/__openerp__.py
index 3971cd76a5a..6077bdb1fe0 100644
--- a/addons/website_sale/__openerp__.py
+++ b/addons/website_sale/__openerp__.py
@@ -10,7 +10,7 @@ OpenERP E-Commerce
==================
""",
- 'depends': ['sale', 'website_payment', 'website_mail', 'website_portal_sale', 'rating'],
+ 'depends': ['website', 'sale', 'payment', 'website_payment', 'website_portal_sale', 'website_mail', 'rating'],
'data': [
'data/data.xml',
'data/web_planner_data.xml',
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 98b48744f5a..f01f20c2613 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -588,6 +588,8 @@ class website_sale(http.Controller):
# create partner
billing_info['team_id'] = request.website.salesteam_id.id
partner_id = orm_partner.create(cr, SUPERUSER_ID, billing_info, context=context)
+ order.write({'partner_id': partner_id, 'partner_invoice_id': partner_id})
+ order_obj.onchange_partner_id(cr, SUPERUSER_ID, [order.id], context=context)
# create a new shipping partner
if checkout.get('shipping_id') == -1:
@@ -598,24 +600,12 @@ class website_sale(http.Controller):
shipping_info['type'] = 'delivery'
shipping_info['parent_id'] = partner_id
checkout['shipping_id'] = orm_partner.create(cr, SUPERUSER_ID, shipping_info, context)
+ order.write({'partner_shipping_id': checkout.get('shipping_id')})
+ order_obj.onchange_partner_shipping_id(cr, SUPERUSER_ID, [order.id], context=context)
order_info = {
- 'partner_id': partner_id,
'message_partner_ids': [(4, partner_id), (3, request.website.partner_id.id)],
- 'partner_invoice_id': partner_id,
}
- order_info.update(order_obj.onchange_partner_id(cr, SUPERUSER_ID, [], partner_id, context=context)['value'])
- address_change = order_obj.onchange_delivery_id(cr, SUPERUSER_ID, [], order.company_id.id, partner_id,
- checkout.get('shipping_id'), None, context=context)['value']
- order_info.update(address_change)
- if address_change.get('fiscal_position_id'):
- fiscal_update = order_obj.onchange_fiscal_position(cr, SUPERUSER_ID, [], address_change['fiscal_position_id'],
- [(4, l.id) for l in order.order_line], context=None)['value']
- order_info.update(fiscal_update)
-
- order_info.pop('user_id')
- order_info.update(partner_shipping_id=checkout.get('shipping_id') or partner_id)
-
order_obj.write(cr, SUPERUSER_ID, [order.id], order_info, context=context)
@http.route(['/shop/checkout'], type='http', auth="public", website=True)
diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index aeb8803a4ea..d1ae2d89041 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -49,32 +49,17 @@ class sale_order(osv.Model):
domain += [('id', '=', line_id)]
return self.pool.get('sale.order.line').search(cr, SUPERUSER_ID, domain, context=context)
- def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, line_id=None, context=None):
- so = self.pool.get('sale.order').browse(cr, uid, order_id, context=context)
-
- values = self.pool.get('sale.order.line').product_id_change(
- cr, SUPERUSER_ID, [],
- pricelist=so.pricelist_id.id,
- product=product_id,
- partner_id=so.partner_id.id,
- fiscal_position_id=so.fiscal_position_id.id,
- qty=qty,
- context=context
- )['value']
-
- if line_id:
- line = self.pool.get('sale.order.line').browse(cr, SUPERUSER_ID, line_id, context=context)
- values['name'] = line.name
- else:
- product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
- values['name'] = product.display_name
- if product.description_sale:
- values['name'] += '\n'+product.description_sale
-
- values['product_id'] = product_id
- values['order_id'] = order_id
- if values.get('tax_id') is not None:
- values['tax_id'] = [(6, 0, values['tax_id'])]
+ def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, context=None):
+ product = self.pool['product.product'].browse(cr, uid, product_id, context=context)
+ values = {
+ 'product_id': product_id,
+ 'name': product.display_name,
+ 'product_uom_qty': qty,
+ 'order_id': order_id,
+ 'product_uom': product.uom_id.id,
+ }
+ if product.description_sale:
+ values['name'] += '\n' + product.description_sale
return values
def _cart_update(self, cr, uid, ids, product_id=None, line_id=None, add_qty=0, set_qty=0, context=None, **kwargs):
@@ -95,6 +80,7 @@ class sale_order(osv.Model):
if not line_id:
values = self._website_product_id_change(cr, uid, ids, so.id, product_id, qty=1, context=context)
line_id = sol.create(cr, SUPERUSER_ID, values, context=context)
+ sol.product_id_change(cr, SUPERUSER_ID, [line_id], context=context)
if add_qty:
add_qty -= 1
@@ -109,7 +95,7 @@ class sale_order(osv.Model):
sol.unlink(cr, SUPERUSER_ID, [line_id], context=context)
else:
# update line
- values = self._website_product_id_change(cr, uid, ids, so.id, product_id, qty=quantity, line_id=line_id, context=context)
+ values = self._website_product_id_change(cr, uid, ids, so.id, product_id, qty=quantity, context=context)
values['product_uom_qty'] = quantity
sol.write(cr, SUPERUSER_ID, [line_id], values, context=context)
@@ -256,8 +242,8 @@ class website(orm.Model):
'team_id': w.salesteam_id.id,
}
sale_order_id = sale_order_obj.create(cr, SUPERUSER_ID, values, context=context)
- values = sale_order_obj.onchange_partner_id(cr, SUPERUSER_ID, [], partner.id, context=context)['value']
- values.update({'user_id': salesperson_id or w.salesperson_id.id})
+ sale_order_obj.onchange_partner_id(cr, SUPERUSER_ID, [sale_order_id], context=context)
+ values = {'user_id': salesperson_id or w.salesperson_id.id}
sale_order_obj.write(cr, SUPERUSER_ID, [sale_order_id], values, context=context)
request.session['sale_order_id'] = sale_order_id
@@ -281,7 +267,7 @@ class website(orm.Model):
flag_pricelist = True
fiscal_position = sale_order.fiscal_position_id and sale_order.fiscal_position_id.id or False
- values = sale_order_obj.onchange_partner_id(cr, SUPERUSER_ID, [sale_order_id], partner.id, context=context)['value']
+ values = sale_order_obj.onchange_partner_id(cr, SUPERUSER_ID, [sale_order_id], context=context).get('value', {})
if values.get('pricelist_id'):
if values['pricelist_id'] != pricelist_id:
values['pricelist_id'] = pricelist_id
@@ -315,7 +301,6 @@ class website(orm.Model):
# update the pricelist
if update_pricelist:
values = {'pricelist_id': pricelist_id}
- values.update(sale_order.onchange_pricelist_id(pricelist_id, None)['value'])
sale_order.write(values)
for line in sale_order.order_line:
if line.exists():
diff --git a/addons/website_sale_delivery/models/sale_order.py b/addons/website_sale_delivery/models/sale_order.py
index df240a6b07a..7416bfc8007 100644
--- a/addons/website_sale_delivery/models/sale_order.py
+++ b/addons/website_sale_delivery/models/sale_order.py
@@ -22,17 +22,11 @@ class delivery_carrier(orm.Model):
class SaleOrder(orm.Model):
_inherit = 'sale.order'
- def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None):
- """ Wrapper because of direct method passing as parameter for function fields """
- return self._amount_all(cr, uid, ids, field_name, arg, context=context)
-
- def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
- res = super(SaleOrder, self)._amount_all(cr, uid, ids, field_name, arg, context=context)
- currency_pool = self.pool.get('res.currency')
+ def _amount_delivery(self, cr, uid, ids, field_name, arg, context=None):
+ res = {}
for order in self.browse(cr, uid, ids, context=context):
- line_amount = sum([line.price_subtotal for line in order.order_line if line.is_delivery])
- currency = order.pricelist_id.currency_id
- res[order.id]['amount_delivery'] = currency_pool.round(cr, uid, currency, line_amount)
+ res[order.id] = {}
+ res[order.id]['amount_delivery'] = sum([line.price_subtotal for line in order.order_line if line.is_delivery])
return res
def _has_delivery(self, cr, uid, ids, field_name, arg, context=None):
@@ -52,7 +46,7 @@ class SaleOrder(orm.Model):
_columns = {
'amount_delivery': fields.function(
- _amount_all_wrapper, type='float', digits=0,
+ _amount_delivery, type='float', digits=0,
string='Delivery Amount',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),