@@ -1969,26 +1969,40 @@ export class PosStore extends Reactive {
19691969 partner : currentPartner ,
19701970 getPayload : ( newPartner ) => currentOrder . set_partner ( newPartner ) ,
19711971 } ) ;
1972- let pricelistId = payload . pos_property_product_pricelist_id ;
19731972
1974- if ( payload && Boolean ( pricelistId ) ) {
1973+ try {
1974+ if ( payload && Boolean ( payload . pos_property_product_pricelist_id ) ) {
1975+ let pricelistId = payload . pos_property_product_pricelist_id ;
1976+ let pricelist = this . models [ "product.pricelist" ] . find ( ( item ) => item . id === pricelistId ) ;
1977+ if ( ! Boolean ( pricelist ) ) {
1978+ await loadPricelistItems ( this , pricelistId ) ;
1979+ pricelist = this . models [ "product.pricelist" ] . find ( ( item ) => item . id === pricelistId ) ;
1980+ }
1981+ if ( Boolean ( pricelist ) ) {
1982+ payload . property_product_pricelist = pricelist ;
1983+ const orderLines = currentOrder . get_orderlines ( ) ;
1984+ for ( const lineIndex in orderLines ) {
1985+ let line = orderLines [ lineIndex ] ;
1986+ await computeProductPricelistCacheOfProductAndPricelist ( this , [ ] , line . product_id , pricelistId ) ;
1987+ }
1988+ }
19751989
1976- let pricelist = this . models [ "product.pricelist" ] . find ( ( item ) => item . id === pricelistId ) ;
1977- if ( ! Boolean ( pricelist ) ) {
1978- await loadPricelistItems ( this , pricelistId ) ;
1979- pricelist = this . models [ "product.pricelist" ] . find ( ( item ) => item . id === pricelistId ) ;
19801990 }
1981- if ( Boolean ( pricelist ) ) {
1982- payload . property_product_pricelist = pricelist ;
1983- const orderLines = currentOrder . get_orderlines ( ) ;
1984- for ( const lineIndex in orderLines ) {
1985- let line = orderLines [ lineIndex ] ;
1986- await computeProductPricelistCacheOfProductAndPricelist ( this , [ ] , line . product_id , pricelistId ) ;
1987- }
1991+ } catch ( error ) {
1992+ console . log ( error )
1993+ let message ;
1994+ if ( error instanceof ConnectionLostError ) {
1995+ message = _t (
1996+ "Connection to the server has been lost. Please check your internet connection."
1997+ ) ;
1998+ } else {
1999+ message = error . data . message ;
19882000 }
1989-
2001+ this . env . services . dialog . add ( AlertDialog , {
2002+ title : _t ( "Failure to apply pricelist of the customer" ) ,
2003+ body : message ,
2004+ } ) ;
19902005 }
1991-
19922006 if ( payload ) {
19932007 currentOrder . set_partner ( payload ) ;
19942008 } else {
0 commit comments