OCA / web

Odoo web client UI related addons
GNU Affero General Public License v3.0
944 stars 1.89k forks source link

[10.0][web_access_rule_buttons] One2Many Error (DataError: invalid input syntax for integer: "one2many_v_id_642") #1033

Closed maljac closed 1 year ago

maljac commented 6 years ago

Hello,

it seems that web_access_rule_buttons throws a exception in certain situations.

Scenario: Use a non-admin user, create a new invoice and create a new line.* Result:

  File "/etc/odoo/addons/web_access_rule_buttons/models.py", line 29, in check_access_rule_all
    self.check_access_rule(operation)
  File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 3313, in check_access_rule
    self._cr.execute(query, [sub_ids] + where_params)
  File "/usr/lib/python2.7/dist-packages/odoo/sql_db.py", line 154, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/odoo/sql_db.py", line 231, in execute
    res = self._obj.execute(query, params)
DataError: invalid input syntax for integer: "one2many_v_id_642"
LINE 1: ...OM "sale_order_line" WHERE sale_order_line.id IN ('one2many_...

Possible Bug:

# web_access_rule_buttons.js
...
        show_hide_buttons : function() {
            var self = this;
            this.dataset.call("check_access_rule_all", [ [ this.datarecord.id ], [ "write" ] ]).then(function(accesses) {
                self.show_hide_edit_button(accesses.write);
            });
        },
...

In the describe scenario, the value of this.datarecord.id ist a string with the value one2many_v_id_642.

Solution: Check the type of this.datarecord.id in JS before making the call to check_access_rule_all.

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.