Skip to content

11.0 mig base exception - #1025

Merged
pedrobaeza merged 8 commits into
OCA:11.0from
akretion:11.0-mig-base_exception
Dec 5, 2017
Merged

pedrobaeza merged 8 commits into
OCA:11.0from
akretion:11.0-mig-base_exception

Conversation

@mourad-ehm

Copy link
Copy Markdown
Contributor

MIG module base_exception and add test.

@pedrobaeza

Copy link
Copy Markdown
Member

Please squash some commits according https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests

@pedrobaeza pedrobaeza mentioned this pull request Oct 13, 2017
92 tasks
@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch 3 times, most recently from 351885c to 8bfb488 Compare October 16, 2017 15:12
@mourad-ehm

mourad-ehm commented Oct 17, 2017

Copy link
Copy Markdown
Contributor Author

Runbot is red but in runbot log I had a no error. Someone know why runbot is red ?
ping @pedrobaeza @jbeficent
log message:

`
2017-10-16 15:27:52,164 151 INFO openerp_test odoo.addons.base.module.module: ALLOW access to module.button_install on ['base_exception'] to user admin #1 via n/a
2017-10-16 15:27:52,278 151 INFO openerp_test odoo.modules.loading: loading 12 modules...
2017-10-16 15:27:52,346 151 INFO openerp_test odoo.modules.loading: 12 modules loaded in 0.07s, 0 queries
2017-10-16 15:27:52,349 151 INFO openerp_test odoo.modules.loading: loading 13 modules...
2017-10-16 15:27:52,572 151 WARNING openerp_test odoo.fields: Field base.exception.test.model.line.lead_id with unknown comodel_name 'base.exception.test.model'
2017-10-16 15:27:52,761 151 INFO openerp_test odoo.modules.registry: module base_exception: creating or updating database tables
2017-10-16 15:27:52,863 151 INFO openerp_test odoo.models: Storing computed values of base.exception.test.purchase.main_exception_id
2017-10-16 15:27:52,872 151 INFO openerp_test odoo.models: Storing computed values of base.exception.test.purchase.amount_total
2017-10-16 15:27:53,028 151 INFO openerp_test odoo.modules.loading: loading base_exception/security/base_exception_security.xml
2017-10-16 15:27:53,139 151 INFO openerp_test odoo.modules.loading: loading base_exception/security/ir.model.access.csv
2017-10-16 15:27:53,233 151 INFO openerp_test odoo.modules.loading: loading base_exception/wizard/base_exception_confirm_view.xml
2017-10-16 15:27:53,262 151 INFO openerp_test odoo.modules.loading: loading base_exception/views/base_exception_view.xml
2017-10-16 15:27:53,352 151 INFO openerp_test odoo.modules.loading: 13 modules loaded in 1.00s, 0 queries
2017-10-16 15:27:53,513 151 INFO openerp_test odoo.modules.loading: Modules loaded.
2017-10-16 15:27:53,515 151 INFO openerp_test odoo.models: Computing parent left and right for table ir_ui_menu...
2017-10-16 15:27:53,532 151 INFO openerp_test odoo.service.server: Initiating shutdown
2017-10-16 15:27:53,533 151 INFO openerp_test odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

Module test summary
�[1;32mSuccess�[0;m base_exception

+=======================================

Tests summary:
test_server.py �[1;32mSuccess�[0;m
+=======================================
`

@yajo

yajo commented Oct 17, 2017

Copy link
Copy Markdown
Member

Runbot had some problems recently, I just rebuilt it, let's see.

@mourad-ehm

mourad-ehm commented Oct 17, 2017

Copy link
Copy Markdown
Contributor Author

I rebuild runbot and had this error:
Unable to find image 'oca-server-tools:8bfb488_2' locally
docker: Error response from daemon: pull access denied for oca-server-tools, repository does not exist or may require 'docker login'.
See 'docker run --help'.

@pedrobaeza

Copy link
Copy Markdown
Member

It seems to be a problem with runbot. I have notified already @gurneyalex about it.

@mourad-ehm

Copy link
Copy Markdown
Contributor Author

Now runbot is build correctly but is still red, someone know why ? ping @gurneyalex @legalsylvain

@mourad-ehm mourad-ehm closed this Oct 24, 2017
@mourad-ehm mourad-ehm reopened this Oct 24, 2017
@pedrobaeza

Copy link
Copy Markdown
Member

See logs. You will find this warning:

2017-10-24 13:29:09,284 151 WARNING openerp_test odoo.fields: Field base.exception.test.model.line.lead_id with unknown comodel_name 'base.exception.test.model'

@JordiBForgeFlow

Copy link
Copy Markdown
Member

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.

@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch from 2ca58e9 to f9ad522 Compare November 23, 2017 08:20
@mourad-ehm

