diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index ff6321e599f..f31f10c4060 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -363,7 +363,12 @@ the rule to mark CC(mail to any other person defined in actions)."), 'user' : self.pool.get('res.users').browse(cr, uid, uid, context=context), 'obj' : obj, }) - self.email_send(cr, uid, obj, emails, action.act_mail_body, emailfrom=email_from) + def to_email(text): + return re.findall(r'([^ ,<@]+@[^> ,]+)', text or '') + emails = to_email(','.join(filter(None, emails))) + email_froms = to_email(email_from) + if email_froms: + self.email_send(cr, uid, obj, emails, action.act_mail_body, emailfrom=email_froms[0]) return True def _action(self, cr, uid, ids, objects, scrit=None, context=None): diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py index 1a1b48e75ee..350c9f70092 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/mail_gateway/mail_gateway.py @@ -122,10 +122,14 @@ class mailgate_thread(osv.osv): obj = self.pool.get('mailgate.message') for case in cases: + partner_id = hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False + if not partner_id and case._name == 'res.partner': + partner_id = case.id data = { 'name': keyword, 'user_id': uid, 'model' : case._name, + 'partner_id': partner_id, 'res_id': case.id, 'date': time.strftime('%Y-%m-%d %H:%M:%S'), 'message_id': message_id, @@ -153,7 +157,7 @@ class mailgate_thread(osv.osv): case.user_id.address_id.email), 'email_cc': email_cc, 'email_bcc': email_bcc, - 'partner_id': hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False, + 'partner_id': partner_id, 'references': references, 'message_id': message_id, 'attachment_ids': [(6, 0, attachments)] @@ -255,11 +259,16 @@ class mailgate_tool(osv.osv_memory): msg_pool = self.pool.get('mailgate.message') for res_id in res_ids: + case = self.pool.get(model).browse(cr, uid, res_id, context=context) + partner_id = hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False + if not partner_id and model == 'res.partner': + partner_id = res_id msg_data = { 'name': msg.get('subject', 'No subject'), 'date': msg.get('date'), 'description': msg.get('body', msg.get('from')), 'history': True, + 'partner_id': partner_id, 'res_model': model, 'email_cc': msg.get('cc'), 'email_from': msg.get('from'), diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index def60b7d458..8b616c3d7ac 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -467,9 +467,8 @@ class mrp_production(osv.osv): 'state': fields.selection([('draft','Draft'),('picking_except', 'Picking Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Cancelled'),('done','Done')],'State', readonly=True, help='When the production order is created the state is set to \'Draft\'.\n If the order is confirmed the state is set to \'Waiting Goods\'.\n If any exceptions are there, the state is set to \'Picking Exception\'.\ \nIf the stock is available then the state is set to \'Ready to Produce\'.\n When the production gets started then the state is set to \'In Production\'.\n When the production is over, the state is set to \'Done\'.'), - 'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'), - 'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'), - + 'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder', store=True), + 'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder', store=True), 'company_id': fields.many2one('res.company','Company',required=True), } _defaults = { diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 6b59287f3ce..4186a6e8722 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -615,7 +615,7 @@ - +