[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
This commit is contained in:
DBR (OpenERP) 2012-04-26 16:01:33 +05:30
parent 5fcb87c60f
commit d9c305ef06
9 changed files with 243 additions and 4 deletions

View File

@ -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')])

View File

@ -42,6 +42,35 @@
</field>
</record>
<!-- Partner kanban view inherte -->
<record model="ir.ui.view" id="crm_lead_partner_kanban_view">
<field name="name">res.partner.kanban.inherit</field>
<field name="model">res.partner</field>
<field name="type">kanban</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="arch" type="xml">
<field name="mobile" position="after">
<field name="opportunity_ids"/>
<field name="meeting_ids"/>
<field name="total_oppo"/>
<field name="total_meeting"/>
</field>
<xpath expr="//div[@class='oe_partner_desc']//h4[@class='oe_partner_heading']" position="after">
<a name="get_opportunity" type="object">
(<t t-esc="record.total_oppo.value"/>)
<t t-if="record.total_oppo.value &lt;= 1">Opportunity</t>
<t t-if="record.total_oppo.value > 1"> Opportunities</t>
</a>
<a name="%(crm.crm_case_categ_meet)d" type="action">
(<t t-esc="record.total_meeting.value"/>)
<t t-if="record.total_meeting.value &lt;= 1">Meeting</t>
<t t-if="record.total_meeting.value > 1">Meetings</t>
</a>
</xpath>
</field>
</record>
<!-- Add History tabs to res.partner form -->
<record id="view_crm_partner_info_form1" model="ir.ui.view">
<field name="name">res.partner.crm.info.inherit1</field>

View File

@ -25,6 +25,7 @@
import sale
import stock
import res_partner
import wizard
import report
import company

View File

@ -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',

View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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:

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Partner kanban view inherte -->
<record model="ir.ui.view" id="crm_lead_partner_kanban_view">
<field name="name">res.partner.kanban.inherit</field>
<field name="model">res.partner</field>
<field name="type">kanban</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="arch" type="xml">
<field name="mobile" position="after">
<field name="total_sale"/>
</field>
<xpath expr="//div[@class='oe_partner_desc']//h4[@class='oe_partner_heading']" position="after">
<a name="%(sale.act_res_partner_2_sale_order)d" type="action">
(<t t-esc="record.total_sale.value" />)
<t t-if="record.total_sale.value &lt;= 1">Quatation</t>
<t t-if="record.total_sale.value > 1">Quatations</t>
</a>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -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()

View File

@ -136,6 +136,8 @@
<field name="type"/>
<field name="product_image"/>
<field name="list_price"/>
<field name="total_reception"/>
<field name="total_delivery"/>
<templates>
<t t-name="kanban-box">
<div class="oe_product_vignette">
@ -150,6 +152,20 @@
<li>Price: <field name="lst_price"></field></li>
<li>Cost: <field name="standard_price"></field></li>
</ul>
<t t-if="record.total_reception.raw_value">
<a name="get_receptions" type="object">
(<t t-esc="record.total_reception.value"/>)
<t t-if="record.total_reception.raw_value &lt;= 1">Reception</t>
<t t-if="record.total_reception.raw_value > 1"> Receptions</t>
</a>
</t>
<t t-if="record.total_delivery.raw_value">
<a name="get_deliveries" type="object">
(<t t-esc="record.total_delivery.value"/>)
<t t-if="record.total_delivery.raw_value &lt;= 1">Delivery</t>
<t t-if="record.total_delivery.raw_value > 1">Deliveries</t>
</a>
</t>
</div>
</div>
<script>

View File

@ -9,8 +9,8 @@
}
.oe_product_img {
width: 100px;
height: 100px;
width: 150px;
height: 150px;
text-align: center;
overflow: hidden;
-moz-border-radius: 3px;
@ -25,13 +25,13 @@
}
.oe_product_photo {
width: 100px;
width: 150px;
height: auto;
clip: rect(5px, 100px, 105px, 0px);
}
.oe_product_photo_wide {
height: 100px;
height: 150px;
width: auto;
clip: rect(0px, 110px, 100px, 10px);
}