跳至内容
菜单
此问题已终结
6 回复
24940 查看

Just started getting this whenever we try to edit a quote, or add a follower to one. Ideas?


Uncaught SecurityError: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules https://oursite.com/web_editor/static/src/js/transcoder.js:16 Traceback:

Error: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules

    at getMatchedCSSRules (https://oursite.com/web_editor/static/src/js/transcoder.js:16:27)

    at Object.style_to_class (https://oursite.com/web_editor/static/src/js/transcoder.js:193:5)

    at Class.render_value (https://oursite.com/web_editor/static/src/js/backend.js:150:24)

    at Class.reinitialize (https://oursite.com/web/static/src/js/views/form_common.js:158:28)

    at Class.trigger (https://oursite.com/web/static/src/js/framework/mixins.js:222:31)

    at Class.trigger (https://oursite.com/web/static/src/js/framework/mixins.js:272:42)

    at https://oursite.com/web/static/src/js/framework/mixins.js:337:22

    at Function._.each._.forEach (https://oursite.com/web/static/lib/underscore/underscore.js:150:9)

    at Class.set (https://oursite.com/web/static/src/js/framework/mixins.js:318:11)

    at Class.test_effective_readonly (https://oursite.com/web/static/src/js/views/form_common.js:422:18

形象
丢弃

I realized that in a new database the problem doesn't appear until the "mail" module is installed. I don't know what is the cause of this....

Please refer this link.

https://github.com/odoo/odoo/issues/22517

Okay, the solution is to change the code of transcoder.js located in web_editor/static/src/js:

The property "rules" is not well checked.

This line is wrong (around line number 16):

if (sheets[i].rules) {

It has to be changed to this:

if (sheets[i].hasOwnProperty('rules')) {

最佳答案

Hi Patrick,

I have encountered the same problem.

Possible Fix:

You might need to update the time zone of the user to match with the machine you are using.

Go to > settings > users > Locate the user record > preferences > and change the Timezone.

(if  the timezone on preference is different than your local machine time zone, you will see a warning icon on the timezone record.)

Regards,

Rupesh Patel 

形象
丢弃

Okay, I realized that in a new database the problem doesn't appear until the "mail" module is installed. I set the timezone on preference now. Then, I install the "mail" module. But the problem persist.

MouTio , Are you using chrome ? have you tried other browser ? check the timezone on your browser too. by these page : http://www.informit.com/articles/article.aspx?p=1766155&seqNum=4

Rupesh Patel, yes, I am using Google Chrome on Windows 10. In Mozilla Firefox the error doesn't appear.

最佳答案

i fixed by below code: ( version odoo 9.0 )

file : addons\web_editor\static\src\js\transcoder.js ( line 12 )

if (!rulesCache.length) {

        var sheets = document.styleSheets;

        for(var i = sheets.length-1; i >= 0 ; i--) {

            var rules;

            // try...catch because browser may not able to enumerate rules for cross-domain sheets

            try {

                rules = sheets[i].rules || sheets[i].cssRules;

            } catch (e) {

                console.warn("Can't read the css rules of: " + sheets[i].href, e);

                continue;

            }

            if (rules) {

                for(var r = rules.length-1; r >= 0; r--) {

                    var selectorText = rules[r].selectorText;

                    if (selectorText &&

                            rules[r].cssText &&

                            selectorText !== "*" &&

                            selectorText.indexOf(":hover") === -1 &&

                            selectorText.indexOf(":before") === -1 &&

                            selectorText.indexOf(":after") === -1 &&

                            selectorText.indexOf(":active") === -1 &&

                            selectorText.indexOf(":link") === -1 &&

                            selectorText.indexOf("::") === -1 &&

                            selectorText.indexOf("\"") === -1 &&

                            selectorText.indexOf("'") === -1) {

                        var st = selectorText.split(/\s*,\s*/);

                        for (var k=0; k

                            rulesCache.push({ 'selector': st[k], 'style': rules[r].style });

                        }

                    }

                }

            }

        }

        rulesCache.reverse();

    }


//to new code: ( bypass style if not work well )

if (!rulesCache.length) {

        var sheets = document.styleSheets;

        for(var i = sheets.length-1; i >= 0 ; i--) {

            var rules;

            // try...catch because browser may not able to enumerate rules for cross-domain sheets

            try {

                rules = sheets[i].rules || sheets[i].cssRules;

            if (rules) {

                for(var r = rules.length-1; r >= 0; r--) {

                    var selectorText = rules[r].selectorText;

                    if (selectorText &&

                            rules[r].cssText &&

                            selectorText !== "*" &&

                            selectorText.indexOf(":hover") === -1 &&

                            selectorText.indexOf(":before") === -1 &&

                            selectorText.indexOf(":after") === -1 &&

                            selectorText.indexOf(":active") === -1 &&

                            selectorText.indexOf(":link") === -1 &&

                            selectorText.indexOf("::") === -1 &&

                            selectorText.indexOf("\"") === -1 &&

                            selectorText.indexOf("'") === -1) {

                        var st = selectorText.split(/\s*,\s*/);

                        for (var k=0; k

                            rulesCache.push({ 'selector': st[k], 'style': rules[r].style });

                        }

                    }

                }

            }

            } catch (e) {

                console.warn("Can't read the css rules of: " + sheets[i].href, e);

                continue;

            }

        }

        rulesCache.reverse();

    }

形象
丢弃
最佳答案

Hi Patrick,

I face the same issue and after google it, I found that some one solved it. I haven't tried it yet.

You can see the whole discussion regarding this error is following link.

https://github.com/odoo/odoo/issues/22517

I don't know if it is helpful or not. But I will try this and post my updates here.

Regards. 

形象
丢弃
最佳答案

I think this issue occur in this module

addons/mail/static/src/js/announcement.js

Line no.15

形象
丢弃
最佳答案

It happens in V9c 
Just started today in my case. The interesting thing is it does not happen when in developer mode.

形象
丢弃
最佳答案

Go to \addons/web_editor/static/src/js/transcoder.js

Change line no 16:

>>> if sheets[i].rules; to if (sheets[i].hasOwnProperty('rules'))

Thanks 

形象
丢弃