Closed niulinlnc closed 5 years ago
What kind of help are you interested in? Do you mean technical explanation of how the progress reporting works? Do you plan to simply use it or you would like to extend it?
Thank you for your response.I found several problems in my initial use:
Date | Level | Type | Message |
---|---|---|---|
06/23/2019 09:37:49 | CRITICAL | server | Couldn't load module web_progress |
06/23/2019 09:37:49 | CRITICAL | server | 38 Function not implemented |
06/23/2019 09:37:49 | WARNING | server | Transient module states were reset |
06/23/2019 09:37:49 | ERROR | server | Failed to load registry Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/modules/registry.py", line 86, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "/home/odoo/src/odoo/odoo/modules/loading.py", line 421, in load_modules loaded_modules, update_module, models_to_check) File "/home/odoo/src/odoo/odoo/modules/loading.py", line 313, in load_marked_modules perform_checks=perform_checks, models_to_check=models_to_check File "/home/odoo/src/odoo/odoo/modules/loading.py", line 179, in load_module_graph load_openerp_module(package.name) File "/home/odoo/src/odoo/odoo/modules/module.py", line 368, in load_openerp_module import('odoo.addons.' + module_name) File " |
06/23/2019 09:37:49 | CRITICAL | server | Failed to initialize database master-454444 . Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/service/server.py", line 1116, in preload_registries registry = Registry.new(dbname, update_module=update_module) File "/home/odoo/src/odoo/odoo/modules/registry.py", line 86, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "/home/odoo/src/odoo/odoo/modules/loading.py", line 421, in load_modules loaded_modules, update_module, models_to_check) File "/home/odoo/src/odoo/odoo/modules/loading.py", line 313, in load_marked_modules perform_checks=perform_checks, models_to_check=models_to_check File "/home/odoo/src/odoo/odoo/modules/loading.py", line 179, in load_module_graph load_openerp_module(package.name) File "/home/odoo/src/odoo/odoo/modules/module.py", line 368, in load_openerp_module import('odoo.addons.' + module_name) File " |
Thanks for your feedback. I just released v.1.1 with a fix for dependency on multiprocessing. It shall resolve your problem with "OSError: [Errno 38] Function not implemented".
Regarding your previous comments I attach a screen-shots taken with my mobile.
I think the layout is OK (as for Odoo standards), but any suggestions are welcome (please create a PR if you have any proposal).
Regarding the process cancellation, it has been always working OK for me (see the screen-shots). If it does not work for you, please provide me with some more details and preferably a GIF/video of what is going on.
Thank you very much for your efficient feedback! I'm using it in the following function. If I click cancel during synchronization, the task will continue.
@api.model
def synchronous_dingding_employee(self, s_avatar=None):
"""
synchronous dingding employee
:return:
"""
url = self.env['ali.dindin.system.conf'].search([('key', '=', 'user_listbypage')]).value
token = self.env['ali.dindin.system.conf'].search([('key', '=', 'token')]).value
# Get the department list
departments = self.env['hr.department'].sudo().search([('din_id', '!=', '')])
for department in departments.with_progress(msg="Synchronizing employee list"):
emp_offset = 0
emp_size = 100
while True:
logging.info(">>>Start getting employees from {} departments".format(department.name))
data = {
'access_token': token,
'department_id': department[0].din_id,
'offset': emp_offset,
'size': emp_size,
}
result_state = self.get_dingding_employees(department, url, data, s_avatar=s_avatar)
if result_state:
emp_offset = emp_offset + 1
else:
break
return True
Another problem is that the progress bars are not very synchronized with the Numbers below, and the progress bars are not refreshed in time. Sometimes halfway through the progress bar, the task is actually over.
The progress reporting is configured to be executed less often than every 5 seconds and the progress bar animates the progress with 5 sec of delay. If the execution inside the main loop takes too much time (more than 1-2 sec), then the progress reporting may not be smooth and the cancellation may take too much time. Operation maybe cancelled only when the next value from the tracked collection is taken.
In your code I would suggest, if possible, to get the number of employees for the department first and then process them (in batches) with tracking (as a sub-operation). It would create a more precise progress tracking and more immediate cancelling.
Also I think there is a small problem in your code, there shall be emp_offset = emp_offset + emp_size
I would suggest something like below (provided self.get_dingding_employees_count(department)
gives a number of employees for a given department):
import math
@api.model
def synchronous_dingding_employee(self, s_avatar=None):
"""
synchronous dingding employee
:return:
"""
url = self.env['ali.dindin.system.conf'].search([('key', '=', 'user_listbypage')]).value
token = self.env['ali.dindin.system.conf'].search([('key', '=', 'token')]).value
# Get the department list
departments = self.env['hr.department'].sudo().search([('din_id', '!=', '')])
for department in departments.with_progress(msg="Synchronizing employee list"):
emp_count = self.get_dingding_employees_count(department)
emp_size = 100
for page in self.web_progress_iter(range(math.ceil(emp_count/emp_size)), msg="batch of 100"):
emp_offset = page*emp_size
logging.info(">>>Start getting employees from {} departments".format(department.name))
data = {
'access_token': token,
'department_id': department[0].din_id,
'offset': emp_offset,
'size': emp_size,
}
result_state = self.get_dingding_employees(department, url, data, s_avatar=s_avatar)
if not result_state:
break
return True
Thank you very much for your advice, I am optimizing the code to make better use of your plugin.
Thank you very much for providing such a nice plug-in. Can you provide more detailed help?