-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
11.0 mig base exception #1025
11.0 mig base exception #1025
Conversation
Please squash some commits according https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests |
351885c
to
8bfb488
Compare
Runbot is red but in runbot log I had a no error. Someone know why runbot is red ? `
|
Tests summary: |
---|
test_server.py �[1;32mSuccess�[0;m |
+======================================= |
` |
Runbot had some problems recently, I just rebuilt it, let's see. |
I rebuild runbot and had this error: |
It seems to be a problem with runbot. I have notified already @gurneyalex about it. |
Now runbot is build correctly but is still red, someone know why ? ping @gurneyalex @legalsylvain |
See logs. You will find this warning:
|
I have proposed small fixes here: https://github.com/Eficent/server-tools/tree/11.0-mig-base_exception But cannot make a PR, the PR does not allow me to select the Akretion repo. |
2ca58e9
to
f9ad522
Compare
Thanks @jbeficent. I integrated your commit. |
@mourad-ehm I still added another commit ForgeFlow@b66bddf in https://github.com/Eficent/server-tools/tree/11.0-mig-base_exception. |
deb3cdd
to
2cbe214
Compare
Here codecov is 55% but other tests coverage in purchase_exception will cover other parts of the code of this module. Then I think it's mergeable as it. Thanks @mourad-ehm for this work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some remarks and questions
active = fields.Boolean('Active') | ||
next_state = fields.Char( | ||
'Next state', | ||
help="If we detect exception we set de state of object (ex purchase) " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set the state
code = fields.Text( | ||
'Python Code', | ||
help="Python code executed to check if the exception apply or " | ||
"not. The code must apply block = True to apply the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block = True
or failed = True
(code.default)
rule.model].fields_get()[ | ||
'state']['selection'] | ||
if rule.next_state\ | ||
not in [s[0] for s in select_vals]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put comprehension list out of if
clause to add readability
@api.multi | ||
def _popup_exceptions(self): | ||
action = self._get_popup_action() | ||
action = action.read()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge in one line or use different variable names
'self': self.pool.get(rec._name), | ||
'object': rec, | ||
'obj': rec, | ||
'pool': self.pool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old api ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not old API but variables which can use in Python code with safe_eval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mourad-ehm self.pool is not meant to be used.
I see it was migrated in v10 like that but it's incorrect. Use self.env[rec._name] and 'env': self.env instead of pool.
But I think changing function to @api.multi and returning {'self': self} should be sufficent. So, you can change the function signature removing obj_name and rec parameters!
if rule.next_state: | ||
if not next_state_rule: | ||
next_state_rule = rule | ||
elif next_state_rule and\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless next_state_rule condition (because of else)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not next_state_rule or rule.sequence < next_state_rule.sequence
next_state_rule = rule
current_model = self._context.get('active_model') | ||
model_except_obj = self.env[current_model] | ||
active_ids = self._context.get('active_ids') | ||
assert len(active_ids) == 1, "Only 1 ID accepted, got %r" % active_ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise instead of assert
2cbe214
to
b0f591f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review
'self': self.pool.get(rec._name), | ||
'object': rec, | ||
'obj': rec, | ||
'pool': self.pool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mourad-ehm self.pool is not meant to be used.
I see it was migrated in v10 like that but it's incorrect. Use self.env[rec._name] and 'env': self.env instead of pool.
But I think changing function to @api.multi and returning {'self': self} should be sufficent. So, you can change the function signature removing obj_name and rec parameters!
|
||
@api.model | ||
def _exception_rule_eval_context(self, obj_name, rec): | ||
user = self.env['res.users'].browse(self._uid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user = self.env.user
'obj': rec, | ||
'pool': self.pool, | ||
'cr': self._cr, | ||
'uid': self._uid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.env.user.id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought self._cr
, self._uid
were shortcuts for self.env.cr, etc.
Are they now deprecated ?
Thanks for your review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bealdav See https://github.com/odoo/odoo/blob/ecbf7aa4714479229658d14cce28fa00376ed390/odoo/models.py#L4254
They are kept for backward compatibility but their future is not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot
'object': rec, | ||
'obj': rec, | ||
'pool': self.pool, | ||
'cr': self._cr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.env.cr
b0f591f
to
736b73e
Compare
cb443e9
to
785be4d
Compare
Thanks @jbeficent, I integrated your commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review.
Should add more tests on roadmap to improve coverage.
OK, thanks @rousseldenis |
@mourad-ehm remember to squash ;) |
Ok, thanks @simahawk. I done it. |
785be4d
to
f886227
Compare
Hi @pedrobaeza, could you merge this PR ? |
Can you please squash commits by author/logic set before merging? |
* Fix menu in base_exception * Fix base_exception/views/base_exception_view.xml
…lled by constraint methods 'detect_exception' can be called on an empty recordset.
f886227
to
4342d25
Compare
Squash done. |
@pedrobaeza thanks for the merge. No project in v11 at akretion for now. It's just to help the community. Thanks |
Thank you! Much appreciated. Merging. |
[t133303] Update project branch with last fixes
MIG module base_exception and add test.