gmarczynski / odoo-web-progress

Dynamic Progress Bar for Odoo Waiting Screen
Other
40 stars 35 forks source link

Can you provide more detailed help? #1

Closed niulinlnc closed 5 years ago

niulinlnc commented 5 years ago

Thank you very much for providing such a nice plug-in. Can you provide more detailed help?

gmarczynski commented 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?

niulinlnc commented 5 years ago

Thank you for your response.I found several problems in my initial use:

  1. After the cancellation in the middle, the process will continue and it seems that it cannot be canceled. 2.The progress bar displayed on the mobile browser side is a bit short, and the layout is not very beautiful.
niulinlnc commented 5 years ago
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 "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "/home/odoo/src/odoo/odoo/modules/module.py", line 82, in load_module exec(open(modfile, 'rb').read(), new_mod.dict) File "", line 3, in File "/home/odoo/src/user/web_progress/models/init.py", line 5, in from . import web_progress File "/home/odoo/src/user/web_progress/models/web_progress.py", line 10, in lock = RLock() File "/usr/lib/python3.6/multiprocessing/context.py", line 72, in RLock return RLock(ctx=self.get_context()) File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 188, in init SemLock.init(self, RECURSIVE_MUTEX, 1, 1, ctx=ctx) File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 60, in init unlink_now) OSError: [Errno 38] Function not implemented
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 "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 656, in _load_unlocked File "", line 626, in _load_backward_compatible File "/home/odoo/src/odoo/odoo/modules/module.py", line 82, in load_module exec(open(modfile, 'rb').read(), new_mod.dict) File "", line 3, in File "/home/odoo/src/user/web_progress/models/init.py", line 5, in from . import web_progress File "/home/odoo/src/user/web_progress/models/web_progress.py", line 10, in lock = RLock() File "/usr/lib/python3.6/multiprocessing/context.py", line 72, in RLock return RLock(ctx=self.get_context()) File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 188, in init SemLock.init(self, RECURSIVE_MUTEX, 1, 1, ctx=ctx) File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 60, in init unlink_now) OSError: [Errno 38] Function not implemented
gmarczynski commented 5 years ago

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".

gmarczynski commented 5 years ago

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.

Screenshot_20190623-231951_Chrome Screenshot_20190623-232008_Chrome 20190623_232106

niulinlnc commented 5 years ago

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
niulinlnc commented 5 years ago

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.

gmarczynski commented 5 years ago

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.

gmarczynski commented 5 years ago

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.

gmarczynski commented 5 years ago

Also I think there is a small problem in your code, there shall be emp_offset = emp_offset + emp_size

gmarczynski commented 5 years ago

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
niulinlnc commented 5 years ago

Thank you very much for your advice, I am optimizing the code to make better use of your plugin.