Simplified logic. - #3
Closed
yajo wants to merge 2 commits into
Closed
Conversation
| def _wrap_name_create(): | ||
| def wrapper(self, cr, uid, name, context=None): | ||
| def _wrap_name_create(self, cr, uid, name, context=None): | ||
| if self.pool.get(self._name).avoid_quick_create: |
Owner
There was a problem hiding this comment.
Thank you @yajo
but avoid_quick_create is not a field of the patched model: it is a field of ir.model.
So, I tried with
def _patch_quick_create(self, cr, ids):
def _wrap_name_create(self, cr, uid, name, context=None):
model_pool = self.pool['ir.model']
model_record_ids = model_pool.search(cr, uid, [
('model', '=', self._name),
], context=context)
model_record = model_pool.browse(
cr, uid, model_record_ids[0], context)
if model_record.avoid_quick_create:
raise orm.except_orm(
_('Error'),
_("Can't create quickly. Opening create form"))
else:
return _wrap_name_create.origin(
self, cr, uid, name, context=context)
for model in self.browse(cr, SUPERUSER_ID, ids):
self.pool.get(model.model)._patch_method(
'name_create', _wrap_name_create)
return True
but got
server-tools/base_optional_quick_create/model.py", line 47, in _wrap_name_create
self, cr, uid, name, context=context)
TypeError: unbound method name_create() must be called with workflow.workitem instance as first argument (got res.partner.title instance instead)
Owner
There was a problem hiding this comment.
server-tools/base_optional_quick_create/model.py", line 41, in wrapper
return _wrap_name_create.origin(
AttributeError: 'function' object has no attribute 'origin'
eLBati
pushed a commit
that referenced
this pull request
Apr 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code explains better by itself that comments.