From ce39ffe9271261cdc52b76e3bc981d177f7a6693 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 12 Sep 2012 16:52:45 +0530 Subject: [PATCH 01/24] [IMP]changed as per new spec update and make it work for crm changes done in crm bzr revid: sgo@tinyerp.com-20120912112245-3cp03024fiqb47qs --- addons/crm/crm_lead.py | 18 ++-- addons/crm/crm_lead_data.xml | 28 +++--- addons/mail/data/mail_data.xml | 10 --- addons/mail/mail_message.py | 45 +++------- addons/mail/mail_message_subtype.py | 8 +- addons/mail/mail_message_subtype.xml | 5 +- addons/mail/mail_thread.py | 41 ++++++--- addons/mail/static/src/js/mail_followers.js | 64 +++++-------- addons/mail/tests/test_mail.py | 99 ++++++--------------- 9 files changed, 106 insertions(+), 212 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b7cc0f840d9..6b04be2244d 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -27,15 +27,13 @@ import time import tools from tools.translate import _ -from base.res.res_partner import format_address - CRM_LEAD_PENDING_STATES = ( crm.AVAILABLE_STATES[2][0], # Cancelled crm.AVAILABLE_STATES[3][0], # Done crm.AVAILABLE_STATES[4][0], # Pending ) -class crm_lead(base_stage, format_address, osv.osv): +class crm_lead(base_stage, osv.osv): """ CRM Lead Case """ _name = "crm.lead" _description = "Lead/Opportunity" @@ -107,12 +105,6 @@ class crm_lead(base_stage, format_address, osv.osv): return result, fold - def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - res = super(crm_lead,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - if view_type == 'form': - res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context) - return res - _group_by_full = { 'stage_id': _read_group_stage_ids } @@ -842,7 +834,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), mail_subtype_new="crm_subtype_stage_change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -852,16 +844,16 @@ class crm_lead(base_stage, format_address, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [id], body=message, subtype_xml_id="crm_subtype_new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_post(cr, uid, ids, body=message,subtype="lost", context=context) + return self.message_post(cr, uid, ids, body=message,subtype_xml_id="crm_subtype_lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_post(cr, uid, ids, body=message, subtype="won", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="crm_subtype_won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 9b3f5d7ec75..252e843cf30 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,32 +155,24 @@ - + new - + crm.lead - + won - + crm.lead - + lost - - - - stage change - + crm.lead - - - - - - - - + + stage change + crm.lead + diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 80aff038dac..8e2af38f2ea 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -13,18 +13,8 @@ - - other - - - - - email - - comment - diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 686f3e3d381..9e228083b1b 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -20,13 +20,11 @@ ############################################################################## import logging -import openerp import tools from email.header import decode_header from operator import itemgetter from osv import osv, fields -from tools.translate import _ _logger = logging.getLogger(__name__) @@ -37,7 +35,6 @@ def decode(text): text = decode_header(text.replace('\r', '')) return ''.join([tools.ustr(x[0], x[1]) for x in text]) - class mail_message(osv.Model): """ Messages model: system notification (replacing res.log notifications), comments (OpenChatter discussion) and incoming emails. """ @@ -60,10 +57,7 @@ class mail_message(osv.Model): for message in self.browse(cr, uid, ids, context=context): if not message.model or not message.res_id: continue - try: - result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]) - except openerp.exceptions.AccessDenied, e: - pass + result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]) return result def _get_unread(self, cr, uid, ids, name, arg, context=None): @@ -154,7 +148,7 @@ class mail_message(osv.Model): def _message_dict_get(self, cr, uid, msg, context=None): """ Return a dict representation of the message browse record. """ - attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] + attachment_ids = self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context) author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] author_user_id = self.pool.get('res.users').name_get(cr, uid, [msg.author_id.user_ids[0].id], context=context)[0] partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) @@ -313,15 +307,15 @@ class mail_message(osv.Model): def unlink(self, cr, uid, ids, context=None): # cascade-delete attachments that are directly attached to the message (should only happen - # for mail.messages that act as parent for a standalone mail.mail record). + # for mail.messages that act as parent for a standalone mail.mail record. attachments_to_delete = [] - for message in self.browse(cr, uid, ids, context=context): - for attach in message.attachment_ids: - if attach.res_model == self._name and attach.res_id == message.id: + for mail in self.browse(cr, uid, ids, context=context): + for attach in mail.attachment_ids: + if attach.res_model == 'mail.message' and attach.res_id == mail.id: attachments_to_delete.append(attach.id) if attachments_to_delete: self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) - return super(mail_message, self).unlink(cr, uid, ids, context=context) + return super(mail_message,self).unlink(cr, uid, ids, context=context) def notify(self, cr, uid, newid, context=None): """ Add the related record followers to the destination partner_ids. @@ -344,6 +338,9 @@ class mail_message(osv.Model): follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) if follow_ids and len(follow_ids): missing_follow_ids.append(p_id) + subtype_record = self.pool.get('mail.message.subtype').browse(cr, uid, message.subtype_id.id,context=context) + if not subtype_record.res_model: + missing_follow_ids.append(p_id) message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) @@ -354,25 +351,3 @@ class mail_message(osv.Model): default = {} default.update(message_id=False, headers=False) return super(mail_message, self).copy(cr, uid, id, default=default, context=context) - - #------------------------------------------------------ - # Tools - #------------------------------------------------------ - - def check_partners_email(self, cr, uid, partner_ids, context=None): - """ Verify that selected partner_ids have an email_address defined. - Otherwise throw a warning. """ - partner_wo_email_lst = [] - for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids, context=context): - if not partner.email: - partner_wo_email_lst.append(partner) - if not partner_wo_email_lst: - return {} - warning_msg = _('The following partners chosen as recipients for the email have no email address linked :') - for partner in partner_wo_email_lst: - warning_msg += '\n- %s' % (partner.name) - return {'warning': { - 'title': _('Partners email addresses not found'), - 'message': warning_msg, - } - } diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 2330e34e1d3..6eb349fc71e 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -29,15 +29,9 @@ class mail_message_subtype(osv.osv): _columns = { 'name': fields.char('Message Subtype ', size = 128, required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), - 'model_ids': fields.many2many('ir.model', - 'mail_message_subtyp_message_rel', - 'message_subtype_id', 'model_id', 'Model', - help = "link some subtypes to several models, for projet/task"), + 'res_model': fields.char('Model',size = 128, help = "link subtype to model"), 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), } _defaults = { 'default': True, } - _sql_constraints = [ - ('name_uniq', 'unique (name)', 'The name of the message subtype must be unique !') - ] diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 0bfdc2cad95..7d0eed2f4da 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -14,7 +14,7 @@ - + @@ -30,13 +30,12 @@ + - - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 87c2e22d46b..23c038ce692 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,7 +562,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype='comment', context=None, **kwargs): + type='notification', parent_id=False, attachments=None, subtype_xml_id='mail_subtype_comment', context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. @@ -599,12 +599,13 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') - if subtype: - subtypes = subtype_obj.name_search(cr, uid, subtype,context=context) - if len(subtypes): - subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0],context=context) - if self._name in [model.model for model in subtype_browse.model_ids]: - values['subtype_id']=subtype_browse.id + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) + if subtype_xml_id: + subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) + if self._name == subtype_browse.res_model: + values['subtype_id']=subtype_browse.id + else: + values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, 'res_id': thread_id or False, @@ -628,14 +629,20 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): - """ Add partners to the records followers. """ + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids = None, context=None): + """ Add partners to the records followers. + :param partner_ids: a list of partner_ids to subscribe + :param return: new value of followers if read_back key in context + """ + self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)],context=context) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('res_model', '=', self._name)],context=context) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - return self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + if context and context.get('read_back'): + return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + return [] def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not @@ -645,8 +652,14 @@ class mail_thread(osv.AbstractModel): return self.message_unsubscribe(cr, uid, ids, partner_ids, context=context) def message_unsubscribe(self, cr, uid, ids, partner_ids, context=None): - """ Remove partners from the records followers. """ - return self.write(cr, uid, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) + """ Remove partners from the records followers. + :param partner_ids: a list of partner_ids to unsubscribe + :param return: new value of followers if read_back key in context + """ + self.write(cr, uid, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) + if context and context.get('read_back'): + return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + return [] #------------------------------------------------------ # Thread state @@ -679,6 +692,6 @@ class mail_thread(osv.AbstractModel): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): followers_obj = self.pool.get('mail.followers') followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 2126d60edf0..b1d62b76a62 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,12 +33,20 @@ openerp_mail_followers = function(session, mail) { }, start: function() { - // use actual_mode property on view to know if the view is in create mode anymore + var self = this; + // NB: all the widget should be modified to check the actual_mode property on view, not use + // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); + this.$el.find('ul.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) + this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype();}) + .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) + .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); + this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) + .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) + .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); - this.bind_events(); }, _check_visibility: function() { @@ -46,40 +54,14 @@ openerp_mail_followers = function(session, mail) { if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, + destroy: function () { + this._super.apply(this, arguments); + }, + reinit: function() { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').hide(); - }, - - bind_events: function() { - var self = this; - this.$('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) - .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.fetch_subtype(); }); - this.$el.on('click','ul.oe_mail_recthread_subtype', function () {self.update_subtype();}) - this.$el.on('click', 'button.oe_mail_button_invite', function(event) { - action = { - type: 'ir.actions.act_window', - res_model: 'mail.wizard.invite', - view_mode: 'form', - view_type: 'form', - views: [[false, 'form']], - target: 'new', - context: { - 'default_res_model': self.view.dataset.model, - 'default_res_id': self.view.datarecord.id - }, - } - self.do_action(action, function() { self.read_value(); }); - }); - }, - - read_value: function() { - var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { - return results[0].message_follower_ids; - }).pipe(this.proxy('set_value')); + // this.$el.find('ul.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -89,11 +71,11 @@ openerp_mail_followers = function(session, mail) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } - return this.fetch_followers(value_ || this.get_value()); + return this.fetch_followers(value_); }, fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + return this.ds_follow.call('read', [value_ || this.get_value(), ['name', 'user_ids']]).then(this.proxy('display_followers')); }, /** Display the followers, evaluate is_follower directly */ @@ -103,7 +85,7 @@ openerp_mail_followers = function(session, mail) { var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { - record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); + record.avatar_url = mail.ChatterUtils.get_image(self.session.prefix, self.session.session_id, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); if (this.message_is_follower) { @@ -149,22 +131,22 @@ openerp_mail_followers = function(session, mail) { }, do_follow: function () { - var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); + var context = new session.web.CompoundContext(this.build_context(), {'read_back': true}); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value')); }, //fetch subtype from subtype model fetch_subtype: function () { var self = this - var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + var subtype_object = this.sub_model.call('search', [[['res_model','=',this.view.model]]]); subtype_object.then(function (subtype_ids){ self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); }); }, do_unfollow: function () { - var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); + var context = new session.web.CompoundContext(this.build_context(), {'read_back': true}); + return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value')); }, }); }; diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 5da3456abe9..0ed1d2b38c0 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -19,8 +19,6 @@ # ############################################################################## -import tools - from openerp.tests import common from openerp.tools.html_sanitize import html_sanitize @@ -31,7 +29,7 @@ Received: by mail1.openerp.com (Postfix, from userid 10002) From: Sylvie Lelitre Subject: {subject} MIME-Version: 1.0 -Content-Type: multipart/alternative; +Content-Type: multipart/alternative; boundary="----=_Part_4200734_24778174.1344608186754" Date: Fri, 10 Aug 2012 14:16:26 +0000 Message-ID: <1198923581.41972151344608186760.JavaMail@agrolait.com> @@ -54,9 +52,9 @@ Content-Transfer-Encoding: quoted-printable =20 =20 - +

Please call me as soon as possible this afternoon!

- +

--
Sylvie

@@ -84,42 +82,15 @@ Sylvie """ -class TestMailMockups(common.TransactionCase): +class test_mail(common.TransactionCase): def _mock_smtp_gateway(self, *args, **kwargs): return True - def _init_mock_build_email(self): - self._build_email_args_list = [] - self._build_email_kwargs_list = [] - def _mock_build_email(self, *args, **kwargs): - self._build_email_args_list.append(args) - self._build_email_kwargs_list.append(kwargs) - return self._build_email(*args, **kwargs) - - def setUp(self): - super(TestMailMockups, self).setUp() - # Install mock SMTP gateway - self._init_mock_build_email() - self._build_email = self.registry('ir.mail_server').build_email - self.registry('ir.mail_server').build_email = self._mock_build_email - self._send_email = self.registry('ir.mail_server').send_email - self.registry('ir.mail_server').send_email = self._mock_smtp_gateway - - def tearDown(self): - # Remove mocks - self.registry('ir.mail_server').build_email = self._build_email - self.registry('ir.mail_server').send_email = self._send_email - super(TestMailMockups, self).tearDown() - - -class test_mail(TestMailMockups): - - def _mock_send_get_mail_body(self, *args, **kwargs): - # def _send_get_mail_body(self, cr, uid, mail, partner=None, context=None) - body = tools.append_content_to_html(args[2].body_html, kwargs.get('partner').name if kwargs.get('partner') else 'No specific partner') - return body + self._build_email_args = args + self._build_email_kwargs = kwargs + return self.build_email_real(*args, **kwargs) def setUp(self): super(test_mail, self).setUp() @@ -135,9 +106,10 @@ class test_mail(TestMailMockups): self.res_users = self.registry('res.users') self.res_partner = self.registry('res.partner') - # Mock send_get_mail_body to test its functionality without other addons override - self._send_get_mail_body = self.registry('mail.mail').send_get_mail_body - self.registry('mail.mail').send_get_mail_body = self._mock_send_get_mail_body + # Install mock SMTP gateway + self.build_email_real = self.registry('ir.mail_server').build_email + self.registry('ir.mail_server').build_email = self._mock_build_email + self.registry('ir.mail_server').send_email = self._mock_smtp_gateway # groups@.. will cause the creation of new mail groups self.mail_group_model_id = self.ir_model.search(self.cr, self.uid, [('model', '=', 'mail.group')])[0] @@ -147,11 +119,6 @@ class test_mail(TestMailMockups): self.group_pigs_id = self.mail_group.create(self.cr, self.uid, {'name': 'Pigs', 'description': 'Fans of Pigs, unite !'}) - def tearDown(self): - # Remove mocks - self.registry('mail.mail').send_get_mail_body = self._send_get_mail_body - super(test_mail, self).tearDown() - def test_00_message_process(self): cr, uid = self.cr, self.uid # Incoming mail creates a new mail_group "frogs" @@ -187,7 +154,7 @@ class test_mail(TestMailMockups): test_msg_id = '' mail_text = MAIL_TEMPLATE_PLAINTEXT.format(to='groups@example.com', subject='frogs', extra='', msg_id=test_msg_id) self.mail_thread.message_process(cr, uid, None, mail_text) - new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id', '=', test_msg_id)])[0]) + new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id','=',test_msg_id)])[0]) self.assertEqual(new_mail.body, '\n

\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n
\n', 'plaintext mail incorrectly parsed') @@ -308,20 +275,18 @@ class test_mail(TestMailMockups): _attachments = [('First', 'My first attachment'), ('Second', 'My second attachment')] # CASE1: post comment, body and subject specified - self._init_mock_build_email() msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment') message = self.mail_message.browse(cr, uid, msg_id) - sent_emails = self._build_email_kwargs_list + sent_email = self._build_email_kwargs # Test: notifications have been deleted self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is _subject, body is _body1 (no formatting done) self.assertEqual(message.subject, _subject, 'mail.message subject incorrect') self.assertEqual(message.body, _body1, 'mail.message body incorrect') - # Test: sent_email: email send by server: correct subject, body, body_alternative - for sent_email in sent_emails: - self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') - self.assertEqual(sent_email['body'], _mail_body1 + '\n
Bert Tartopoils
\n', 'sent_email body incorrect') - self.assertEqual(sent_email['body_alternative'], _mail_bodyalt1 + '\nBert Tartopoils', 'sent_email body_alternative is incorrect') + # Test: sent_email: email send by server: correct subject, body; body_alternative + self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') + self.assertEqual(sent_email['body'], _mail_body1, 'sent_email body incorrect') + self.assertEqual(sent_email['body_alternative'], _mail_bodyalt1, 'sent_email body_alternative is incorrect') # Test: mail_message: partner_ids = group followers message_pids = set([partner.id for partner in message.partner_ids]) test_pids = set([p_a_id, p_b_id, p_c_id]) @@ -331,16 +296,14 @@ class test_mail(TestMailMockups): notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'mail.message notification partners incorrect') # Test: sent_email: email_to should contain b@b, not c@c (pref email), not a@a (writer) - for sent_email in sent_emails: - self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') + self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') # CASE2: post an email with attachments, parent_id, partner_ids # TESTS: automatic subject, signature in body_html, attachments propagation - self._init_mock_build_email() msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', partner_ids=[(6, 0, [p_d_id])], parent_id=msg_id, attachments=_attachments) message = self.mail_message.browse(cr, uid, msg_id2) - sent_emails = self._build_email_kwargs_list + sent_email = self._build_email_kwargs self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id2)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is False, body is _body2 (no formatting done), parent_id is msg_id @@ -348,11 +311,9 @@ class test_mail(TestMailMockups): self.assertEqual(message.body, html_sanitize(_body2), 'mail.message body incorrect') self.assertEqual(message.parent_id.id, msg_id, 'mail.message parent_id incorrect') # Test: sent_email: email send by server: correct subject, body, body_alternative - self.assertEqual(len(sent_emails), 2, 'sent_email number of sent emails incorrect') - for sent_email in sent_emails: - self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') - self.assertIn(_mail_body2, sent_email['body'], 'sent_email body incorrect') - self.assertIn(_mail_bodyalt2, sent_email['body_alternative'], 'sent_email body_alternative incorrect') + self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') + self.assertEqual(sent_email['body'], _mail_body2, 'sent_email body incorrect') + self.assertEqual(sent_email['body_alternative'], _mail_bodyalt2, 'sent_email body_alternative incorrect') # Test: mail_message: partner_ids = group followers message_pids = set([partner.id for partner in message.partner_ids]) test_pids = set([p_a_id, p_b_id, p_c_id, p_d_id]) @@ -362,8 +323,7 @@ class test_mail(TestMailMockups): notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'mail.message notification partners incorrect') # Test: sent_email: email_to should contain b@b, c@c, not a@a (writer) - for sent_email in sent_emails: - self.assertTrue(set(sent_email['email_to']).issubset(set(['b@b', 'c@c'])), 'sent_email email_to incorrect') + self.assertEqual(set(sent_email['email_to']), set(['b@b', 'c@c']), 'sent_email email_to incorrect') # Test: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') @@ -450,14 +410,12 @@ class test_mail(TestMailMockups): self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message incorrect content_subtype') # 2. Post the comment, get created message - parent_id = message.id mail_compose.send_mail(cr, uid, [compose_id]) group_pigs.refresh() message = group_pigs.message_ids[0] - # Test: mail.message: subject as Re:.., body in html, parent_id + # Test: mail.message: subject as Re:.., body in html self.assertEqual(message.subject, _msg_reply, 'mail.message incorrect subject') self.assertIn('Administrator wrote:
Pigs rules
', message.body, 'mail.message body is incorrect') - self.assertEqual(message.parent_id and message.parent_id.id, parent_id, 'mail.message parent_id incorrect') # Test: mail.message: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') @@ -501,7 +459,6 @@ class test_mail(TestMailMockups): # It will be updated as soon as we have fixed specs ! cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - def _compare_structures(struct1, struct2, n=0): # print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') @@ -673,10 +630,10 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype='email') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message - msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') - notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) - self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") +# msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') +# notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) +# self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From 6f0b8abe3159831e67434c5938bc867a98b462dd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:05:40 +0530 Subject: [PATCH 02/24] [IMP]account,project,project_issue: changed as per new spec bzr revid: sgo@tinyerp.com-20120913053540-atfsrw8bkf16qo3t --- addons/account/account_invoice.py | 33 ++++++------- addons/account/data/account_data.xml | 26 +++++----- addons/account_voucher/account_voucher.py | 8 ++-- .../account_voucher/account_voucher_data.xml | 21 +++------ addons/analytic/analytic.py | 18 ++++++- addons/base_status/base_stage.py | 14 +++++- addons/project/project.py | 21 ++++----- addons/project/project_data.xml | 47 ++++++++++--------- addons/project_issue/project_issue.py | 4 +- addons/project_issue/project_issue_data.xml | 25 ++++------ 10 files changed, 109 insertions(+), 108 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 9dcbd877c67..8a7251b3856 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -395,23 +395,18 @@ class account_invoice(osv.osv): template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = dict(context) - ctx.update({ - 'default_model': 'account.invoice', - 'default_res_id': ids[0], - 'default_use_template': True, - 'default_template_id': template_id, - }) + ctx = dict(context, active_model='account.invoice', active_id=ids[0]) + ctx.update({'mail.compose.template_id': template_id}) return { - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'mail.compose.message', - 'views': [(res_id, 'form')], - 'view_id': res_id, - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': ctx, - 'nodestroy': True, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(res_id, 'form')], + 'view_id': res_id, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': ctx, + 'nodestroy': True, } def confirm_paid(self, cr, uid, ids, context=None): @@ -1306,15 +1301,15 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype_xml_id="analytic_subtype_new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype="paid", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context) account_invoice() class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index bf3b3152552..22849a9b886 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,28 +560,24 @@ Invoice account.invoice
- + new - + account.analytic.account - + + new + account.invoice + + + paid - + account.invoice - + cancelled - + account.invoice - - - - - - - - - diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index ae670b3d0b7..d2976882981 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1045,8 +1045,6 @@ class account_voucher(osv.osv): # if the amount encoded in voucher is equal to the amount unreconciled, we need to compute the # currency rate difference if line.amount == line.amount_unreconciled: - if not line.move_line_id.amount_residual: - raise osv.except_osv(_('Wrong bank statement line'),_("You have to delete the bank statement line which the payment was reconciled to manually. Please check the payment of the partner %s by the amount of %s.")%(line.voucher_id.partner_id.name, line.voucher_id.amount)) currency_rate_difference = line.move_line_id.amount_residual - amount else: currency_rate_difference = 0.0 @@ -1295,17 +1293,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_post(cr, uid, [obj.id], body=message, subtype="post", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="reconcile", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_reconcile", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index a99a8735842..dd46a83777e 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -13,27 +13,18 @@ If you want to use advanced accounting features, you should install the "Account Module eInvoicing & Payments has been installed. - - + + account.voucher - + post - + account.voucher - + reconcile - + account.voucher - - - - - - - - - diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index a44fcb01653..776df713b4e 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -96,6 +96,22 @@ class account_analytic_account(osv.osv): res[row['id']][field] = row[field] return self._compute_level_tree(cr, uid, ids, child_ids, res, fields, context) + def name_get(self, cr, uid, ids, context=None): + if isinstance(ids, (int, long)): + ids=[ids] + if not ids: + return [] + res = [] + for account in self.browse(cr, uid, ids, context=context): + data = [] + acc = account + while acc: + data.insert(0, acc.name) + acc = acc.parent_id + data = ' / '.join(data) + res.append((account.id, data)) + return res + def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = self.name_get(cr, uid, ids) return dict(res) @@ -281,7 +297,7 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context) account_analytic_account() diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 9bb2764d8bd..f72168cde46 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -362,17 +362,27 @@ class base_stage(object): msg = _('%s has been opened.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) self.message_post(cr, uid, [id], body=msg, context=context) return True + + def find_xml_id(self,cr,uid,ids,name,context=None): + subtype_obj = self.pool.get('mail.message.subtype') + irmodel_obj = self.pool.get('ir.model.data') + subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) + ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)]) + ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) + return ir_model_browse.name def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, subtype="closed", context=context) + xml_id = self.find_xml_id(cr, uid, ids, name="closed", context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, subtype="cancelled", context=context) + xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_pending_send_note(self, cr, uid, ids, context=None): diff --git a/addons/project/project.py b/addons/project/project.py index e1dea8e70c5..412e14fd8fd 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -41,9 +41,8 @@ class project_task_type(osv.osv): 'case_default': fields.boolean('Common to All Projects', help="If you check this field, this stage will be proposed by default on each new project. It will not assign this stage to existing projects."), 'project_ids': fields.many2many('project.project', 'project_task_type_rel', 'type_id', 'project_id', 'Projects'), - 'state': fields.selection(_TASK_STATE, 'Related Status', required=True, - help="The status of your document is automatically changed regarding the selected stage. " \ - "For example, if a stage is related to the status 'Close', when your document reaches this stage, it is automatically closed."), + 'state': fields.selection(_TASK_STATE, 'State', required=True, + help="The related state for the stage. The state of your document will automatically change regarding the selected stage. Example, a stage is related to the state 'Close', when your document reach this stage, it will be automatically closed."), 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), } @@ -514,23 +513,23 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="project_subtype_new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): message = _("Project has been opened.") - return self.message_post(cr, uid, ids, body=message, subtype="open", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_open", context=context) def set_pending_send_note(self, cr, uid, ids, context=None): message = _("Project is now pending.") - return self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_pending", context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_cancelled", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -728,7 +727,7 @@ class task(base_stage, osv.osv): When the case is over, the state is set to \'Done\'.\ If the case needs to be reviewed then the state is \ set to \'Pending\'.'), - 'categ_ids': fields.many2many('project.category', string='Tags'), + 'categ_ids': fields.many2many('project.category', string='Categories'), 'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready To Pull')], 'Kanban State', help="A task's kanban state indicates special situations affecting it:\n" " * Normal is the default situation\n" @@ -1231,10 +1230,10 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="task_subtype_stage_change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="task_subtype_new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 34608d3abeb..0544b6d4e78 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -85,43 +85,48 @@ - + new - + project.project - + + new + project.task + + + open - + project.project - + pending - + project.project - + closed - + project.project - + + closed + project.task + + cancelled - + project.project - + + cancelled + project.task + + + stage change - + project.task - - - - - - - - - diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index d3f47ba9b3e..83eddb83d5e 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -503,7 +503,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="issue_subtype_stage_change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -515,7 +515,7 @@ class project_issue(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="issue_subtype_new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 6ee704c6b39..f6c225a4d00 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -32,33 +32,24 @@ - + new - + project.issue - + stage change - + project.issue - + cancelled - + project.issue - + closed - - - - - - - - - - + project.issue From 8ca3f76711df87f17e2514dec84f63b82fee2ab7 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:59:28 +0530 Subject: [PATCH 03/24] [IMP]code improvement and other minor changes bzr revid: sgo@tinyerp.com-20120913062928-hvqnp116y49yrl4d --- addons/account/data/account_data.xml | 6 +----- addons/analytic/__openerp__.py | 3 ++- addons/analytic/analytic_data.xml | 10 ++++++++++ addons/base_status/base_stage.py | 11 +++++++---- addons/crm/crm_lead_data.xml | 5 +++++ 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 addons/analytic/analytic_data.xml diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 22849a9b886..7689ca2c253 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,11 +560,7 @@ Invoice account.invoice - - new - account.analytic.account - - + new account.invoice diff --git a/addons/analytic/__openerp__.py b/addons/analytic/__openerp__.py index 10762a1d2be..d90b2fd62ac 100644 --- a/addons/analytic/__openerp__.py +++ b/addons/analytic/__openerp__.py @@ -38,7 +38,8 @@ that have no counterpart in the general financial accounts. 'security/analytic_security.xml', 'security/ir.model.access.csv', 'analytic_sequence.xml', - 'analytic_view.xml' + 'analytic_view.xml', + 'analytic_data.xml' ], 'demo': [], 'installable': True, diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml new file mode 100644 index 00000000000..cfd3b5e9b78 --- /dev/null +++ b/addons/analytic/analytic_data.xml @@ -0,0 +1,10 @@ + + + + + new + account.analytic.account + + + + \ No newline at end of file diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index f72168cde46..4b1cc3c6946 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -367,21 +367,24 @@ class base_stage(object): subtype_obj = self.pool.get('mail.message.subtype') irmodel_obj = self.pool.get('ir.model.data') subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)]) + ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_id)]) + xml_id = False ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) - return ir_model_browse.name + if ir_model_browse: + xml_id = ir_model_browse[0].name + return xml_id def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="closed", context) + xml_id = self.find_xml_id(cr, uid, ids, name="closed", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context) + xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 252e843cf30..633782ed233 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -174,5 +174,10 @@ crm.lead + + cancelled + crm.lead + + From 296ae6e24baa8918331d57c7c8e21b21a82cb4bc Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:11:01 +0530 Subject: [PATCH 04/24] [IMP]event:changed in event module as per new spec bzr revid: sgo@tinyerp.com-20120913064101-85pfg3kbbqnoufzx --- addons/event/event.py | 20 +++++++++---------- addons/event/event_data.xml | 39 ++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index 8c755456d9c..82c0390ee03 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -287,27 +287,27 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_cancelled", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_closed", context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, subtype="confirmed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_confirmed", context=context) return True event_event() @@ -353,7 +353,7 @@ class event_registration(osv.osv): return self.write(cr, uid, ids, {'state': 'draft'}, context=context) def confirm_registration(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_('State set to open'), context=context) + self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="registration_subtype_confirmed", context=context) return self.write(cr, uid, ids, {'state': 'open'},context=context) def create(self, cr, uid, vals, context=None): @@ -383,13 +383,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), subtype_xml_id="registration_subtype_closed", context=context) else: raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="registration_subtype_cancelled", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -459,12 +459,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 608dcdb4e8f..814fd0b179c 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -12,34 +12,51 @@ automatic 100 - + + new + event.event - + closed + event.event - + cancelled + event.event - + confirmed + event.event - - - - - + + + + new + event.registration + - - + + closed + event.registration + + cancelled + event.event + + + + confirmed + event.registration + + From 66e8595b01b0c1d38190b1222d0955b710b6c1db Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:28:54 +0530 Subject: [PATCH 05/24] [IMP]changed in all hr module for subtype bzr revid: sgo@tinyerp.com-20120913065854-7y5jkls3q2jebduv --- addons/hr_holidays/hr_holidays.py | 6 ++-- addons/hr_holidays/hr_holidays_data.xml | 21 ++++---------- addons/hr_recruitment/hr_recruitment.py | 14 ++++----- addons/hr_recruitment/hr_recruitment_data.xml | 29 +++++++------------ .../hr_timesheet_invoice.py | 8 ++--- .../hr_timesheet_invoice_data.xml | 25 +++++----------- 6 files changed, 38 insertions(+), 65 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 4136abbb2f7..4e85313e2e4 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -364,7 +364,7 @@ class hr_holidays(osv.osv): def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."),subtype="new", context=context) + _("The request has been created and is waiting confirmation."),subtype_xml_id="hr_holidays_subtype_new", context=context) return True def holidays_confirm_notificate(self, cr, uid, ids, context=None): @@ -384,12 +384,12 @@ class hr_holidays(osv.osv): _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype="approved", context=context) + _("The request has been approved. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_approved", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype="refused", context=context) + _("The request has been refused. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index ad337b72c62..8ddfb79a527 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -50,28 +50,19 @@ Once validated, they are visible in the employee's calendar. HR officers can def brown - + new - + hr.holidays - + approved - + hr.holidays - + refused - + hr.holidays - - - - - - - - - diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 25be4f3c3f1..6d38c4e4e08 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -461,14 +461,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="hr_recruitment_subtype_stage_change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, subtype="in progress", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_in_progress", context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -476,23 +476,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype="refused", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="hr_recruitment_subtype_refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 30ff9118584..dedeb20a3dc 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -462,38 +462,29 @@ You can automatically receive job application though an email gateway, see the H - + new - + hr.applicant - + hired - + hr.applicant - + refused - + hr.applicant - + stage change - + hr.applicant - + in progress - + hr.applicant - - - - - - - - - diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 4ed61119a5f..e3f54609e95 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -95,25 +95,25 @@ class account_analytic_account(osv.osv): def set_close(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'cancelled'}, context=context) message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_invoice_subtype_cancelled", context=context) return True def set_open(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, subtype="open", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_open", context=context) return True def set_pending(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_pending", context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 5cc5024d591..29a3233f509 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -17,32 +17,23 @@ 50.0 - + closed - + account.analytic.account - + pending - + account.analytic.account - + open - + account.analytic.account - + cancelled - + account.analytic.account - - - - - - - - - From 97026e96d30c103a6873f66da0e50b4f47ece37f Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:33:33 +0530 Subject: [PATCH 06/24] [IMP]changed in idea for subtype bzr revid: sgo@tinyerp.com-20120913070333-8mvke4g0h13r6e6d --- addons/idea/idea.py | 8 ++++---- addons/idea/idea_data.xml | 25 ++++++++----------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index e33c9b99014..f8346ec2bba 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,21 +67,21 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype_xml_id="idea_subtype_cancelled", context=context) return True def idea_open(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype="open", context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype_xml_id="idea_subtype_open", context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype_xml_id="idea_subtype_closed", context=context) self.write(cr, uid, ids, { 'state': 'close' }) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype_xml_id="idea_subtype_new", context=context) self.write(cr, uid, ids, { 'state': 'draft' }) return True idea_idea() diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index 36ccf2e992e..b4f3f70d2dd 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -17,32 +17,23 @@ - + new - + idea.idea - + open - + idea.idea - + cancelled - + idea.idea - + closed - - - - - - - - - - + idea.idea From fa5f1e174e8e0c525edc6e5a43a3d0681a11d77c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:44:30 +0530 Subject: [PATCH 07/24] [IMP]changed in mrp and mrp_operations for subtype bzr revid: sgo@tinyerp.com-20120913071430-o7bml82s6tgnwn4h --- addons/mrp/mrp.py | 10 +++---- addons/mrp/mrp_data.xml | 29 +++++++------------- addons/mrp_operations/mrp_operation_data.xml | 29 +++++++------------- addons/mrp_operations/mrp_operations.py | 10 +++---- 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 40d8d1b7e5f..bc0baae71e8 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1044,27 +1044,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mrp_subtype_new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_cancelled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_ready", context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, subtype="production", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_production", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 6ee7cc82dd2..3740f03bdc8 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -27,38 +27,29 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 - + new - + mrp.production - + ready - + mrp.production - + production - + mrp.production - + cancelled - + mrp.production - + closed - + mrp.production - - - - - - - - - diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index e2d7f9f0a56..812ce3da536 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -31,38 +31,29 @@ - + new - + mrp.production.workcenter.line - + started - + mrp.production.workcenter.line - + pending - + mrp.production.workcenter.line - + cancelled - + mrp.production.workcenter.line - + closed - + mrp.production.workcenter.line - - - - - - - - - diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index a18eb4141ba..6ed636850f1 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="cancelled", context=context) return True mrp_production_workcenter_line() From 2e7de7cf6fad0212d3d2a8953fba64d8b5aa77a2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:50:05 +0530 Subject: [PATCH 08/24] [IMP]changed in mrp_repair for subtype bzr revid: sgo@tinyerp.com-20120913072005-cmlf91arfwpxnv6o --- addons/mrp_repair/mrp_repair.py | 14 +++++----- addons/mrp_repair/mrp_repair_data.xml | 37 ++++++++++----------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 44624044090..202f9efd391 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -571,40 +571,40 @@ class mrp_repair(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been created." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_new", context=context) return True def set_start_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been started." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="started", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_started", context=context) return True def set_toinvoiced_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Draft Invoice of %s %s waiting for validation.") % (repair.invoice_id.amount_total, repair.invoice_id.currency_id.symbol) - self.message_post(cr, uid, [repair.id], body=message, subtype="pending", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_pending", context=context) return True def set_confirm_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _( "Repair Order for %s has been accepted." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="accepted", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_accepted", context=context) return True def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Repair has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_cancelled", context=context) return True def set_ready_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is now ready to repair.") - self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_ready", context=context) return True def set_done_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is closed.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_closed", context=context) return True mrp_repair() diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml index b45b7ec3105..6414e07f713 100644 --- a/addons/mrp_repair/mrp_repair_data.xml +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -1,47 +1,38 @@ - + new - + mrp.repair - + started - + mrp.repair - + ready - + mrp.repair - + pending - + mrp.repair - + accepted - + mrp.repair - + cancelled - + mrp.repair - + closed - + mrp.repair - - - - - - - - - From 2e3f2e2458d71cdf693c6ec97e3d9cc28d4a6e75 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:59:49 +0530 Subject: [PATCH 09/24] [IMP]changed in procurement for subtype bzr revid: sgo@tinyerp.com-20120913072949-pny1yj3ke2gj2rr3 --- addons/procurement/procurement.py | 12 ++++----- addons/procurement/procurement_data.xml | 35 ++++++++++--------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 1cb695663df..dcb47f1af88 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -496,22 +496,22 @@ class procurement_order(osv.osv): return obj_id def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype_xml_id="procurement_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype="confirmed", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype_xml_id="procurement_subtype_confirmed", context=context) def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype="running", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype_xml_id="procurement_subtype_running", context=context) def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype_xml_id="procurement_subtype_ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype_xml_id="procurement_subtype_cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype_xml_id="procurement_subtype_closed", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 1f60977c4dd..950c487ae53 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -32,36 +32,29 @@ - - + + new + procurement.order - + confirmed - + procurement.order - + ready - + procurement.order - + running - + procurement.order - - + + cancelled + procurement.order - + closed - - - - - - - - - - + procurement.order \ No newline at end of file From ad6e9d96e4d6f0f33f48415e13ffebcaf7992b77 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:27:27 +0530 Subject: [PATCH 10/24] [IMP]changed in sale module for subtype update specification bzr revid: sgo@tinyerp.com-20120913085727-7swp0404g99fkf7l --- addons/stock/stock.py | 18 +++++++++++++----- addons/stock/stock_data.xml | 29 +++++++++++++---------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index d577e69e237..50e85fa5191 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="stock_in_subtype_new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), subtype="moved", context=context) + return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name),context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="stock_in_subtype_new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1393,12 +1393,20 @@ class stock_picking(osv.osv): 'in': 'received', 'internal': 'moved', } + xml_id_dict = { + 'out':'stock_out_subtype_delivered', + 'in' : 'stock_in_subtype_received' + } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype=type_dict.get(obj.type), context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype_xml_id=xml_id_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): + xml_id_dict = { + 'out':'stock_out_subtype_cancelled', + 'in' : 'stock_in_subtype_cancelled' + } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id=xml_id_dict.get(obj.type), context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index f83b0ada388..a59642fa912 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -170,30 +170,27 @@ watch your stock valuation, and track production lots upstream and downstream (b - - + + new + stock.picking.in - + delivered - + stock.picking.out - + received - + stock.picking.in - - + + cancelled + stock.picking.in - - - - - - - - + + cancelled + stock.picking.out From 986e5817d18b149c3d31cc8c123b878a3e6b62b9 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:32:12 +0530 Subject: [PATCH 11/24] [IMP]changed in sale module for subtype update specification bzr revid: sgo@tinyerp.com-20120913090212-8c9jgb38x1d6517j --- addons/sale/sale.py | 10 +++++----- addons/sale/sale_data.xml | 29 ++++++++++------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 0af625ed7d9..0f01909ac7f 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1032,7 +1032,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1040,7 +1040,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_cancelled", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1052,15 +1052,15 @@ class sale_order(osv.osv): self.message_post(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Order delivered."), subtype="delivered", context=context) + self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="sale_subtype_delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="sale_subtype_paid", context=context) def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="sale_subtype_pending", context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_post(cr, uid, ids, body=_('Sale order set to draft.'), context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index 2f4b81b27f4..4eca7f60c8f 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -50,37 +50,28 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. - + new - + sale.order - + cancelled - + sale.order - + paid - + sale.order - + pending - + sale.order - + delivered - - - - - - - - - - + sale.order From c67edb99bb891c468fedb6b4a373fe9da1843ebc Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:38:34 +0530 Subject: [PATCH 12/24] [IMP]changed in purchase module for subtype update specification bzr revid: sgo@tinyerp.com-20120913090834-5lf57kikymrzsg8z --- addons/purchase/purchase.py | 12 ++++++------ addons/purchase/purchase_data.xml | 29 ++++++++++------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index c950c852261..b0f10d3f71f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -740,7 +740,7 @@ class purchase_order(osv.osv): return [('state', '=', 'draft')] def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="purchase_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -758,20 +758,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="purchase_subtype_pending", context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype="received", context=context) + self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="purchase_subtype_received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="purchase_subtype_paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="purchase_subtype_new", context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="purchase_subtype_cancelled", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index a84564b2360..aa62e84e19d 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -49,37 +49,28 @@ You can also manage purchase requisitions, see also the Purchase Settings. - + new - + purchase.order - + paid - + purchase.order - + pending - + purchase.order - + received - + purchase.order - + cancelled - + purchase.order - - - - - - - - - From 9524b34e314511191fc2c2265a44e5c9594f645c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:42:08 +0530 Subject: [PATCH 13/24] [IMP]changed in purchase_requisition module for subtype update specification bzr revid: sgo@tinyerp.com-20120913091208-si6e042trpzdyq6m --- .../purchase_requisition.py | 8 +++---- .../purchase_requisition_data.xml | 23 +++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index a3df366381d..5d8d2bb2f87 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -94,13 +94,13 @@ class purchase_requisition(osv.osv): self.message_post(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) def reset_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="requisition_subtype_new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="requisition_subtype_closed", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype_xml_id="requisition_subtype_cancelled", context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -184,7 +184,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="requisition_subtype_new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 2b22c2057a1..534bf2fe2a7 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -7,24 +7,17 @@ model="ir.values" name="set"/> - + closed - + purchase.requisition - - + + new + purchase.requisition - - - - - - - - - - - + + cancelled + purchase.requisition \ No newline at end of file From 18ceddcf2ee7086fe2e2d512e415064986febf9c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:45:02 +0530 Subject: [PATCH 14/24] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120913091502-dvlpgoa3dr72km04 --- addons/event/event_data.xml | 4 ---- addons/mail/tests/test_mail.py | 4 ---- 2 files changed, 8 deletions(-) diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 814fd0b179c..bc7f71ef664 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -16,24 +16,20 @@ new event.event - closed event.event - cancelled event.event - confirmed event.event - diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index e3718d23855..9b0586d5d5c 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -636,7 +636,3 @@ class test_mail(common.TransactionCase): msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") - # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message -# msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') -# notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) -# self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From e6eafcaf22aa4c84ca751f1e6cd2f06a0833c987 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:47:57 +0530 Subject: [PATCH 15/24] [IMP]minor changes in account bzr revid: sgo@tinyerp.com-20120913091757-6izlnq34z3v9jd7n --- addons/account_voucher/account_voucher_data.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index dd46a83777e..a59993aae6b 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -14,6 +14,7 @@ If you want to use advanced accounting features, you should install the "Account + new account.voucher From 53a67e065236f549cd07b35406cc59181417ee55 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:12:09 +0530 Subject: [PATCH 16/24] [IMP]change in mrp bzr revid: sgo@tinyerp.com-20120913094209-4r0laz8gtmcz1tsq --- addons/mrp_operations/mrp_operations.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 6ed636850f1..53eaceed066 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_cancelled", context=context) return True mrp_production_workcenter_line() From 458899673b2d06572ea68b1874b56767d7966a76 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:33:07 +0530 Subject: [PATCH 17/24] [IMP]change in mrp operations openerp.py bzr revid: sgo@tinyerp.com-20120913100307-4f49x1my6ajzzfiz --- addons/mrp_operations/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mrp_operations/__openerp__.py b/addons/mrp_operations/__openerp__.py index a5bda80f924..ba2e2d88637 100644 --- a/addons/mrp_operations/__openerp__.py +++ b/addons/mrp_operations/__openerp__.py @@ -58,6 +58,7 @@ So, that we can compare the theoretic delay and real delay. 'depends': ['mrp'], 'data': [ 'security/ir.model.access.csv', + 'mrp_operation_data.xml', 'mrp_operations_workflow.xml', 'mrp_operations_view.xml', 'mrp_operations_report.xml', @@ -65,7 +66,7 @@ So, that we can compare the theoretic delay and real delay. 'process/mrp_operation_process.xml', 'mrp_operations_workflow_instance.xml' ], - 'demo': ['mrp_operation_data.xml', + 'demo': [ 'mrp_operations_demo.yml' ], 'test': [ From 17987c7e2c71a695a5d3fcff324c29067ba6b7ab Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:54:56 +0530 Subject: [PATCH 18/24] [IMP]crm yml improve for subtype bzr revid: sgo@tinyerp.com-20120913102456-c74asnmmh6kx5270 --- addons/crm/test/process/crm_message_subtype.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 3dd042c1279..46c6aae7bf4 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -3,24 +3,21 @@ - !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: False - I have add the sub_type name email with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_email }: name: email - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: True - I have add the sub_type name comment with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: True - I have add the subtypes as won in feeds From d5687b3ed0538d095cc8209c1de78de1a10448b6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 16:15:18 +0530 Subject: [PATCH 19/24] [IMP]crm yml improve bzr revid: sgo@tinyerp.com-20120913104518-6cse5m221l8n5yc4 --- addons/crm/test/process/crm_message_subtype.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 46c6aae7bf4..a1ad9a9c39a 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -3,22 +3,14 @@ - !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won - res_model:crm.lead + res_model: crm.lead default: False -- - I have add the sub_type name email with default true -- - !record {model: mail.message.subtype, id: mail.mail_subtype_email }: - name: email - res_model:crm.lead - default: True - I have add the sub_type name comment with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment - res_model:crm.lead - default: True + res_model: crm.lead - I have add the subtypes as won in feeds - From f554db5c6bc94b3e9fdf5aa67a0030cbb4026df2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 17:10:44 +0530 Subject: [PATCH 20/24] [IMP]add subtype for crm_claim bzr revid: sgo@tinyerp.com-20120913114044-0spnm47pty5g04wu --- addons/crm_claim/crm_claim.py | 6 +++--- addons/crm_claim/crm_claim_data.xml | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 535f6d20367..ce2427b9752 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -238,16 +238,16 @@ class crm_claim(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been created.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_new', context=context) def case_refuse_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been refused.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_refused', context=context) def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='claim_subtype_stage_change', context=context) class res_partner(osv.osv): diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index 33bd280c364..a72c285f506 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -75,6 +75,32 @@ + + + + new + crm.claim + + + + refused + crm.claim + + + + stage change + crm.claim + + + cancelled + crm.claim + + + + closed + crm.claim + + From 2fbc7e9d046dcebea15b6a43289297e705984212 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 17:21:38 +0530 Subject: [PATCH 21/24] [IMP]improve subtype in crm_claim bzr revid: sgo@tinyerp.com-20120913115138-4rrsmwmlfh4f25s1 --- addons/crm_claim/crm_claim_data.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index a72c285f506..e68bc3ad6cb 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -99,7 +99,6 @@ closed crm.claim - From 8821601a87dc1a35253314673252f40a10e93493 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 11:27:30 +0530 Subject: [PATCH 22/24] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120914055730-c0x2tshrr8j6aa5v --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 87c2e22d46b..71f22138c90 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -628,7 +628,7 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids=None, context=None): """ Add partners to the records followers. """ if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From a11e752ea2a1533c7db3e037689a8e132ade8bbd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 11:35:46 +0530 Subject: [PATCH 23/24] [IMP]improve code bzr revid: sgo@tinyerp.com-20120914060546-e0uj8dru6c9pym9y --- addons/base_status/base_stage.py | 14 +++++++------- addons/mail/mail_thread.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 4b1cc3c6946..2695567e0a1 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -365,13 +365,13 @@ class base_stage(object): def find_xml_id(self,cr,uid,ids,name,context=None): subtype_obj = self.pool.get('mail.message.subtype') - irmodel_obj = self.pool.get('ir.model.data') - subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_id)]) - xml_id = False - ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) - if ir_model_browse: - xml_id = ir_model_browse[0].name + ir_model_data_obj = self.pool.get('ir.model.data') + subtype_ids = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) + ir_data_ids = ir_model_data_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_ids)]) + xml_id = 'mail_subtype_comment' + ir_model_data_record = ir_model_data_obj.browse(cr,uid,ir_data_ids) + if ir_model_data_record: + xml_id = ir_model_data_record[0].name return xml_id def case_close_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3f034b8875a..137ba3eccda 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -604,7 +604,7 @@ class mail_thread(osv.AbstractModel): subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) if self._name == subtype_browse.res_model: values['subtype_id']=subtype_browse.id - else: + if not subtype_browse.res_model: values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, @@ -629,7 +629,7 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From 6537579a9c927264100e3dc5cb843b930566c6ab Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 15:02:36 +0530 Subject: [PATCH 24/24] [IMP]improve lead code bzr revid: sgo@tinyerp.com-20120914093236-knk88eqvnbd4slct --- addons/crm/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 924326c7c02..81ca828dc76 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -842,7 +842,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), mail_subtype_new="crm_subtype_stage_change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="crm_subtype_stage_change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)):