@@ -81,7 +81,7 @@ def test_generate_hr_expense_advance(self): # For Advance Only
81
81
},
82
82
]
83
83
}
84
- return self .generate_hr_expense (data_dict )
84
+ return self .generate_hr_expense (data_dict , test = True )
85
85
86
86
@api .model
87
87
def test_generate_hr_expense_expense (self ): # Expense / Advance
@@ -186,7 +186,7 @@ def test_generate_hr_expense_expense(self): # Expense / Advance
186
186
},
187
187
]
188
188
}
189
- return self .generate_hr_expense (data_dict )
189
+ return self .generate_hr_expense (data_dict , test = True )
190
190
191
191
@api .model
192
192
def _pre_process_hr_expense (self , data_dict ):
@@ -257,7 +257,9 @@ def _post_process_hr_expense(self, expense):
257
257
expense .signal_workflow ('confirm' )
258
258
259
259
@api .model
260
- def generate_hr_expense (self , data_dict ):
260
+ def generate_hr_expense (self , data_dict , test = False ):
261
+ if not test and not self .env .user .company_id .pabiweb_active :
262
+ raise UserError (_ ('Odoo/PABIWeb Disconnected!' ))
261
263
try :
262
264
prepare_code = data_dict .get ('preparer_code' )
263
265
data_dict = self ._pre_process_hr_expense (data_dict )
@@ -316,29 +318,29 @@ def _finalize_data_to_load(self, data_dict):
316
318
data_array = {}
317
319
for table in _table_fields :
318
320
data_array [table ] = False
319
- data_array [table + '_fields' ] = False
321
+ data_array [table + '_fields' ] = False
320
322
if table in fields :
321
323
i = fields .index (table )
322
324
data_array [table ] = data [i ] or () # ({'x': 1, 'y': 2}, {})
323
325
del fields [i ]
324
326
del data [i ]
325
327
line_count = max (line_count , len (data_array [table ]))
326
328
if data_array [table ]:
327
- data_array [table + '_fields' ] = \
328
- [table + '/' + key for key in data_array [table ][0 ].keys ()]
329
- fields += data_array [table + '_fields' ] or []
329
+ data_array [table + '_fields' ] = \
330
+ [table + '/' + key for key in data_array [table ][0 ].keys ()]
331
+ fields += data_array [table + '_fields' ] or []
330
332
# Data
331
333
datas = []
332
334
for i in range (0 , line_count , 1 ):
333
335
record = []
334
336
for table in _table_fields :
335
- data_array [table + '_data' ] = False
336
- if data_array [table + '_fields' ]:
337
- data_array [table + '_data' ] = \
337
+ data_array [table + '_data' ] = False
338
+ if data_array [table + '_fields' ]:
339
+ data_array [table + '_data' ] = \
338
340
(len (data_array [table ]) > i and data_array [table ][i ] or
339
- {key : False for key in data_array [table + '_fields' ]})
340
- record += data_array [table + '_data' ] and \
341
- data_array [table + '_data' ].values () or []
341
+ {key : False for key in data_array [table + '_fields' ]})
342
+ record += data_array [table + '_data' ] and \
343
+ data_array [table + '_data' ].values () or []
342
344
if i == 0 :
343
345
datas += [tuple (data + record )]
344
346
else :
0 commit comments