@ -37,6 +37,13 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
return this . _super ( ) ;
return this . _super ( ) ;
}
}
this . pos . from_loaded_order = false ;
this . pos . from_loaded_order = false ;
// When reprinting a loaded order we temporarily set it as the
// active one. When we get out from the printing screen, we set
// it back to the one that was active
if ( this . pos . current_order ) {
this . pos . set_order ( this . pos . current_order ) ;
this . pos . current_order = false ;
}
return this . gui . show_screen ( this . gui . startup_screen ) ;
return this . gui . show_screen ( this . gui . startup_screen ) ;
} ,
} ,
} ) ;
} ) ;
@ -145,6 +152,10 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
action_print : function ( order ) {
action_print : function ( order ) {
var receipt = order . export_for_printing ( ) ;
var receipt = order . export_for_printing ( ) ;
// We store temporarily the current order so we can safely compute
// taxes based on fiscal position
this . pos . current_order = this . pos . get_order ( )
this . pos . set_order ( order ) ;
if ( this . pos . config . iface_print_via_proxy ) {
if ( this . pos . config . iface_print_via_proxy ) {
this . pos . proxy . print_receipt ( QWeb . render (
this . pos . proxy . print_receipt ( QWeb . render (
'XmlReceipt' , {
'XmlReceipt' , {
@ -155,6 +166,8 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
orderlines : order . get_orderlines ( ) ,
orderlines : order . get_orderlines ( ) ,
paymentlines : order . get_paymentlines ( ) ,
paymentlines : order . get_paymentlines ( ) ,
} ) ) ;
} ) ) ;
this . pos . set_order ( this . pos . current_order ) ;
this . pos . current_order = false ;
} else {
} else {
this . pos . reloaded_order = order ;
this . pos . reloaded_order = order ;
this . gui . show_screen ( 'receipt' ) ;
this . gui . show_screen ( 'receipt' ) ;
@ -182,6 +195,14 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
order_data . partner_id = order_data . partner_id [ 0 ] ;
order_data . partner_id = order_data . partner_id [ 0 ] ;
}
}
order . set_client ( this . pos . db . get_partner_by_id ( order_data . partner_id ) ) ;
order . set_client ( this . pos . db . get_partner_by_id ( order_data . partner_id ) ) ;
// Set fiscal position
if ( order_data . fiscal_position && this . pos . fiscal_positions ) {
var fiscal_positions = this . pos . fiscal_positions ;
order . fiscal_position = fiscal_positions . filter ( function ( p ) {
return p . id === order_data . fiscal_position ;
} ) [ 0 ] ;
order . trigger ( 'change' ) ;
}
// Set order lines
// Set order lines
var orderLines = order_data . line_ids || order_data . lines || [ ] ;
var orderLines = order_data . line_ids || order_data . lines || [ ] ;
_ . each ( orderLines , function ( orderLine ) {
_ . each ( orderLines , function ( orderLine ) {
@ -204,17 +225,6 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
} ) ;
} ) ;
}
}
} ) ;
} ) ;
// Set fiscal position
if ( order_data . fiscal_position && this . pos . fiscal_positions ) {
var fiscal_positions = this . pos . fiscal_positions ;
order . fiscal_position = fiscal_positions . filter ( function ( p ) {
return p . id === order_data . fiscal_position ;
} ) [ 0 ] ;
_ . each ( order . orderlines . models , function ( line ) {
line . set_quantity ( line . quantity ) ;
} ) ;
order . trigger ( 'change' ) ;
}
if ( order_data . return ) {
if ( order_data . return ) {
order . return = true ;
order . return = true ;
// A credit note should be emited if there was an invoice
// A credit note should be emited if there was an invoice