From d9c305ef068242cc5e2c1d998d19ed82418130a4 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 26 Apr 2012 16:01:33 +0530 Subject: [PATCH] [ADD,IMP] sale,crm: added: sale/res_partner.py sale/res_partner_view.xml modified: crm/res_partner.py crm/res_partner_view.xml sale/__init__.py sale/__openerp__.py stock/product.py stock/product_view.xml stock/static/src/css/stock.css For set links off quatations,opportunity and meeting bzr revid: dbr@tinyerp.com-20120426103133-l0uc091e9r7mbu9b --- addons/crm/res_partner.py | 52 +++++++++++++++++++ addons/crm/res_partner_view.xml | 29 +++++++++++ addons/sale/__init__.py | 1 + addons/sale/__openerp__.py | 1 + addons/sale/res_partner.py | 42 +++++++++++++++ addons/sale/res_partner_view.xml | 25 +++++++++ addons/stock/product.py | 73 +++++++++++++++++++++++++++ addons/stock/product_view.xml | 16 ++++++ addons/stock/static/src/css/stock.css | 8 +-- 9 files changed, 243 insertions(+), 4 deletions(-) create mode 100644 addons/sale/res_partner.py create mode 100644 addons/sale/res_partner_view.xml diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index 3d43bc76022..af56afd2577 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -20,10 +20,29 @@ ############################################################################## from osv import fields,osv +from tools.translate import _ class res_partner(osv.osv): """ Inherits partner and adds CRM information in the partner form """ _inherit = 'res.partner' + + def _total_oppo(self, cr, uid, ids, field_name, arg, context=None): + total_oppo={} + oppo_pool=self.pool.get('crm.lead') + for id in ids: + oppo_ids = oppo_pool.search(cr, uid, [('partner_id', '=', id)]) + total_oppo[id] = len(oppo_ids) + return total_oppo + + def _total_meeting(self, cr, uid, ids, field_name, arg, context=None): + total_meeting={} + meeting_pool=self.pool.get('crm.meeting') + for id in ids: + meeting_ids = meeting_pool.search(cr, uid, [('partner_id', '=', id)]) + total_meeting[id] = len(meeting_ids) + return total_meeting + + _columns = { 'section_id': fields.many2one('crm.case.section', 'Sales Team'), 'opportunity_ids': fields.one2many('crm.lead', 'partner_id',\ @@ -32,6 +51,13 @@ class res_partner(osv.osv): 'Meetings'), 'phonecall_ids': fields.one2many('crm.phonecall', 'partner_id',\ 'Phonecalls'), + 'total_oppo': fields.function(_total_oppo , type='integer',string="Total Opportunity"), + 'total_meeting': fields.function(_total_meeting , type='integer',string="Total Meeting"), + } + + _defaults = { + 'total_oppo': 0, + 'total_meeting': 0, } def redirect_partner_form(self, cr, uid, partner_id, context=None): @@ -49,6 +75,32 @@ class res_partner(osv.osv): } return value + def get_opportunity(self, cr, uid, ids, context=None): + if context is None: + context = {} + models_data = self.pool.get('ir.model.data') + + form_view = models_data.get_object_reference(cr, uid, 'crm', 'crm_case_form_view_oppor') + tree_view = models_data.get_object_reference(cr, uid, 'crm', 'crm_case_tree_view_oppor') + search_view = models_data.get_object_reference(cr, uid, 'crm', 'view_crm_case_opportunities_filter') + partner_id = self.browse(cr, uid, ids[0], context=context) + domain =[('partner_id', '=', partner_id.id)] + + return { + 'name': _('Opportunity'), + 'view_type': 'form', + 'view_mode': 'tree, form', + 'res_model': 'crm.lead', + 'domain': domain, + 'view_id': False, + 'views': [(tree_view and tree_view[1] or False, 'tree'), + (form_view and form_view[1] or False, 'form'), + (False, 'calendar'), (False, 'graph')], + 'type': 'ir.actions.act_window', + 'search_view_id': search_view and search_view[1] or False, + 'nodestroy': True, + } + def make_opportunity(self, cr, uid, ids, opportunity_summary, planned_revenue=0.0, probability=0.0, partner_id=None, context=None): categ_obj = self.pool.get('crm.case.categ') categ_ids = categ_obj.search(cr, uid, [('object_id.model','=','crm.lead')]) diff --git a/addons/crm/res_partner_view.xml b/addons/crm/res_partner_view.xml index 6926464cd93..d9f63276eca 100644 --- a/addons/crm/res_partner_view.xml +++ b/addons/crm/res_partner_view.xml @@ -42,6 +42,35 @@ + + + + res.partner.kanban.inherit + res.partner + kanban + + + + + + + + + + + () + Opportunity + Opportunities + + + () + Meeting + Meetings + + + + + res.partner.crm.info.inherit1 diff --git a/addons/sale/__init__.py b/addons/sale/__init__.py index 2688b61ddd9..fe19b7fa609 100644 --- a/addons/sale/__init__.py +++ b/addons/sale/__init__.py @@ -25,6 +25,7 @@ import sale import stock +import res_partner import wizard import report import company diff --git a/addons/sale/__openerp__.py b/addons/sale/__openerp__.py index 8a2686cca83..992a96f261d 100644 --- a/addons/sale/__openerp__.py +++ b/addons/sale/__openerp__.py @@ -80,6 +80,7 @@ Dashboard for Sales Manager that includes: 'sale_report.xml', 'sale_data.xml', 'sale_view.xml', + 'res_partner_view.xml', 'report/sale_report_view.xml', 'stock_view.xml', 'process/sale_process.xml', diff --git a/addons/sale/res_partner.py b/addons/sale/res_partner.py new file mode 100644 index 00000000000..20c47909ba6 --- /dev/null +++ b/addons/sale/res_partner.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields,osv +from tools.translate import _ + +class res_partner(osv.osv): + _inherit = 'res.partner' + + def _total_sale(self, cr, uid, ids, field_name, arg, context=None): + total_sale={} + sale_pool=self.pool.get('sale.order') + for id in ids: + sale_ids = sale_pool.search(cr, uid, [('partner_id', '=', id)]) + total_sale[id] = len(sale_ids) + return total_sale + + _columns = { + 'total_sale': fields.function(_total_sale , type='integer',string="Total Sale"), + } + _defaults = { + 'total_sale': 0, + } +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/res_partner_view.xml b/addons/sale/res_partner_view.xml new file mode 100644 index 00000000000..a13ecf29db8 --- /dev/null +++ b/addons/sale/res_partner_view.xml @@ -0,0 +1,25 @@ + + + + + + res.partner.kanban.inherit + res.partner + kanban + + + + + + + + () + Quatation + Quatations + + + + + + + diff --git a/addons/stock/product.py b/addons/stock/product.py index 304fa8dcd87..37d26e3d23f 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -26,6 +26,22 @@ import decimal_precision as dp class product_product(osv.osv): _inherit = "product.product" + def _get_reception(self, cr, uid, ids, field_name, arg, context=None): + total_reception={} + reception_pool=self.pool.get('stock.picking') + for id in ids: + reception_ids = reception_pool.search(cr, uid, [('move_lines.product_id','=',id),('type','=','in')]) + total_reception[id] = len(reception_ids) + return total_reception + + def _total_delivery(self, cr, uid, ids, field_name, arg, context=None): + total_delivery={} + delivery_pool=self.pool.get('stock.picking') + for id in ids: + delivery_ids = delivery_pool.search(cr, uid, [('move_lines.product_id', '=', id),('type','=','out')]) + total_delivery[id] = len(delivery_ids) + return total_delivery + def get_product_accounts(self, cr, uid, product_id, context=None): """ To get the stock input account, stock output account and stock journal related to product. @param product_id: product id @@ -331,6 +347,8 @@ class product_product(osv.osv): return res _columns = { + 'total_reception': fields.function(_get_reception , type='integer',string="Total Reception"), + 'total_delivery': fields.function(_total_delivery , type='integer',string="Total Delivery"), 'qty_available': fields.function(_product_available, multi='qty_available', type='float', digits_compute=dp.get_precision('Product UoM'), string='Quantity On Hand', @@ -446,6 +464,61 @@ class product_product(osv.osv): if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('Produced Qty') return res + def get_receptions(self, cr, uid, ids, context=None): + if context is None: + context = {} + models_data = self.pool.get('ir.model.data') + + form_view = models_data.get_object_reference(cr, uid, 'stock', 'view_picking_in_form') + tree_view = models_data.get_object_reference(cr, uid, 'stock', 'view_picking_in_tree') + search_view = models_data.get_object_reference(cr, uid, 'stock', 'view_picking_internal_search') + product_id = self.browse(cr, uid, ids[0], context=context) + domain =[('move_lines.product_id', '=', product_id.id),('type','=','in')] + context.update({'default_type': 'internal', 'contact_display': 'partner_address', 'search_default_available': 1}) + + return { + 'name': _('Receptions'), + 'view_type': 'form', + 'view_mode': 'tree, form', + 'res_model': 'stock.picking', + 'domain': domain, + 'view_id': False, + 'views': [(tree_view and tree_view[1] or False, 'tree'), + (form_view and form_view[1] or False, 'form'), + (False, 'calendar'), (False, 'graph')], + 'type': 'ir.actions.act_window', + 'context': context, + 'search_view_id': search_view and search_view[1] or False, + 'nodestroy': True, + } + + def get_deliveries(self, cr, uid, ids, context=None): + if context is None: + context = {} + models_data = self.pool.get('ir.model.data') + + form_view = models_data.get_object_reference(cr, uid, 'stock', 'view_picking_out_form') + tree_view = models_data.get_object_reference(cr, uid, 'stock', 'view_picking_out_tree') + search_view = models_data.get_object_reference(cr, uid, 'stock', 'view_picking_out_search') + product_id = self.browse(cr, uid, ids[0], context=context) + domain =[('move_lines.product_id', '=', product_id.id),('type','=','out')] + context.update({'default_type': 'out', 'contact_display': 'partner_address'}) + + return { + 'name': _('Deliveries'), + 'view_type': 'form', + 'view_mode': 'tree, form', + 'res_model': 'stock.picking', + 'domain': domain, + 'view_id': False, + 'views': [(tree_view and tree_view[1] or False, 'tree'), + (form_view and form_view[1] or False, 'form'), + (False, 'calendar'), (False, 'graph')], + 'type': 'ir.actions.act_window', + 'context':context, + 'search_view_id': search_view and search_view[1] or False, + 'nodestroy': True, + } product_product() diff --git a/addons/stock/product_view.xml b/addons/stock/product_view.xml index 5af954a023a..e5d070507e7 100644 --- a/addons/stock/product_view.xml +++ b/addons/stock/product_view.xml @@ -136,6 +136,8 @@ + +
@@ -150,6 +152,20 @@
  • Price:
  • Cost:
  • + + + () + Reception + Receptions + + + + + () + Delivery + Deliveries + +