diff options
| author | jpa-odoo <jpa@openerp.com> | 2015-01-26 11:24:58 +0100 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2015-01-26 17:06:00 +0100 |
| commit | de331d5aae945d6afd6d2e379204833f8a751efa (patch) | |
| tree | ada281c256e2d20ab2171518f46fc4ce5fe19a28 | |
| parent | 4caeda8669484f5a57b3737e7c35e7a14246d85f (diff) | |
[IMP] website_sale : onboarding. Allow user to print saleorder when confirm its command, display delivery method menu in sale and in warehouse (with access right stock.group_stock_manager and base.group_sale_manager) and improve quantity ui widget.
| -rw-r--r-- | addons/delivery/delivery_data.xml | 29 | ||||
| -rw-r--r-- | addons/delivery/delivery_demo.xml | 34 | ||||
| -rw-r--r-- | addons/delivery/delivery_view.xml | 5 | ||||
| -rw-r--r-- | addons/delivery/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | addons/website_sale/controllers/main.py | 76 | ||||
| -rw-r--r-- | addons/website_sale/static/src/js/website_sale.js | 2 | ||||
| -rw-r--r-- | addons/website_sale/static/src/js/website_sale_validate.js | 17 | ||||
| -rw-r--r-- | addons/website_sale/views/templates.xml | 181 | ||||
| -rw-r--r-- | addons/website_sale_options/views/templates.xml | 16 |
9 files changed, 190 insertions, 173 deletions
diff --git a/addons/delivery/delivery_data.xml b/addons/delivery/delivery_data.xml index fec56b329b3..62cd70554fb 100644 --- a/addons/delivery/delivery_data.xml +++ b/addons/delivery/delivery_data.xml @@ -1,6 +1,35 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data noupdate="1"> + + <!-- Create a transporter --> + <record id="res_partner_delivery" model="res.partner"> + <field name="name">Transporter (Delivery provider)</field> + <field name="is_company" eval="True"/> + <field name="supplier" eval="True"/> + <field name="customer" eval="False"/> + </record> + + <!-- Create a service product --> + <record id="product_product_delivery" model="product.product"> + <field name="name">Standard delivery</field> + <field name="default_code">Delivery</field> + <field name="type">service</field> + <field name="categ_id" ref="product.product_category_all"/> + <field name="standard_price">10.0</field> + <field name="list_price">10.0</field> + <field name="image" type="base64" file="delivery/static/img/product_product_delivery-image.jpg"/> + </record> + + <record id="free_delivery_carrier" model="delivery.carrier"> + <field name="name">Free delivery charges</field> + <field name="normal_price">0</field> + <field name="free_if_more_than" eval="True"/> + <field name="amount">1000</field> + <field name="partner_id" ref="res_partner_delivery"/> + <field name="product_id" ref="product_product_delivery"/> + </record> + <record forcecreate="True" id="property_delivery_carrier" model="ir.property"> <field name="name">property_delivery_carrier</field> <field name="fields_id" search="[('model','=','res.partner'),('name','=','property_delivery_carrier')]"/> diff --git a/addons/delivery/delivery_demo.xml b/addons/delivery/delivery_demo.xml index ae711083b73..a535145f6d8 100644 --- a/addons/delivery/delivery_demo.xml +++ b/addons/delivery/delivery_demo.xml @@ -2,54 +2,28 @@ <openerp> <data noupdate="1"> - <!-- Create a transporter --> - - <record id="res_partner_23" model="res.partner"> - <field name="name">The Poste</field> - <field name="is_company">1</field> - <field name="supplier">1</field> - <field eval="0" name="customer"/> + <!-- Update a transporter --> + <record id="res_partner_delivery" model="res.partner"> <field name="city">Manchester</field> <field name="zip">06040</field> <field model="res.country" name="country_id" search="[('code','ilike','us')]"/> <field name="street">3958 Maxwell Street</field> </record> - <!-- Create a service product --> - - <record id="product_product_delivery" model="product.product"> - <field name="name">Delivery by Poste</field> - <field name="default_code">Delivery</field> - <field name="type">service</field> - <field name="categ_id" ref="product.product_category_3"/> - <field name="standard_price">10.0</field> - <field name="list_price">10.0</field> - <field name="image" type="base64" file="delivery/static/img/product_product_delivery-image.jpg"/> - </record> - <!-- Carrier --> <record id="delivery_carrier" model="delivery.carrier"> <field name="name">The Poste</field> <field name="normal_price">20</field> - <field name="partner_id" ref="res_partner_23"/> + <field name="partner_id" ref="res_partner_delivery"/> <field name="product_id" ref="product_product_delivery"/> <field name="use_detailed_pricelist" eval="True"/> </record> - <record id="free_delivery_carrier" model="delivery.carrier"> - <field name="name">Free delivery charges</field> - <field name="normal_price">0</field> - <field name="free_if_more_than">True</field> - <field name="amount">1000</field> - <field name="partner_id" ref="res_partner_23"/> - <field name="product_id" ref="product_product_delivery"/> - </record> - <record id="normal_delivery_carrier" model="delivery.carrier"> <field name="name">Normal Delivery Charges</field> <field name="normal_price">10</field> - <field name="partner_id" ref="res_partner_23"/> + <field name="partner_id" ref="res_partner_delivery"/> <field name="product_id" ref="product_product_delivery"/> </record> diff --git a/addons/delivery/delivery_view.xml b/addons/delivery/delivery_view.xml index a0126b56d6b..98ea8641efa 100644 --- a/addons/delivery/delivery_view.xml +++ b/addons/delivery/delivery_view.xml @@ -1,7 +1,8 @@ <openerp> <data> <!-- Delivery Carriers --> - <menuitem id="menu_delivery" name="Delivery" parent="stock.menu_stock_configuration" groups="base.group_no_one" sequence="50"/> + <menuitem id="menu_delivery" name="Delivery" parent="stock.menu_stock_configuration" groups="stock.group_stock_manager" sequence="50"/> + <menuitem id="sale_menu_delivery" name="Delivery" parent="base.menu_base_config" groups="base.group_sale_manager" sequence="12"/> <record id="view_delivery_carrier_tree" model="ir.ui.view"> <field name="name">delivery.carrier.tree</field> @@ -109,6 +110,7 @@ </record> <menuitem action="action_delivery_carrier_form" id="menu_action_delivery_carrier_form" parent="menu_delivery" sequence="1"/> + <menuitem action="action_delivery_carrier_form" id="sale_menu_action_delivery_carrier_form" parent="sale_menu_delivery" sequence="1"/> <!-- Delivery Grids --> <record id="view_delivery_grid_tree" model="ir.ui.view"> @@ -171,6 +173,7 @@ </field> </record> <menuitem action="action_delivery_grid_form" id="menu_action_delivery_grid_form" parent="menu_delivery" sequence="2"/> + <menuitem action="action_delivery_grid_form" id="sale_menu_action_delivery_grid_form" parent="sale_menu_delivery" sequence="2"/> <record id="view_delivery_grid_line_form" model="ir.ui.view"> <field name="name">delivery.grid.line.form</field> diff --git a/addons/delivery/security/ir.model.access.csv b/addons/delivery/security/ir.model.access.csv index 7403b55f618..5f7791a1a62 100644 --- a/addons/delivery/security/ir.model.access.csv +++ b/addons/delivery/security/ir.model.access.csv @@ -6,3 +6,6 @@ access_delivery_carrier_manager,delivery.carrier,model_delivery_carrier,base.gro access_delivery_grid_manager,delivery.grid,model_delivery_grid,base.group_sale_manager,1,1,1,1
access_delivery_grid_line_manager,delivery.grid.line,model_delivery_grid_line,base.group_sale_manager,1,1,1,1
access_delivery_carrier_partner_manager,delivery.carrier partner_manager,model_delivery_carrier,base.group_partner_manager,1,0,0,0
+access_delivery_carrier_stock_manager,delivery.carrier,model_delivery_carrier,stock.group_stock_manager,1,1,1,1
+access_delivery_grid_stock_manager,delivery.grid,model_delivery_grid,stock.group_stock_manager,1,1,1,1
+access_delivery_grid_line_stock_manager,delivery.grid.line,model_delivery_grid_line,stock.group_stock_manager,1,1,1,1
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index c8f4e29a6f9..bf28cfbee6b 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -413,7 +413,7 @@ class website_sale(http.Controller): checkout.update( self.checkout_parse("billing", order.partner_id) ) else: checkout = self.checkout_parse('billing', data) - try: + try: shipping_id = int(shipping_id) except (ValueError, TypeError): pass @@ -757,48 +757,33 @@ class website_sale(http.Controller): order = request.registry['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context) assert order.id == request.session.get('sale_last_order_id') + values = {} + flag = False if not order: - return { - 'state': 'error', - 'message': '<p>%s</p>' % _('There seems to be an error with your request.'), - } - - tx_ids = request.registry['payment.transaction'].search( - cr, SUPERUSER_ID, [ - '|', ('sale_order_id', '=', order.id), ('reference', '=', order.name) - ], context=context) - - if not tx_ids: - if order.amount_total: - return { - 'state': 'error', - 'message': '<p>%s</p>' % _('There seems to be an error with your request.'), - } - else: - state = 'done' - message = '<h2>%s</h2>' % _('Your order has been confirmed, thank you for your loyalty.') - validation = None + values.update({'not_order': True, 'state': 'error'}) else: - tx = request.registry['payment.transaction'].browse(cr, SUPERUSER_ID, tx_ids[0], context=context) - state = tx.state - message = '<h2>%s</h2>' % _('Thank you for your order.') - if state == 'done': - message += '<p>%s</p>' % _('Your payment has been received.') - elif state == 'cancel': - message += '<p>%s</p>' % _('The payment seems to have been canceled.') - elif state == 'pending' and tx.acquirer_id.validation == 'manual': - message += '<p>%s</p>' % _('Your transaction is waiting confirmation.') - if tx.acquirer_id.post_msg: - message += tx.acquirer_id.post_msg + tx_ids = request.registry['payment.transaction'].search( + cr, SUPERUSER_ID, [ + '|', ('sale_order_id', '=', order.id), ('reference', '=', order.name) + ], context=context) + + if not tx_ids: + if order.amount_total: + values.update({'tx_ids': False, 'state': 'error'}) + else: + values.update({'tx_ids': False, 'state': 'done', 'validation': None}) else: - message += '<p>%s</p>' % _('Your transaction is waiting confirmation.') - validation = tx.acquirer_id.validation + tx = request.registry['payment.transaction'].browse(cr, SUPERUSER_ID, tx_ids[0], context=context) + state = tx.state + flag = True if state == 'pending' and tx.acquirer_id.validation == 'automatic' else False + values.update({ + 'tx_ids': True, + 'state': state, + 'validation' : tx.acquirer_id.validation, + 'tx_post_msg': tx.acquirer_id.post_msg or None + }) - return { - 'state': state, - 'message': message, - 'validation': validation - } + return {'recall': flag, 'message': request.website._render("website_sale.order_state_message", values)} @http.route('/shop/payment/validate', type='http', auth="public", website=True) def payment_validate(self, transaction_id=None, sale_order_id=None, **post): @@ -870,6 +855,17 @@ class website_sale(http.Controller): return request.website.render("website_sale.confirmation", {'order': order}) + @http.route(['/shop/print'], type='http', auth="public", website=True) + def print_saleorder(self): + cr, uid, context = request.cr, SUPERUSER_ID, request.context + sale_order_id = request.session.get('sale_last_order_id') + if sale_order_id: + pdf = request.registry['report'].get_pdf(cr, uid, [sale_order_id], 'sale.report_saleorder', data=None, context=context) + pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))] + return request.make_response(pdf, headers=pdfhttpheaders) + else: + return request.redirect('/shop') + #------------------------------------------------------ # Edit #------------------------------------------------------ @@ -953,4 +949,4 @@ class website_sale(http.Controller): 'currency': order.currency_id.name } ret['lines'] = self.order_lines_2_google_api(order.order_line) - return ret
\ No newline at end of file + return ret diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index b0f06561142..9575d36d0d2 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -63,7 +63,7 @@ $('.oe_website_sale').each(function () { $(oe_website_sale).on('click', 'a.js_add_cart_json', function (ev) { ev.preventDefault(); var $link = $(ev.currentTarget); - var $input = $link.parent().parent().find("input"); + var $input = $link.parent().find("input"); var min = parseFloat($input.data("min") || 0); var max = parseFloat($input.data("max") || Infinity); var quantity = ($link.has(".fa-minus").length ? -1 : 1) + parseFloat($input.val(),10); diff --git a/addons/website_sale/static/src/js/website_sale_validate.js b/addons/website_sale/static/src/js/website_sale_validate.js index da917eb1298..25974a1936e 100644 --- a/addons/website_sale/static/src/js/website_sale_validate.js +++ b/addons/website_sale/static/src/js/website_sale_validate.js @@ -4,24 +4,17 @@ $(document).ready(function () { function payment_transaction_poll_status() { var order_node = $('div.oe_website_sale_tx_status'); - if (! order_node || order_node.data('orderId') === undefined) { + if (! order_node || order_node.data('order-id') === undefined) { return; } - var order_id = order_node.data('orderId'); + var order_id = order_node.data('order-id'); return openerp.jsonRpc('/shop/payment/get_status/' + order_id, 'call', { }).then(function (result) { - var tx_node = $('div.oe_website_sale_tx_status'); _poll_nbr += 1; - if (result.state == 'pending' && result.validation == 'automatic' && _poll_nbr <= 5) { - var txt = result.mesage; - setTimeout(function () { - payment_transaction_poll_status(); - }, 1000); + if(result.recall && _poll_nbr <= 5){ + setTimeout(function () { payment_transaction_poll_status(); }, 1000); } - else { - var txt = result.message; - } - tx_node.html(txt); + $('div.oe_website_sale_tx_status').html(result.message); }); } diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 42670547b20..38b6e609343 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -287,7 +287,7 @@ <div class="row"> <div class="col-sm-4"> <ol class="breadcrumb"> - <li><a t-att-href="keep(category=0)" onclick="history.go(-1); return false;">Products</a></li> + <li><a t-att-href="keep(category=0)">Products</a></li> <li t-if="category"><a t-att-href="keep('/shop/category/%s' % slug(category), category=0)" t-field="category.name"/></li> <li class="active"><span t-field="product.name"/></li> </ol> @@ -351,17 +351,13 @@ <template id="product_quantity" inherit_id="website_sale.product" customize_show="True" name="Select Quantity"> <xpath expr="//a[@id='add_to_cart']" position="before"> <div class="css_quantity input-group oe_website_spinner"> - <span class="input-group-addon"> - <a t-attf-href="#" class="mb8 js_add_cart_json"> - <i class="fa fa-minus"></i> - </a> - </span> - <input type="text" class="js_quantity form-control" data-min="1" name="add_qty" value="1"/> - <span class="input-group-addon"> - <a t-attf-href="#" class="mb8 float_left js_add_cart_json"> - <i class="fa fa-plus"></i> - </a> - </span> + <a t-attf-href="#" class="mb8 input-group-addon js_add_cart_json"> + <i class="fa fa-minus"></i> + </a> + <input type="text" class="form-control" data-min="1" name="add_qty" value="1"/> + <a t-attf-href="#" class="mb8 input-group-addon float_left js_add_cart_json"> + <i class="fa fa-plus"></i> + </a> </div> </xpath> </template> @@ -638,20 +634,16 @@ </td> <td class="text-center"> <div class="input-group oe_website_spinner"> - <span class="input-group-addon"> - <a t-attf-href="#" class="mb8 js_add_cart_json" data-no-instant=""> - <i class="fa fa-minus"></i> - </a> - </span> + <a t-attf-href="#" class="mb8 input-group-addon js_add_cart_json" data-no-instant=""> + <i class="fa fa-minus"></i> + </a> <input type="text" class="js_quantity form-control" - t-att-data-line-id="line.id" + t-att-data-line-id="line.id" t-att-data-product-id="line.product_id.id" t-att-value="int(line.product_uom_qty)"/> - <span class="input-group-addon"> - <a t-attf-href="#" class="mb8 float_left js_add_cart_json" data-no-instant=""> - <i class="fa fa-plus"></i> - </a> - </span> + <a t-attf-href="#" class="mb8 input-group-addon float_left js_add_cart_json" data-no-instant=""> + <i class="fa fa-plus"></i> + </a> </div> </td> </tr> @@ -1083,61 +1075,69 @@ </ul> <h1 class="mb32">Order <em t-field="order.name"/> Confirmed</h1> <div class="row"> - <div class="col-md-8 oe_cart"> - <div class="oe_website_sale_tx_status" t-att-data-order-id="order.id"> - </div> - <h3 class="mt32"><strong>Order Details:</strong></h3> - <table class="table"> - <thead> - <tr> - <th>Products</th> - <th>Quantity</th> - <th class="text-right" width="100">Unit Price</th> - <th class="text-right" width="100">Subtotal</th> - </tr> - </thead> - <tbody> - <tr t-foreach="order.order_line" t-as="line"> - <td> - <div> - <a t-attf-href="/shop/product/#{ slug(line.product_id.product_tmpl_id) }"> - <strong t-esc="line.product_id.name_get()[0][1]"/> - </a> - </div> - <div class="text-muted" t-field="line.name"/> - </td> - <td> - <div id="quote_qty"> - <span t-field="line.product_uom_qty"/> - <span t-field="line.product_uom"/> - </div> - </td> - <td> - <strong class="text-right"> - <div t-field="line.price_unit" - t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/> - </strong> - </td> - <td> - <div class="text-right" - t-field="line.price_subtotal" - t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/> - </td> - </tr> - <tr> - <td></td><td></td> - <td class="text-right"><strong>Total:</strong></td> - <td class="text-right"> - <strong t-field="order.amount_total" - t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/> - </td> - </tr> - </tbody> - </table> - <div class="clearfix"/> - <div class="oe_structure"/> + <div class="col-md-8"> + <div class="thanks_msg"> + <h2>Thank you for your order. + <a class="btn btn-primary pull-right" href="/shop/print" target="_blank"> + <i class="fa fa-print"></i> Print + </a> + </h2> + <div class="oe_website_sale_tx_status" t-att-data-order-id="order.id"></div> + </div> + <div class="oe_cart"> + <h3 class="mt32 text-left"><strong>Order Details:</strong></h3> + <table class="table"> + <thead> + <tr> + <th>Products</th> + <th>Quantity</th> + <th class="text-right" width="100">Unit Price</th> + <th class="text-right" width="100">Subtotal</th> + </tr> + </thead> + <tbody> + <tr t-foreach="order.order_line" t-as="line"> + <td> + <div> + <a t-attf-href="/shop/product/#{ slug(line.product_id.product_tmpl_id) }"> + <strong t-esc="line.product_id.name_get()[0][1]"/> + </a> + </div> + <div class="text-muted" t-field="line.name"/> + </td> + <td> + <div id="quote_qty"> + <span t-field="line.product_uom_qty"/> + <span t-field="line.product_uom"/> + </div> + </td> + <td> + <strong class="text-right"> + <div t-field="line.price_unit" + t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/> + </strong> + </td> + <td> + <div class="text-right" + t-field="line.price_subtotal" + t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/> + </td> + </tr> + <tr> + <td></td><td></td> + <td class="text-right"><strong>Total:</strong></td> + <td class="text-right"> + <strong t-field="order.amount_total" + t-field-options='{"widget": "monetary", "display_currency": "order.pricelist_id.currency_id"}'/> + </td> + </tr> + </tbody> + </table> + <div class="clearfix"/> + <div class="oe_structure"/> + </div> </div> - <div class="col-md-3 col-md-offset-1 text-muted" id="right_column"> + <div class="col-md-3 col-md-offset-1 text-muted"> <h4>Bill To:</h4> <div t-field="order.partner_invoice_id" t-field-options='{ "widget": "contact", @@ -1163,8 +1163,31 @@ </t> </template> -<!-- Page Shop my cart and payment total --> +<template id="order_state_message" name="Order State Message"> + <t t-if="(not_order and state == 'error') or (not tx_ids and state == 'error')"> + <p>There seems to be an error with your request.</p> + </t> + <t t-if="not tx_ids and state == 'done'"> + <p>Your order has been confirmed, thank you for your loyalty.</p> + </t> + <t t-if="tx_ids and state == 'done'"> + <p>Your payment has been received.</p> + </t> + <t t-if="tx_ids and state == 'cancel'"> + <p>The payment seems to have been canceled.</p> + </t> + <t t-if="tx_ids and state == 'pending' and validation == 'manual'"> + <p>Your transaction is waiting confirmation.</p><br /> + <t t-if="tx_post_msg"> + <div class="hidden-print"><t t-raw="tx_post_msg"/></div> + </t> + </t> + <t t-if="tx_ids and state not in ['done', 'cancel', 'pending']"> + <p>Your transaction is waiting confirmation.</p> + </t> +</template> +<!-- Page Shop my cart and payment total --> <template id="total"> <table class='pull-right mb16' id="cart_total" t-if="website_sale_order"> <thead> @@ -1356,7 +1379,7 @@ <template id="sales_backend_access" inherit_id='website_sale.orders_followup' customize_show="True" name="Backend Access"> <xpath expr="//div[@class='container oe_website_sale']" position="before"> <h4 class="text-muted text-center mt64 mb64"> - If you wish to access the complete application to manage your orders, you can follow + If you wish to access the complete application to manage your orders, you can follow <a href="/web#action=portal_sale.action_orders_portal">this link</a>. </h4> </xpath> diff --git a/addons/website_sale_options/views/templates.xml b/addons/website_sale_options/views/templates.xml index 2963666cc8c..cc9319d6185 100644 --- a/addons/website_sale_options/views/templates.xml +++ b/addons/website_sale_options/views/templates.xml @@ -72,17 +72,13 @@ </td> <td> <div class="input-group oe_website_spinner"> - <span class="input-group-addon"> - <a t-attf-href="#" class="mb8 js_add_cart_json"> - <i class="fa fa-minus"></i> - </a> - </span> + <a t-attf-href="#" class="mb8 input-group-addon js_add_cart_json"> + <i class="fa fa-minus"></i> + </a> <input type="text" class="js_quantity form-control" data-min="1" name="add_qty" value="1"/> - <span class="input-group-addon"> - <a t-attf-href="#" class="mb8 float_left js_add_cart_json"> - <i class="fa fa-plus"></i> - </a> - </span> + <a t-attf-href="#" class="mb8 input-group-addon float_left js_add_cart_json"> + <i class="fa fa-plus"></i> + </a> </div> </td> </tr> |
