From fbb5eea4ba6278b8910f73e20dff2922ff40d236 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 20 Mar 2014 15:16:14 +0530 Subject: [PATCH 01/23] [IMP] convert button into stat button for project bzr revid: rajmyt@gmail.com-20140320094614-53ix0c0fdgrzbmsc --- addons/project/project.py | 35 +++++++++++-------- addons/project/project_view.xml | 11 ++++-- addons/project_issue/project_issue.py | 27 ++++++++------ addons/project_issue/project_issue_view.xml | 5 ++- .../project_long_term_view.xml | 7 ++-- .../project_timesheet_view.xml | 5 ++- 6 files changed, 56 insertions(+), 34 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index e5dcf5de2cf..ee6390e4b87 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -187,19 +187,23 @@ class project(osv.osv): res[id] = (project_attachments or 0) + (task_attachments or 0) return res - def _task_count(self, cr, uid, ids, field_name, arg, context=None): - """ :deprecated: this method will be removed with OpenERP v8. Use task_ids - fields instead. """ - if context is None: - context = {} - res = dict.fromkeys(ids, 0) - ctx = context.copy() - ctx['active_test'] = False - task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)], context=ctx) - for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): - res[task.project_id.id] += 1 +# def _task_count(self, cr, uid, ids, field_name, arg, context=None): +# """ :deprecated: this method will be removed with OpenERP v8. Use task_ids +# fields instead. """ +# if context is None: +# context = {} +# res = dict.fromkeys(ids, 0) +# ctx = context.copy() +# ctx['active_test'] = False +# task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)], context=ctx) +# for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): +# res[task.project_id.id] += 1 +# return res + def _total_task_count(self, cr, uid, ids, field_name, arg, context=None): + res={} + for tasks in self.browse(cr, uid, ids, context): + res[tasks.id] = len(tasks.task_ids) return res - def _get_alias_models(self, cr, uid, context=None): """ Overriden in project_issue to offer more options """ return [('project.task', "Tasks")] @@ -265,8 +269,8 @@ class project(osv.osv): }), 'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report", states={'close':[('readonly',True)]} ), 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), - 'task_count': fields.function(_task_count, type='integer', string="Open Tasks", - deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."), +# 'task_count': fields.function(_task_count, type='integer', string="Open Tasks", +# deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."), 'task_ids': fields.one2many('project.task', 'project_id', domain=[('stage_id.fold', '=', False)]), 'color': fields.integer('Color Index'), @@ -287,7 +291,8 @@ class project(osv.osv): "- Followers Only: employees see only the followed tasks or issues; if portal\n" " is activated, portal users see the followed tasks or issues."), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), - 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int') + 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int'), + 'total_task_count': fields.function(_total_task_count, string="Task", type='integer'), } def _get_type_common(self, cr, uid, context): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 08738227f5a..45fe175f515 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -93,8 +93,13 @@
- - +
@@ -238,7 +243,7 @@ - + diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 6f072f5abd1..69ceb7839ca 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -490,22 +490,27 @@ class project(osv.Model): def _get_alias_models(self, cr, uid, context=None): return [('project.task', "Tasks"), ("project.issue", "Issues")] - def _issue_count(self, cr, uid, ids, field_name, arg, context=None): - """ :deprecated: this method will be removed with OpenERP v8. Use issue_ids - fields instead. """ - res = dict.fromkeys(ids, 0) - issue_ids = self.pool.get('project.issue').search(cr, uid, [('project_id', 'in', ids)]) - for issue in self.pool.get('project.issue').browse(cr, uid, issue_ids, context): - if issue.stage_id and not issue.stage_id.fold: - res[issue.project_id.id] += 1 +# def _issue_count(self, cr, uid, ids, field_name, arg, context=None): +# """ :deprecated: this method will be removed with OpenERP v8. Use issue_ids +# fields instead. """ +# res = dict.fromkeys(ids, 0) +# issue_ids = self.pool.get('project.issue').search(cr, uid, [('project_id', 'in', ids)]) +# for issue in self.pool.get('project.issue').browse(cr, uid, issue_ids, context): +# if issue.stage_id and not issue.stage_id.fold: +# res[issue.project_id.id] += 1 +# return res + def _total_issue_count(self, cr, uid, ids, field_name, arg, context=None): + res={} + for issues in self.browse(cr, uid, ids, context): + res[issues.id] = len(issues.issue_ids) return res - _columns = { 'project_escalation_id': fields.many2one('project.project', 'Project Escalation', help='If any issue is escalated from the current Project, it will be listed under the project selected here.', states={'close': [('readonly', True)], 'cancelled': [('readonly', True)]}), - 'issue_count': fields.function(_issue_count, type='integer', string="Unclosed Issues", - deprecated="This field will be removed in OpenERP v8. Use issue_ids one2many field instead."), +# 'issue_count': fields.function(_issue_count, type='integer', string="Unclosed Issues", +# deprecated="This field will be removed in OpenERP v8. Use issue_ids one2many field instead."), + 'total_issue_count': fields.function(_total_issue_count, string="Issue", type='integer'), 'issue_ids': fields.one2many('project.issue', 'project_id', domain=[('stage_id.fold', '=', False)]) } diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 3af9ee608d6..2b2c48519f9 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -306,7 +306,10 @@ diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml index 548264eb07b..a51c7976602 100644 --- a/addons/project_timesheet/project_timesheet_view.xml +++ b/addons/project_timesheet/project_timesheet_view.xml @@ -30,7 +30,10 @@ From df53c3f970d948321dc91de7e2818decce94adbe Mon Sep 17 00:00:00 2001 From: Randhir Mayatra rma-openerp Date: Thu, 20 Mar 2014 16:50:17 +0530 Subject: [PATCH 02/23] [IMP] improve code bzr revid: rma@tinyerp.com-20140320112017-03miv5s8jovz0iac --- addons/project/project.py | 19 ++----------------- addons/project/project_view.xml | 4 ++-- addons/project_issue/project_issue.py | 15 ++------------- addons/project_issue/project_issue_view.xml | 2 +- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index ee6390e4b87..942a47d06a6 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -186,20 +186,7 @@ class project(osv.osv): task_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)], context=context, count=True) res[id] = (project_attachments or 0) + (task_attachments or 0) return res - -# def _task_count(self, cr, uid, ids, field_name, arg, context=None): -# """ :deprecated: this method will be removed with OpenERP v8. Use task_ids -# fields instead. """ -# if context is None: -# context = {} -# res = dict.fromkeys(ids, 0) -# ctx = context.copy() -# ctx['active_test'] = False -# task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)], context=ctx) -# for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): -# res[task.project_id.id] += 1 -# return res - def _total_task_count(self, cr, uid, ids, field_name, arg, context=None): + def _task_count(self, cr, uid, ids, field_name, arg, context=None): res={} for tasks in self.browse(cr, uid, ids, context): res[tasks.id] = len(tasks.task_ids) @@ -269,8 +256,7 @@ class project(osv.osv): }), 'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report", states={'close':[('readonly',True)]} ), 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), -# 'task_count': fields.function(_task_count, type='integer', string="Open Tasks", -# deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."), + 'task_count': fields.function(_task_count, type='integer', string="Tasks",), 'task_ids': fields.one2many('project.task', 'project_id', domain=[('stage_id.fold', '=', False)]), 'color': fields.integer('Color Index'), @@ -292,7 +278,6 @@ class project(osv.osv): " is activated, portal users see the followed tasks or issues."), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int'), - 'total_task_count': fields.function(_total_task_count, string="Task", type='integer'), } def _get_type_common(self, cr, uid, context): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 45fe175f515..35d4e1bf64f 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -95,7 +95,7 @@
From b51066b500e069142df47cf03c045b2b068872a7 Mon Sep 17 00:00:00 2001 From: Randhir Mayatra rma-openerp Date: Thu, 20 Mar 2014 19:14:14 +0530 Subject: [PATCH 03/23] [IMP] convert button into stat button for customer bzr revid: rma@tinyerp.com-20140320134414-mk1ie8okynrtudsq --- addons/account/partner.py | 4 +++- addons/account/partner_view.xml | 6 ++++-- addons/project/res_partner.py | 11 ++++++++++- addons/project/res_partner_view.xml | 10 ++++++---- addons/project_issue/project_issue.py | 17 ++++++++++++++++- addons/project_issue/project_issue_view.xml | 11 +++++++---- addons/sale/res_partner_view.xml | 7 ++++--- 7 files changed, 50 insertions(+), 16 deletions(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index 0c3395de1b2..6ae83368143 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -163,13 +163,14 @@ class res_partner(osv.osv): return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context) def _invoice_journal_item_count(self, cr, uid, ids, field_name, arg, context=None): - res = dict(map(lambda x: (x,{'invoice_count': 0, 'journal_item_count': 0}), ids)) + res = dict(map(lambda x: (x,{'invoice_count': 0, 'journal_item_count': 0, 'cotracts_count': 0 }), ids)) # the user may not have access rights try: for partner in self.browse(cr, uid, ids, context): res[partner.id] = { 'invoice_count': len(partner.invoice_ids), 'journal_item_count': len(partner.journal_item_ids), + 'cotracts_count': len(partner.contract_ids) } except: pass @@ -204,6 +205,7 @@ class res_partner(osv.osv): 'debit': fields.function(_credit_debit_get, fnct_search=_debit_search, string='Total Payable', multi='dc', help="Total amount you have to pay to this supplier."), 'debit_limit': fields.float('Payable Limit'), 'invoice_count': fields.function(_invoice_journal_item_count, string="Invoices", type='integer', multi="invoice_journal"), + 'cotracts_count': fields.function(_invoice_journal_item_count, string="Contracts", type='integer', multi="invoice_journal"), 'journal_item_ids': fields.one2many('account.move.line', 'partner_id', 'Journal Items'), 'journal_item_count': fields.function(_invoice_journal_item_count, string="Journal Items", type="integer", multi="invoice_journal"), 'property_account_payable': fields.property( diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index b64f2a4f88c..8dbda70ec6b 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -74,8 +74,10 @@ - diff --git a/addons/project/res_partner.py b/addons/project/res_partner.py index e49cacf4f89..79af0413385 100644 --- a/addons/project/res_partner.py +++ b/addons/project/res_partner.py @@ -22,11 +22,20 @@ from openerp.osv import fields,osv class res_partner(osv.osv): - + def _task_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict(map(lambda x: (x,0), ids)) + try: + for partner in self.browse(cr, uid, ids, context): + res[partner.id] = len(partner.task_ids) + except: + pass + return res + """ Inherits partner and adds Tasks information in the partner form """ _inherit = 'res.partner' _columns = { 'task_ids': fields.one2many('project.task', 'partner_id', 'Tasks'), + 'task_count': fields.function(_task_count, string='# Tasks', type='integer'), } def copy(self, cr, uid, record_id, default=None, context=None): diff --git a/addons/project/res_partner_view.xml b/addons/project/res_partner_view.xml index f12189b5163..a77ea467dcb 100644 --- a/addons/project/res_partner_view.xml +++ b/addons/project/res_partner_view.xml @@ -10,11 +10,13 @@ - + + diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index c4c35b2b712..947aba44242 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -569,5 +569,20 @@ class project_project(osv.Model): self._check_create_write_values(cr, uid, vals, context=context) return super(project_project, self).write(cr, uid, ids, vals, context=context) - +class res_partner(osv.osv): + def _issue_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict(map(lambda x: (x,0), ids)) + try: + for partner in self.browse(cr, uid, ids, context): + res[partner.id] = len(partner.issue_ids) + except: + pass + return res + + """ Inherits partner and adds Tasks information in the partner form """ + _inherit = 'res.partner' + _columns = { + 'issue_ids': fields.one2many('project.issue', 'partner_id', 'Issues'), + 'issue_count': fields.function(_issue_count, string='# Issues', type='integer'), + } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index ace56dd2d5a..a312b8e78d8 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -378,11 +378,14 @@ - + + diff --git a/addons/sale/res_partner_view.xml b/addons/sale/res_partner_view.xml index 5107f0c17af..049d2e40284 100644 --- a/addons/sale/res_partner_view.xml +++ b/addons/sale/res_partner_view.xml @@ -48,10 +48,11 @@ - From 0f40b3bc8f9c50e6e4361901eb9c024ba76851a3 Mon Sep 17 00:00:00 2001 From: Randhir Mayatra rma-openerp Date: Mon, 24 Mar 2014 10:39:21 +0530 Subject: [PATCH 04/23] [IMP] convert button into stat button for project_issue and stock_claim bzr revid: rma@tinyerp.com-20140324050921-qxn3n4getus3il6c --- .../claim_from_delivery/claim_delivery_view.xml | 7 ++++--- addons/crm/crm_lead.py | 11 ++++++++++- addons/crm/crm_lead_view.xml | 17 +++++++++-------- addons/crm_claim/crm_claim.py | 9 +++++++++ addons/crm_claim/res_partner_view.xml | 8 ++++---- addons/crm_project_issue/project_issue_view.xml | 3 ++- addons/project_issue/project_issue.py | 5 ++--- addons/stock/stock.py | 12 ++++++++++-- 8 files changed, 50 insertions(+), 22 deletions(-) diff --git a/addons/claim_from_delivery/claim_delivery_view.xml b/addons/claim_from_delivery/claim_delivery_view.xml index 9187b1d11ca..852d602c269 100644 --- a/addons/claim_from_delivery/claim_delivery_view.xml +++ b/addons/claim_from_delivery/claim_delivery_view.xml @@ -9,7 +9,6 @@ {'default_ref': 'stock.picking.out,'+str(context.get('active_id', False))} [('ref','=','stock.picking.out,'+str(context.get('active_id',False)))] - crm.claim.from_delivery.form stock.picking.out @@ -17,11 +16,13 @@
-
- diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 4da0a509ed1..b972fe34255 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -214,7 +214,14 @@ class crm_lead(format_address, osv.osv): duration = len(no_days) res[lead.id][field] = abs(int(duration)) return res - + def _meeting_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict(map(lambda x: (x,0), ids)) + try: + for meeting in self.browse(cr, uid, ids, context=context): + res[meeting.id] = len(meeting.opportunity_ids) + except: + pass + return res _columns = { 'partner_id': fields.many2one('res.partner', 'Partner', ondelete='set null', track_visibility='onchange', select=True, help="Linked partner (optional). Usually created when converting the lead."), @@ -289,6 +296,8 @@ class crm_lead(format_address, osv.osv): 'payment_mode': fields.many2one('crm.payment.mode', 'Payment Mode', \ domain="[('section_id','=',section_id)]"), 'planned_cost': fields.float('Planned Costs'), + 'opportunity_ids': fields.one2many('calendar.event', 'opportunity_id', 'Opportunities'), + 'meeting_count': fields.function(_meeting_count, string='# Meetings', type='integer'), } _defaults = { diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index a33b215fb8f..17c7f58c4fe 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -103,9 +103,8 @@
-