-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Mig mgmtsystem action to v. 10.0 #168
Mig mgmtsystem action to v. 10.0 #168
Conversation
4158120
to
444c42c
Compare
444c42c
to
8953c4c
Compare
6efe004
to
d6fd8c7
Compare
I think this one is the next in the dependency graph. I relaunched travis which shows a lint error and a couple of test failures. |
@sbidoul thanks |
@sbidoul edit: |
c0f0e73
to
92b8004
Compare
rebased on OCA/10.0 |
5e8db9a
to
7f2b270
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.
Only code review.
Just didn't review all the new features as I don't know what it's supposed to do, and I'm not sure a migration PR is the best place for it.
@@ -136,15 +136,25 @@ def create(self, vals): | |||
"""Creation of Action.""" | |||
Sequence = self.env['ir.sequence'] | |||
vals['reference'] = Sequence.next_by_code('mgmtsystem.action') | |||
action = super(MgmtSystemAction, self).create(vals) | |||
self.send_mail_for_action(action) |
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.
Why not send the email ?
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.
@grindtildeath
That was a sunday miskate, thanks for the spot my friend :D
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.
Correction: This was not an mistake, this is removed because of the new feature introduced in project module in V10.0, which I adapted in this module.
Its this method: _track_template(self, tracking):
checks if stage_id has been changed and sends the mail template that is associated to the stage.
Big advantage in comparison to the old method is that you can choose which stages send notifications for actions. In the old method the notifications were allways send regardles if you wanted it or not.
def write(self, vals): | ||
"""Update user data.""" | ||
if vals.get('stage_id'): | ||
stage_new = self._get_stage_new() |
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.
Why change method names ?
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.
Hi @grindtildeath
I changed the methods name because stage_new() implies creating a new stage, the name does not imply on the methods intention to retrive the default stage from the database.
So if possible i would like to stay consistent to the odoo core modules with stage_default or something like get_default_stage_id so that the methods name at least contains the word default in it.
I chose _default_stage since this was the shortest method name fullfillig the requirement of not beein missleading.
/opt/odoo/10/srv/addons/crm/tests/test_lead2opportunity.py: 'stage_id': default_stage_id
[('is_starting', '=', True)], | ||
limit=1) | ||
return ( | ||
self.env.ref('mgmtsystem_action.stage_draft', False) or |
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.
Why change the default behaviour ? I suppose we should be able not to use stage_draft as default (is_starting=True).
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.
@grindtildeath
The prior version of the method returned the xmlid of the stage, stage_draft, meaning the stage with id stage_draft had to be present at all times in the database for the create method to work, now if a manager user deletes the stage with the id stage_draft it can no longer be retrieved by the method and create method for new records fails. So this new method checks for there being a stage with id stage_draft and if this stage is not present it returns the stage that has the bool field as being the starting stage.
from datetime import datetime, timedelta | ||
|
||
|
||
class MgmtSystemAction(models.Model): | ||
class MgmtsystemAction(models.Model): |
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.
Please don't change class names for compatibility.
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.
@grindtildeath
Did you try it out? The modules names are seperated by a dot .
So in class MgmtsystemAction
field _name is written as name = "mgmtsystem.action"
the casecamel has to bee accordingly or it throwse an error
_inherit = ['mail.thread', 'ir.needaction_mixin'] | ||
_order = "date_deadline desc" | ||
_track = { |
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.
What is this supposed to do ?
is_ending = fields.Boolean('Ending stage') | ||
sequence = fields.Integer( | ||
'Sequence', default=1, help="Used to order stages. Lower is better.") |
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.
Please keep default behaviour (default=100)
case_default = fields.Boolean('Common to All Teams') | ||
is_starting = fields.Boolean( | ||
string='Is starting Stage', | ||
help="select stis checkbox if this is the default stage \n" |
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.
"Select this checkbox if this is default stage." (it might for for something else than nonconformities)
<field name="arch" type="xml"> | ||
<tree string="Action Stage"> | ||
<field name="name"/> | ||
<field name="sequence" widget="handle" groups="base.group_no_one"/> |
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.
Why define this group here ?
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.
@grindtildeath
thats also not needed, since ill be splitting migration code and new features, this will be left out as well.
Thanks again for the good review...
Also thanks to @sbidoul for spotting the linting errors and the test failures.
As for the failures im still working on it.
@eugen-don thanks for your work around here. To facilitate review and accelerate the migration, perhaps could you do a first PR for the migration, and then a second one with the new features? |
I see the new features cause some confusion on the review. ILl split the code this week in 2 PRs one just the migration and an aditional one for the new features.. |
@eugen-don thanks! Let me know when it's done, it's should be mergeable quickly so we can move forward with the rest while the feature improvement is fine-tuned. |
@eugen-don |
d15350a
to
fece5c2
Compare
d7129f8
to
7b8e6ff
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.
When the action is closed, all the fields should be readonly.
Otherwise 👍
Hi @max3903 it allready was fixed but i removed it since some people told me to put improvements in a different PR. IMO its an improvement since in v 9.0 you can edit all fields in closed actions. Should i first make a fix for v 9.0 and do a PR there? or else we have new code here that cant be compared against v 9.0 when reviewing... |
@eugen-don IMO keep improvements in other PRs so we can expedite migration and start collaborating on improvements. |
for action in self: | ||
template.send_mail(action.id, force_send=force_send) | ||
self.env['mail.template'].browse(template.id).send_mail( | ||
action.id, force_send=force_send) |
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.
@eugen-don why do you rmove the for action
loop?
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.
@sbidoul Hi
The mails are send on record creation, there is no need for a looping.
I actually wanted to preserve the looping since i wasnt sure about its purpose...
So i did some extensive testin just to figure out that the looping prevented the mails from beeing send on record creation
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.
Ah I see it receives the action as argument. Then it must be @api.model
since this method does not act on a recordset.
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.
you think we should use model here instead of multi?
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.
yes, it's mechanical: if you have @api.multi, you must have either ensure_one or iterate over the recordset, in this case you don't so @api.model correctly expresses this is a method that does not act on a recordset of actions
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... thats a good explanation... ill do a quick test and change this
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.
Just a small improvement, otherwise looks good ! Thanks again for your work.
template = self.env.ref( | ||
'mgmtsystem_action.email_template_new_action_reminder') | ||
for action in self: | ||
template.send_mail(action.id, force_send=force_send) | ||
self.env['mail.template'].browse(template.id).send_mail( |
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.
As template is a recordset there's no use of browsing mail.template.
You can simply use : template.send_mail()
Otherwise it makes an unnecessary select in DB.
@@ -219,5 +209,5 @@ def process_reminder_queue(self, reminder_days=10): | |||
template = self.env.ref( | |||
'mgmtsystem_action.action_email_template_reminder_action') | |||
for action in action_ids: | |||
template.send_mail(action.id, force_send=True) | |||
self.env['mail.template'].browse(template.id).send_mail(action.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.
Same as before.
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.
@grindtildeath Thanks for the spot
Im dooing too much copy paste lately :D
MIG mgmtsystem_action to V. 10.0
d563ce2
to
8ee1cbf
Compare
Thanks! |
thnaks for your support guys |
Mig mgmtsystem action to v. 10.0
depends: