Closed angelmoya closed 8 years ago
Can you provide a detailed error message and stack trace if any?
That is the stack trace of this error:
Traceback (most recent call last): File "/home/domatix/workspace/odoo/odoo/openerp/http.py", line 537, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/domatix/workspace/odoo/odoo/openerp/http.py", line 574, in dispatch result = self._call_function(_self.params) File "/home/domatix/workspace/odoo/odoo/openerp/http.py", line 310, in _call_function return checked_call(self.db, args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/service/model.py", line 113, in wrapper return f(dbname, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/http.py", line 307, in checked_call return self.endpoint(_a, _kw) File "/home/domatix/workspace/odoo/odoo/openerp/http.py", line 803, in call return self.method(_args, _kw) File "/home/domatix/workspace/odoo/odoo/openerp/http.py", line 403, in response_wrap response = f(_args, _kw) File "/home/domatix/workspace/odoo/odoo/addons/web/controllers/main.py", line 944, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/domatix/workspace/odoo/odoo/addons/web/controllers/main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 241, in wrapper return old_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/addons/account_followup/account_followup.py", line 296, in write return super(res_partner, self).write(cr, uid, ids, vals, context=context) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 241, in wrapper return old_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 363, in old_api result = method(recs, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/addons/base/res/res_partner.py", line 564, in write result = super(res_partner, self).write(vals) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 239, in wrapper return new_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 547, in new_api result = method(self._model, cr, uid, self.ids, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/addons/mail/mail_thread.py", line 432, in write result = super(mail_thread, self).write(cr, uid, ids, values, context=context) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 241, in wrapper return old_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 363, in old_api result = method(recs, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/models.py", line 3776, in write self._write(old_vals) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 239, in wrapper return new_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 547, in new_api result = method(self._model, cr, uid, self.ids, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/models.py", line 4023, in _write recs.recompute() File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 239, in wrapper return new_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/models.py", line 5692, in recompute rec._write(values) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 239, in wrapper return new_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 547, in new_api result = method(self._model, cr, uid, self.ids, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/models.py", line 3881, in _write self.check_access_rule(cr, user, ids, 'write', context=context) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 241, in wrapper return old_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/models.py", line 3528, in check_access_rule self._check_record_rules_result_count(cr, uid, sub_ids, returned_ids, operation, context=context) File "/home/domatix/workspace/odoo/odoo/openerp/api.py", line 241, in wrapper return old_api(self, _args, _kwargs) File "/home/domatix/workspace/odoo/odoo/openerp/models.py", line 3477, in _check_record_rules_result_count (self._description, operation)) except_orm: (u'Acceso denegado', u'No se ha podido completar la operaci\xf3n por restricciones de seguridad. Contacte por favor con su administrador de sistema.\n\n(Tipo de documento: A generic banking mandate, Operaci\xf3n: write)')
company_dependent is not support in one2many fields.
The problem maybe is from core.
For example my bank account have two mandates, I have a mandate in company A. Then I try to create a mandate in company B, as I logged in company B, in bank account I can't see mandate A, so when I save this bank account the field mandate_ids in the view only have the mandate B, then save bank account try to delte relation of mantade A, but I have no acces to mandate A.
This is solved making a multi-company record rule, not with company_dependent flag.
Multicompany record rule is set, and that is what prevents them to get mandate of other companies on logged company.
The easy way to prevent this error is delete this record rule, but the cure would therefore be worse than the disease.
If you try to replicate steps you can see it, it's hard to explain.
You are misunderstanding record rules then: they act as filters (part of the WHERE SQL clause), so when you browse a one2many, returned lines are prefiltered with this record rule, so there's no possibility to have incorrect mandates.
@pedrobaeza try to replicate steps, and then you will undestand de issue.
rule is: ''' ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] '''
Then If I have a bank account on partner, and one mandate for other company diferent than I logged, I can't see this mandate on logged company that is rigth, when I try to create other mandate for actual company then rule raise and exception. It's like odoo try to unlink mandates that are not in list view.
OK, I have been able to reproduce the problem, but it's due to a bug in the core, that as you say is trying to unlink the other mandate when you click save. You should make a PR to solve it in Odoo. The only bug I found in this repo code is in https://github.com/OCA/bank-payment/blob/8.0/account_banking_mandate/views/account_banking_mandate_view.xml#L36, whose domain doesn't make too much sense
Steps to replicate error:
To solve I'm trying to set "company_dependent=True" on field mandate_ids in res.partner.bank.