From 93ba65f5ca8c6cf86b45884041047132cd89295e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 14 Jul 2010 13:42:48 +0200 Subject: [PATCH 1/2] [IMP] crm, mail_gateway: switch history message fields to read-only, they are only updated programmatically. + minor cleanup bzr revid: odo@openerp.com-20100714114248-ish7w76i2dt8t6t6 --- addons/crm/crm_lead.py | 4 ++-- addons/crm/wizard/crm_send_email.py | 31 ++++++++++++++--------------- addons/mail_gateway/mail_gateway.py | 28 +++++++++++++------------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index bffb1fc53b8..606895e27a6 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -152,8 +152,8 @@ and users"), \nIf the case is in progress the state is set to \'Open\'.\ \nWhen the case is over, the state is set to \'Done\'.\ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), - 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('model','=',_name)]), - 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)]), + 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('model','=',_name)], readonly=True), + 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)], readonly=True), } _defaults = { diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py index 27bc9328b61..bc2b5357c15 100644 --- a/addons/crm/wizard/crm_send_email.py +++ b/addons/crm/wizard/crm_send_email.py @@ -120,22 +120,21 @@ class crm_send_new_email(osv.osv_memory): if not flag: raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.')) - if flag: - case_pool.history(cr, uid, [case], _('Send'), history=True, \ - email=obj.email_to, details=body, \ - subject=obj.subject, email_from=email_from, \ - email_cc=email_cc, message_id=message_id, \ - references=ref_id or message_id, attach=attach) - if obj.state == 'unchanged': - pass - elif obj.state == 'done': - case_pool.case_close(cr, uid, [case.id]) - elif obj.state == 'draft': - case_pool.case_reset(cr, uid, [case.id]) - elif obj.state in ['cancel', 'open', 'pending']: - act = 'case_' + obj.state - getattr(case_pool, act)(cr, uid, [case.id]) - cr.commit() + + case_pool.history(cr, uid, [case], _('Send'), history=True, \ + email=obj.email_to, details=body, \ + subject=obj.subject, email_from=email_from, \ + email_cc=email_cc, message_id=message_id, \ + references=ref_id or message_id, attach=attach) + if obj.state == 'unchanged': + pass + elif obj.state == 'done': + case_pool.case_close(cr, uid, [case.id]) + elif obj.state == 'draft': + case_pool.case_reset(cr, uid, [case.id]) + elif obj.state in ['cancel', 'open', 'pending']: + act = 'case_' + obj.state + getattr(case_pool, act)(cr, uid, [case.id]) return {} diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py index 7187de5d1a5..1abda444116 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/mail_gateway/mail_gateway.py @@ -41,8 +41,8 @@ class mailgate_thread(osv.osv): _description = 'Mailgateway Thread' _columns = { - 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True)]), - 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False)]), + 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True)], readonly=True), + 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False)], readonly=True), } def message_new(self, cr, uid, msg, context): @@ -149,23 +149,23 @@ class mailgate_message(osv.osv): _description = 'Mailgateway Message' _order = 'id desc' _columns = { - 'name':fields.text('Subject'), - 'model': fields.char('Object Name', size=128, select=1), - 'res_id': fields.integer('Resource ID', select=1), + 'name':fields.text('Subject', readonly=True), + 'model': fields.char('Object Name', size=128, select=1, readonly=True), + 'res_id': fields.integer('Resource ID', select=1, readonly=True), 'ref_id': fields.char('Reference Id', size=256, readonly=True, help="Message Id in Email Server.", select=True), - 'date': fields.datetime('Date'), - 'history': fields.boolean('Is History?'), + 'date': fields.datetime('Date', readonly=True), + 'history': fields.boolean('Is History?', readonly=True), 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), - 'message': fields.text('Description'), - 'email_from': fields.char('From', size=128, help="Email From"), - 'email_to': fields.char('To', help="Email Recipients", size=256), - 'email_cc': fields.char('Cc', help="Carbon Copy Email Recipients", size=256), - 'email_bcc': fields.char('Bcc', help='Blind Carbon Copy Email Recipients', size=256), + 'message': fields.text('Description', readonly=True), + 'email_from': fields.char('From', size=128, help="Email From", readonly=True), + 'email_to': fields.char('To', help="Email Recipients", size=256, readonly=True), + 'email_cc': fields.char('Cc', help="Carbon Copy Email Recipients", size=256, readonly=True), + 'email_bcc': fields.char('Bcc', help='Blind Carbon Copy Email Recipients', size=256, readonly=True), 'message_id': fields.char('Message Id', size=1024, readonly=True, help="Message Id on Email.", select=True), 'references': fields.text('References', readonly=True, help="References emails."), - 'description': fields.text('Description'), + 'description': fields.text('Description', readonly=True), 'partner_id': fields.many2one('res.partner', 'Partner', required=False), - 'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'), + 'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments', readonly=True), } def init(self, cr): From 948d1daa0f0422f8d267919bf84d04e4cd4a3706 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 14 Jul 2010 18:28:15 +0530 Subject: [PATCH 2/2] [IMP]:mrp:improved production order report. bzr revid: apa@tinyerp.com-20100714125815-qeh4oeu2ielj6ixg --- addons/mrp/report/order.rml | 103 +++++++++++++----------------------- 1 file changed, 36 insertions(+), 67 deletions(-) diff --git a/addons/mrp/report/order.rml b/addons/mrp/report/order.rml index 3db5396d444..0f08d368900 100644 --- a/addons/mrp/report/order.rml +++ b/addons/mrp/report/order.rml @@ -118,7 +118,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -135,15 +135,7 @@ - - - - - - - - - + @@ -186,10 +178,9 @@ + - -
[[ repeatIn(objects,'o') ]] @@ -204,7 +195,7 @@ - + Product @@ -220,7 +211,7 @@ - + [[ o.product_id.code ]] [[ o.product_id.name ]] @@ -236,16 +227,16 @@ - + - + - Printing date + Planned Date - Planned Date + Printing date Partner Ref @@ -256,31 +247,31 @@
- + - - [[ formatLang(time.strftime('%Y-%m-%d'),date = True) ]] - [[ formatLang(o.date_planned, date_time = True) ]] - [[ 'sale_ref' in o._columns.keys() and o.sale_ref or removeParentNode('para') ]] + [[ formatLang(time.strftime('%Y-%m-%d'),date = True) ]] - [[ 'sale_name' in o._columns.keys() and o.sale_name or removeParentNode('para') ]] + [[ ('sale_ref' in o._columns.keys() and o.sale_ref) or '' ]] + + + [[ ('sale_name' in o._columns.keys() and o.sale_name) or '' ]]
- + Work Orders - + - + Sequence @@ -301,7 +292,7 @@
[[ repeatIn(o.workcenter_lines,'line2') ]] - + [[ line2.sequence ]] @@ -324,17 +315,19 @@
- + Bill Of Material -
- Products to Consume - - [[ o.move_lines ==[] and removeParentNode('section')]] + Consumed Products [[ o.move_lines2 ==[] and removeParentNode('para')]] + Products to Consume [[ o.move_lines ==[] and removeParentNode('para')]] + + + + Product @@ -350,10 +343,9 @@ -
- - [[ repeatIn(o.move_lines,'line') ]] + [[ repeatIn(o.move_lines,'line') ]] + [[ line.product_id.code ]] [[ line.product_id.name ]] @@ -372,34 +364,10 @@ -
- - - +
- Consumed Products - - - [[ o.move_lines2 ==[] and removeParentNode('section')]] - - - Product - - - Quantity - - - Source Location - - - Destination Location - - - -
-
- - [[ repeatIn(o.move_lines2,'line2') ]] + [[ repeatIn(o.move_lines2,'line2') ]] + [[ line2.product_id.code ]] [[ line2.product_id.name ]] @@ -418,8 +386,9 @@ - + + +
-
- \ No newline at end of file +