Odoo Hilfe

1

0
7 Answers
0
Avatar

Yenthe Van Ginneken

--Yenthe Van Ginneken--
22706
| 9 9 12
Turnhout, Belgien
--Yenthe Van Ginneken--

My Odoo training platform: https://www.oocademy.com
My Odoo blog: http://www.odoo.yenthevg.com/
My Twitter: https://twitter.com/Yenthe666

Yenthe Van Ginneken
09.03.16, 09:06

Hi guys,

Eventually I solved this by inheriting the default _track_subtype function from the module project_issue and by adding some custom code in it to fix my automatic e-mail. The code:

# We will inherit the default track_subtype function from the module project_issue # in order to send out our e-mail in the correct state. def _track_subtype(self, cr, uid, ids, init_values, context=None): res = super(project_issue, self)._track_subtype(cr, uid, ids, init_values, context=context) record = self.browse(cr, uid, ids[0], context=context) if record.stage_id.name == record.project_id.final_fase_id.name: """ This means the issue has entered its final stage and is done. We should now notify the user by e-mail of completion.""" template = self.pool.get('ir.model.data').get_object(cr, uid, 'your_module_name', 'template_email_id') mail_id = self.pool.get('mail.template').send_mail(cr, uid, template.id, record.id , force_send=True) if 'kanban_state' in init_values and record.kanban_state == 'blocked': return 'project_issue.mt_issue_blocked' elif 'kanban_state' in init_values and record.kanban_state == 'done': return 'project_issue.mt_issue_ready' elif 'user_id' in init_values and record.user_id: # assigned -> new return 'project_issue.mt_issue_new' elif 'stage_id' in init_values and record.stage_id and record.stage_id.sequence <= 1: # start stage -> new return 'project_issue.mt_issue_new' elif 'stage_id' in init_values: return 'project_issue.mt_issue_stage' return res


Yenthe

0
Avatar

Zbik

--Zbik--
12143
| 7 6 9
Łódź, Polen
--Zbik--


Zbik
18.02.16, 05:27

Probably one mail is sent by _track (stage change - see model project.issue ) and the second sending itself.

6 Comments
Yenthe Van Ginneken
18.02.16, 05:39

I was thinking about that too but then the question is how should I prevent this behaviour from only sending one email? I'd rather not create another field with a datetime just to validate one wasn't sent out seconds before..

Zbik
18.02.16, 05:44

You change _track conditions, or send only with _track.

Yenthe Van Ginneken
18.02.16, 06:05

@zbik which one is the best fit? It should send out one e-mail on creation only. How do i trigger the _track so that it only sends one?

Zbik
18.02.16, 07:30

Go to menu /Settings/Email/Subytpes and disable tracks for model.

Yenthe Van Ginneken
09.03.16, 07:49

@zbik it is indeed coming from the track (track_visbility as seen here: https://github.com/odoo/odoo/blob/9.0/addons/project_issue/project_issue.py#L162-L164) how should I correctly handle this? Should I override this Python function and re-write it to make the e-mail go off here or should I change some other behaviour? Any example / approach? I'm not sure how I should ideally handle this.

Yenthe Van Ginneken
09.03.16, 09:17

@zbik posted an example. What do you think of this approach?

Fragen Sie
Keep Informed
1 Verfolger
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now