mourad-ehm commented Nov 23, 2017

Copy link
Copy Markdown
Contributor Author

Thanks @jbeficent. I integrated your commit.

@JordiBForgeFlow

Copy link
Copy Markdown
Member

@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch 3 times, most recently from deb3cdd to 2cbe214 Compare November 27, 2017 08:44
@bealdav

bealdav commented Nov 27, 2017

Copy link
Copy Markdown
Member

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

@hparfr hparfr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some remarks and questions

Comment thread base_exception/models/base_exception.py Outdated
active = fields.Boolean('Active')
next_state = fields.Char(
'Next state',
help="If we detect exception we set de state of object (ex purchase) "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set the state

Comment thread base_exception/models/base_exception.py Outdated
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 "

Copy link
Copy Markdown
Contributor

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)

Comment thread base_exception/models/base_exception.py Outdated
rule.model].fields_get()[
'state']['selection']
if rule.next_state\
not in [s[0] for s in select_vals]:

Copy link
Copy Markdown
Contributor

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

Comment thread base_exception/models/base_exception.py Outdated
@api.multi
def _popup_exceptions(self):
action = self._get_popup_action()
action = action.read()[0]

Copy link
Copy Markdown
Contributor

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

Comment thread base_exception/models/base_exception.py Outdated
'self': self.pool.get(rec._name),
'object': rec,
'obj': rec,
'pool': self.pool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old api ?

Copy link
Copy Markdown
Contributor Author

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

@rousseldenis rousseldenis Nov 27, 2017

Copy link
Copy Markdown
Contributor

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!

Comment thread base_exception/models/base_exception.py Outdated
if rule.next_state:
if not next_state_rule:
next_state_rule = rule
elif next_state_rule and\

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise instead of assert

@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch from 2cbe214 to b0f591f Compare November 27, 2017 14:37

@rousseldenis rousseldenis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

Comment thread base_exception/models/base_exception.py Outdated
'self': self.pool.get(rec._name),
'object': rec,
'obj': rec,
'pool': self.pool,

@rousseldenis rousseldenis Nov 27, 2017

Copy link
Copy Markdown
Contributor

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!

Comment thread base_exception/models/base_exception.py Outdated

@api.model
def _exception_rule_eval_context(self, obj_name, rec):
user = self.env['res.users'].browse(self._uid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user = self.env.user

Comment thread base_exception/models/base_exception.py Outdated
'obj': rec,
'pool': self.pool,
'cr': self._cr,
'uid': self._uid,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.env.user.id

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot

Comment thread base_exception/models/base_exception.py Outdated
'object': rec,
'obj': rec,
'pool': self.pool,
'cr': self._cr,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.env.cr

@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch from b0f591f to 736b73e Compare November 28, 2017 11:10
@mourad-ehm mourad-ehm closed this Dec 4, 2017
@mourad-ehm mourad-ehm reopened this Dec 4, 2017
@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch from cb443e9 to 785be4d Compare December 4, 2017 11:28
@mourad-ehm

Copy link
Copy Markdown
Contributor Author

Thanks @jbeficent, I integrated your commits.

@rousseldenis rousseldenis left a comment

Copy link
Copy Markdown
Contributor

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.

@mourad-ehm

Copy link
Copy Markdown
Contributor Author

OK, thanks @rousseldenis

@simahawk

simahawk commented Dec 4, 2017

Copy link
Copy Markdown
Contributor

@mourad-ehm remember to squash ;)

@mourad-ehm

mourad-ehm commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

Ok, thanks @simahawk. I done it.

@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch from 785be4d to f886227 Compare December 5, 2017 07:57
@mourad-ehm

Copy link
Copy Markdown
Contributor Author

Hi @pedrobaeza, could you merge this PR ?

@pedrobaeza

Copy link
Copy Markdown
Member

Can you please squash commits by author/logic set before merging?

@mourad-ehm
mourad-ehm force-pushed the 11.0-mig-base_exception branch from f886227 to 4342d25 Compare December 5, 2017 09:02
@mourad-ehm

Copy link
Copy Markdown
Contributor Author

Squash done.

@bealdav

bealdav commented Dec 5, 2017

Copy link
Copy Markdown
Member

@pedrobaeza thanks for the merge. No project in v11 at akretion for now.

It's just to help the community. Thanks

@pedrobaeza

Copy link
Copy Markdown
Member

Thank you! Much appreciated.

Merging.

@pedrobaeza
pedrobaeza merged commit b5409b9 into OCA:11.0 Dec 5, 2017
@bealdav
bealdav deleted the 11.0-mig-base_exception branch December 5, 2017 10:37
SiesslPhillip pushed a commit to grueneerde/OCA-server-tools that referenced this pull request Nov 20, 2024
[t133303] Update project branch with last fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.