fix message process sale

This commit is contained in:
Wilson Gomez 2023-05-19 14:58:12 -05:00
parent ff17658c90
commit 601d310f0f
6 changed files with 31 additions and 14 deletions

View File

@ -199,7 +199,7 @@ class SearchSale(SearchWindow):
headers['position'] = {'desc': 'POSICION', 'type': 'char'}
widths_append(130)
headers['total_amount_cache'] = {'desc': 'VALOR TOTAL', 'type': 'number'}
headers['total_amount'] = {'desc': 'VALOR TOTAL', 'type': 'number'}
widths_append(90)
title = ('BUSCAR PEDIDOS...')

View File

@ -232,16 +232,15 @@ class FrontWindow(QMainWindow):
self.Module = Model('ir.module', self.ctx)
print(time.time() - time1, 'final')
self.Config = Model('sale.configuration', self.ctx)
self.Sale = Model('sale.sale', self.ctx)
self._config, = self.Config.find([('id', '=', 1)])
self.discount_method = self._config.get('discount_pos_method')
self.allow_discount_handle = self._config.get('allow_discount_handle', None)
self.sale_automatic = False
if self.enviroment == 'retail' and self._config.get('new_sale_automatic'):
self.sale_automatic = True
self._commission_activated = self.Module.find([
('name', '=', 'commission'),
('state', '=', 'activated'),
])
res = self.Sale.fields_get(['commision'])
self._commission_activated = True if res.get('commision') else False
# self._source = self.Module.find([
# ('name', '=', 'sale_source'),
# ('state', '=', 'activated'),
@ -296,7 +295,6 @@ class FrontWindow(QMainWindow):
self.ctx['sale_device'] = sale_device
self.ctx['shop'] = self._user['shop']
self.Sale = Model('sale.sale', self.ctx)
self.SaleLine = Model('sale.line', self.ctx)
self.Product = Model('product.product', self.ctx)
self.Journal = Model('account.statement.journal', self.ctx)

View File

@ -1117,14 +1117,18 @@ class AppWindow(FrontWindow):
sale_id = self._sale['id']
self.ctx['exception'] = True
res, msg, exception = self.Sale.faster_process({'sale_id': sale_id})
if msg:
self.message_bar.set(msg)
res = self.Sale.faster_process({'sale_id': sale_id})
if isinstance(res, list):
res, msg, exception = res
if msg:
self.message_bar.set(msg)
return
if exception:
self.dialog('invoice_validated_failed', extra_message=exception)
return
else:
self.dialog('process_invoice_failed', extra_message=res['error'])
return
if exception:
self.dialog('invoice_validated_failed', extra_message=exception)
return
self.set_amounts(res)
self._sale['number'] = res['number']
self.field_number.setText(self._sale['number'])

View File

@ -87,6 +87,17 @@ class Model(object):
}
res = self.get_connection('POST', '/search', args_)
return res
def fields_get(self, fields=[]):
if not fields:
fields = self.fields
args_ = {
'model': self.model,
'fields_names': fields,
'context': self.ctx,
}
res = self.get_connection('POST', '/fields_get', args_)
return res
# route = self.get_route('search')
# data = json.dumps(args_, default=encoder)
# res = requests.post(route, data=data)
@ -173,6 +184,9 @@ class Model(object):
conn.request(method, url, body=payload, headers=HEADERS)
response = conn.getresponse()
res = json.loads(response.read())
if response.status != 200:
print(res, 'validate error')
res = res['detail']
conn.close()
return res

View File

@ -65,4 +65,5 @@ class StackMessages(QWidget):
'missing_note_for_delete_product': ('error', 'DEBE ESCRIBIR UNA OBSERVACION PARA ELIMINAR EL PRODUCTO'),
'dont_delete_product': ('error', 'PARA ELIMINAR UN PRODUCTO DE LA VENTA DEBE FORZAR A BORRADOR EN TRYTON.'),
'base_uvt_pos': ('info', 'VENTA SUPERA LA BASE, \n DEBE SELECCIONAR VENTA ELECTRONICA.'),
'process_invoice_failed': ('error', 'ERROR AL PROCESAR FACTURA'),
}

View File

@ -1 +1 @@
__version__ = "6.0.10"
__version__ = "6.0.11"