muk-it / muk_dms

MuK Document Management System
GNU Lesser General Public License v3.0
91 stars 144 forks source link

MUK DOCUMENTS VERY SLOW with ODOO 11 #78

Closed Pereiral01 closed 5 years ago

Pereiral01 commented 5 years ago

Hello,

Some moths ago, I bought a MUK DOCUMENTS APP. I’m using it, with very well results, but some bit a bit, it was slowing down. Now each time I go to access to it, it takes 3 min to open the tree folders …

Once opened, the file reading is fluid. So I think the problem is when it comes to loading the information.

We have a lot of documents (about 5600), Could it be the cause of this behavior? Is there any option to configure better it? (Zip files, archive …) any idea, please?

I used ODOO 11 COMMUNITY and all app goes very fast except muk Documents.

I forgot ... with the user “ADMIN" opens relatively fast, but with the rest of users (which can only see certain folders depending on access permissions) takes minutes .... maybe this information can help them. Thank so much Cheers

keshrath commented 5 years ago

Unfortunately, that's true. The reason for this is essentially these two methods:

https://github.com/muk-it/muk_dms/blob/11.0/muk_dms/models/dms_settings.py#L150 https://github.com/muk-it/muk_dms/blob/11.0/muk_dms/models/dms_settings.py#L156

Each document is asked if its parent can be read and so the top elements are determined. However, this is a rather unperformant solution for many files and was therfore completely revised with version 12 and solved directly in SQL with a single query.

A relatively simple way to improve the speed should be to change this method

@api.depends('settings_files')
    def _compute_top_files(self):
        for record in self: 
            record.top_files = record.settings_files.filtered(
                lambda f: not f.directory.check_access('read'))

to

@api.depends('settings_files')
    def _compute_top_files(self):
        pass

This means that you lose the possibility to define rights at file level, but this is usually not really used anyway and therefore version 12 does not use it at all as well.

The best solution would probably be to backport parts of the version 12 rework, but I don't have the time at the moment. I would be happy to review a pull requests if anyone wants to give it a try.

Version 12 has been tested with thousands of files and so far no performance problems have been detected.

keshrath commented 5 years ago

In Version 12 we use this method:

https://github.com/muk-it/muk_base/blob/12.0/muk_utils/models/base.py#L82

Pereiral01 commented 5 years ago

Hello Mathias,

I des MUK_DOCUMENTS 11.0.1.3.5 ….

I changed the dms_settings.py (attached it) with:

@api.multi def _compute_top_files(self): for record in self: record.top_files = record.settings_files

Restarted server … and ODOO WHITE page … restarted again and white again.

I would to do anything more? A SQL QUEARY? Which one? Any idea?

Many thanks

El 12 abr 2019 18:07 +0200, Mathias Markl notifications@github.com, escribió:

Unfortunately, that's true. The reason for this is essentially these two methods: https://github.com/muk-it/muk_dms/blob/11.0/muk_dms/models/dms_settings.py#L150 https://github.com/muk-it/muk_dms/blob/11.0/muk_dms/models/dms_settings.py#L156 Each document is asked if its parent can be read and so the top elements are determined. However, this is a rather unperformant solution for many files and was therfore completely revised with version 12 and solved directly in SQL with a single query. A relatively simple way to improve the speed should be to change this method @api.depends('settings_files') def _compute_top_files(self): for record in self: record.top_files = record.settings_files.filtered( lambda f: not f.directory.check_access('read')) to @api.depends('settings_files') def _compute_top_files(self): for record in self: record.top_files = record.settings_files This means that you lose the possibility to define rights at file level, but this is usually not really used anyway and therefore version 12 does not use it at all as well. The best solution would probably be to backport parts of the version 12 rework, but I don't have the time at the moment. I would be happy to review a pull requests if anyone wants to give it a try. Version 12 has been tested with thousands of files and so far no performance problems have been detected. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

keshrath commented 5 years ago
@api.multi
def _compute_top_files(self):
   pass
Pereiral01 commented 5 years ago

Hello,

Thank you very much for your fast answer. Now it says this:

Error: Odoo Server Error

Traceback (most recent call last): File "/odoo/odoo-server/odoo/fields.py", line 936, in get value = record.env.cache.get(record, self) File "/odoo/odoo-server/odoo/api.py", line 960, in get value = self._data[field][record.id][key] KeyError: <odoo.api.Environment object at 0x7ff604fe9f98>

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/odoo/odoo-server/odoo/http.py", line 650, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/odoo/odoo-server/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/odoo/odoo-server/odoo/tools/pycompat.py", line 87, in reraise raise value File "/odoo/odoo-server/odoo/http.py", line 692, in dispatch result = self._call_function(self.params) File "/odoo/odoo-server/odoo/http.py", line 342, in _call_function return checked_call(self.db, *args, *kwargs) File "/odoo/odoo-server/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/odoo/odoo-server/odoo/http.py", line 335, in checked_call result = self.endpoint(*a, kw) File "/odoo/odoo-server/odoo/http.py", line 936, in call return self.method(*args, *kw) File "/odoo/odoo-server/odoo/http.py", line 515, in response_wrap response = f(args, kw) File "/odoo/odoo-server/addons/web/controllers/main.py", line 930, in call_kw return self._call_kw(model, method, args, kwargs) File "/odoo/odoo-server/addons/web/controllers/main.py", line 922, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/odoo/odoo-server/odoo/api.py", line 687, in call_kw return call_kw_model(method, model, args, kwargs) File "/odoo/odoo-server/odoo/api.py", line 672, in call_kw_model result = method(recs, *args, **kwargs) File "/odoo/odoo-server/odoo/models.py", line 4210, in search_read result = records.read(fields) File "/odoo/odoo-server/addons/muk_dms/models/dms_base.py", line 143, in read result = super(DMSBaseModel, self).read(fields, load) File "/odoo/odoo-server/odoo/models.py", line 2576, in read values[name] = field.convert_to_read(record[name], record, use_name_get) File "/odoo/odoo-server/odoo/models.py", line 4729, in getitem return self._fields[key].get(self, type(self)) File "/odoo/odoo-server/odoo/fields.py", line 940, in get self.determine_value(record) File "/odoo/odoo-server/odoo/fields.py", line 1051, in determine_value self.compute_value(recs) File "/odoo/odoo-server/odoo/fields.py", line 1007, in compute_value self._compute_value(records) File "/odoo/odoo-server/odoo/fields.py", line 998, in _compute_value getattr(records, self.compute)() File "/odoo/odoo-server/addons/muk_dms/models/dms_settings.py", line 127, in _compute_top_files Pass NameError: name 'Pass' is not defined

El 15 abr 2019 18:22 +0200, Mathias Markl notifications@github.com, escribió:

@api.multi def _compute_top_files(self): pass — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

keshrath commented 5 years ago

lower case

Pereiral01 commented 5 years ago

Lower case? Whats means this, please? Many thanks

El 16 abr 2019 8:23 PM +0900, Mathias Markl notifications@github.com, escribió:

lower case — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

keshrath commented 5 years ago

it looks to me like you wrote Pass instead of pass