[FIX][IMP] portal, sale: fix and improve UX for signature form in customer portal
* set height for draw signature when user want to accept order to avoid various display issues; * fix name input not being displayed as error if trying to sign with a void partner name; * no more show 'Accept & Sign' button if customer signed document; * update message string for success message after signature; * add an option to specify the signature button label and use it in sale customer portal; * improve return of signature route to return more specific error messages; This commit contains squashed code from @rop-odoo .
This commit is contained in:
committed by
Thibault Delavallée
parent
9d9f4cccdb
commit
23d7c53424
@@ -40,6 +40,7 @@ odoo.define('portal.signature_form', function (require){
|
||||
'decor-color': '#D1D0CE',
|
||||
'color': '#000',
|
||||
'background-color': '#fff',
|
||||
'height': '142px',
|
||||
});
|
||||
this.empty_sign = this.$("#o_portal_signature").jSignature('getData', 'image');
|
||||
},
|
||||
@@ -60,7 +61,7 @@ odoo.define('portal.signature_form', function (require){
|
||||
var signature = self.$("#o_portal_signature").jSignature('getData', 'image');
|
||||
var is_empty = signature ? this.empty_sign[1] === signature[1] : true;
|
||||
|
||||
this.$('#o_portal_sign_name').toggleClass('has-error', !partner_name);
|
||||
this.$('#o_portal_sign_name').parent().toggleClass('has-error', !partner_name);
|
||||
this.$('#o_portal_sign_draw').toggleClass('panel-danger', is_empty).toggleClass('panel-default', !is_empty);
|
||||
if (is_empty || ! partner_name) {
|
||||
return false;
|
||||
@@ -85,8 +86,8 @@ odoo.define('portal.signature_form', function (require){
|
||||
}
|
||||
else if (data.success) {
|
||||
$confirm_btn.remove();
|
||||
var $prout = qweb.render("portal.portal_signature_success", {widget: data});
|
||||
self.$('#o_portal_sign_draw').parent().replaceWith($prout);
|
||||
var $success = qweb.render("portal.portal_signature_success", {widget: data});
|
||||
self.$('#o_portal_sign_draw').parent().replaceWith($success);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
</div>
|
||||
<div id="o_portal_signature" class="panel-body" style="padding: 0"/>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary o_portal_sign_submit">Sign & Confirm</button>
|
||||
<div class="mt16 pull-right">
|
||||
<button type="submit" class="btn btn-primary o_portal_sign_submit"><t t-esc="widget.options.signLabel or 'Accept & Sign'"/></button>
|
||||
</div>
|
||||
</form>
|
||||
</t>
|
||||
<t t-name="portal.portal_signature_success">
|
||||
<div class="alert alert-success" role="alert">
|
||||
<strong>Well done!</strong><br />
|
||||
<span t-esc="widget.success_msg"/>
|
||||
<strong>Thank You !</strong><br />
|
||||
<span t-esc="widget.success"/>
|
||||
<a t-att-href="widget.redirect_url">Click here to see your document.</a>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</templates>
|
||||
|
||||
@@ -368,6 +368,7 @@
|
||||
t-att-data-res-model="object._name"
|
||||
t-att-data-res-id="object.id"
|
||||
t-att-data-call-url="callUrl"
|
||||
t-att-data-sign-label="signLabel"
|
||||
t-att-data-access-token="accessToken"/>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
@@ -204,18 +204,16 @@ class CustomerPortal(CustomerPortal):
|
||||
def portal_quote_accept(self, res_id, access_token=None, partner_name=None, signature=None):
|
||||
if request.env['ir.config_parameter'].sudo().get_param(
|
||||
'sale.sale_portal_confirmation_options', default='none') not in ('pay', 'sign'):
|
||||
return False
|
||||
return {'error': _('Operation not allowed')}
|
||||
if not signature:
|
||||
return {'error': _('Signature is missing.')}
|
||||
try:
|
||||
order_sudo = self._order_check_access(res_id, access_token=access_token)
|
||||
except AccessError:
|
||||
return {
|
||||
'error': _('Invalid order')
|
||||
}
|
||||
|
||||
return {'error': _('Invalid order')}
|
||||
if order_sudo.state != 'sent':
|
||||
return {
|
||||
'error': _('Order is not in a state requiring customer validation.')
|
||||
}
|
||||
return {'error': _('Order is not in a state requiring customer validation.')}
|
||||
|
||||
order_sudo.action_confirm()
|
||||
|
||||
_message_post_helper(
|
||||
|
||||
@@ -317,11 +317,12 @@
|
||||
<div class="panel-body">
|
||||
<div class="row" t-if="order.state == 'sent' and portal_confirmation == 'sign'" id="portal_sign">
|
||||
<div class="col-md-offset-3 col-md-6">
|
||||
<h4>Accept order</h4>
|
||||
<h4>Accept & Sign</h4>
|
||||
<t t-call="portal.portal_signature">
|
||||
<t t-set="object" t-value="order"/>
|
||||
<t t-set="partner_name" t-value="order.partner_id.name"/>
|
||||
<t t-set="callUrl" t-value="'/my/quotes/accept'"/>
|
||||
<t t-set="signLabel" t-value="'Accept Order'"/>
|
||||
<t t-set="accessToken" t-value="order.access_token"/>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user