minor fix

This commit is contained in:
Wilson Gomez 2023-07-05 17:03:05 -05:00
parent 3613dfe3e5
commit f8174d45ce
3 changed files with 33 additions and 29 deletions

View File

@ -206,10 +206,10 @@ class FrontWindow(QMainWindow):
def load_modules(self):
self._sale_pos_restaurant = None
time1 = time.time()
self.Module = Model('ir.module', self.ctx)
self.Module = Model('ir.module', self.ctx, main_window=self)
print(time.time() - time1, 'final')
self.Config = Model('sale.configuration', self.ctx)
self.Sale = Model('sale.sale', self.ctx)
self.Config = Model('sale.configuration', self.ctx, main_window=self)
self.Sale = Model('sale.sale', self.ctx, main_window=self)
self._config, = self.Config.find([('id', '=', 1)])
self.discount_method = self._config.get('discount_pos_method')
@ -256,9 +256,9 @@ class FrontWindow(QMainWindow):
self.PartyConsumer = Model('party.consumer', self.ctx)
if self._config['delivery_product.']:
self._delivery_product = 0
self.User = Model('res.user', self.ctx)
self.User = Model('res.user', self.ctx, main_window=self)
self._user, = self.User.find([('login', '=', self.user)])
self.Company = Model('company.company', self.ctx)
self.Company = Model('company.company', self.ctx, main_window=self)
self._company, = self.Company.find([('id', '=', 1)])
self.logo = self._company['logo']
sale_device = self._user['sale_device']
@ -269,30 +269,30 @@ class FrontWindow(QMainWindow):
self.ctx['sale_device'] = sale_device
self.ctx['shop'] = self._user['shop']
self.SaleLine = Model('sale.line', self.ctx)
self.Product = Model('product.product', self.ctx)
self.Journal = Model('account.statement.journal', self.ctx)
self.Statement = Model('account.statement', self.ctx)
self.Expenses = Model('sale_pos.expenses_daily', self.ctx)
self.Employee = Model('company.employee', self.ctx)
self.Shop = Model('sale.delivery_party', self.ctx)
self.SaleDiscont = Model('sale.discount', self.ctx)
self.Device = Model('sale.device', self.ctx)
self.Category = Model('product.category', self.ctx)
self.PaymentTerm = Model('account.invoice.payment_term', self.ctx)
self.Party = Model('party.party', self.ctx)
self.DeliveryParty = Model('sale.delivery_party', self.ctx)
self.Taxes = Model('account.tax', self.ctx)
self.SaleLine = Model('sale.line', self.ctx, main_window=self)
self.Product = Model('product.product', self.ctx, main_window=self)
self.Journal = Model('account.statement.journal', self.ctx, main_window=self)
self.Statement = Model('account.statement', self.ctx, main_window=self)
self.Expenses = Model('sale_pos.expenses_daily', self.ctx, main_window=self)
self.Employee = Model('company.employee', self.ctx, main_window=self)
self.Shop = Model('sale.delivery_party', self.ctx, main_window=self)
self.SaleDiscont = Model('sale.discount', self.ctx, main_window=self)
self.Device = Model('sale.device', self.ctx, main_window=self)
self.Category = Model('product.category', self.ctx, main_window=self)
self.PaymentTerm = Model('account.invoice.payment_term', self.ctx, main_window=self)
self.Party = Model('party.party', self.ctx, main_window=self)
self.DeliveryParty = Model('sale.delivery_party', self.ctx, main_window=self)
self.Taxes = Model('account.tax', self.ctx, main_window=self)
self.Discount = Model('sale.discount', self.ctx, fields=[
'name', 'active', 'discount', 'type_discount'
])
self.ActionReport = Model('ir.action.report', self.ctx)
], main_window=self)
self.ActionReport = Model('ir.action.report', self.ctx, main_window=self)
if self._commission_activated:
self.Agent = Model('commission.agent', self.ctx)
self.Comission = Model('commission', self.ctx)
self.Agent = Model('commission.agent', self.ctx, main_window=self)
self.Comission = Model('commission', self.ctx, main_window=self)
if self._sale_pos_restaurant:
self.RestTables = Model('sale.shop.table', self.ctx)
self.Consumer = Model('party.consumer', self.ctx)
self.RestTables = Model('sale.shop.table', self.ctx, main_window=self)
self.Consumer = Model('party.consumer', self.ctx, main_window=self)
self.device, = self.Device.find([
('id', '=', self._user['sale_device']),
])
@ -357,8 +357,8 @@ class FrontWindow(QMainWindow):
'locations': [self.shop['warehouse']],
}
self.Source = Model('sale.source', self.ctx)
self.Pricelist = Model('product.price_list', self.ctx)
self.Source = Model('sale.source', self.ctx, main_window=self)
self.Pricelist = Model('product.price_list', self.ctx, main_window=self)
return True

View File

@ -64,9 +64,10 @@ def logout(ctx):
class Model(object):
def __init__(self, model, ctx, fields=None):
def __init__(self, model, ctx, fields=None, main_window=None):
self.model = model
self.ctx = ctx
self.main_window = main_window
self.port = ctx['params']['port']
self.host = ctx['params']['server']
self.db = ctx['params']['database']
@ -194,7 +195,9 @@ class Model(object):
response = conn.getresponse()
res = json.loads(response.read())
if response.status != 200:
print(res, 'validate error')
if self.main_window:
print(res['detail']['error'], 'for show', self.main_window.dialog)
self.main_window.dialog('error_server', extra_message=res['detail']['error'])
res = res['detail']
conn.close()
return res

View File

@ -68,4 +68,5 @@ class StackMessages(QWidget):
'process_invoice_failed': ('error', 'ERROR AL PROCESAR FACTURA'),
'confirm_agent': ('question', 'Confirmar comision de agente'),
'qty_combo_min_req': ('error', 'Cantidad minima requerida!'),
'error_server': ('error', 'Error'),
}