[IMP] salesteams: add account, crm: on_change user_id, change the salesteams
bzr revid: chm@openerp.com-20130206115736-fw3coo0u50itvjlq
This commit is contained in:
parent
1c58057325
commit
0c4a656639
|
@ -109,19 +109,18 @@ class crm_case_section(osv.osv):
|
|||
def get_full_name(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return dict(self.name_get(cr, uid, ids, context=context))
|
||||
|
||||
def get_number_leads(self, cr, uid, ids, field_name, arg, context=None):
|
||||
def get_number_items(self, cr, uid, ids, model, domain, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
obj = self.pool.get(model)
|
||||
for section_id in ids:
|
||||
res[section_id] = lead_obj.search(cr, uid, [("section_id", "=", section_id), '|', '|', ("type", "=", "lead"), ("type", "=", "both"), ("type", "=", False), ('state', 'not in', ['done', 'cancel'])], count=True, context=context)
|
||||
res[section_id] = obj.search(cr, uid, [("section_id", "=", section_id)] + domain, count=True, context=context)
|
||||
return res
|
||||
|
||||
def get_number_opportunities(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
lead_obj = self.pool.get('crm.lead')
|
||||
for section_id in ids:
|
||||
res[section_id] = lead_obj.search(cr, uid, [("section_id", "=", section_id), '|', ("type", "=", "opportunity"), ("type", "=", "both"), ('state', 'not in', ['done', 'cancel'])], context=context, count=True)
|
||||
return res
|
||||
def _get_number_leads(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return self.get_number_items(cr, uid, ids, 'crm.lead', ['|', '|', ("type", "=", "lead"), ("type", "=", "both"), ("type", "=", False), ('state', 'not in', ['done', 'cancel'])], context=context)
|
||||
|
||||
def _get_number_opportunities(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return self.get_number_items(cr, uid, ids, 'crm.lead', ['|', ("type", "=", "opportunity"), ("type", "=", "both"), ('state', 'not in', ['done', 'cancel'])], context=context)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Sales Team', size=64, required=True, translate=True),
|
||||
|
@ -142,8 +141,9 @@ class crm_case_section(osv.osv):
|
|||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
|
||||
help="The email address associated with this team. New emails received will automatically "
|
||||
"create new leads assigned to the team."),
|
||||
'number_lead': fields.function(get_number_leads, type='integer', readonly=True),
|
||||
'number_opportunity': fields.function(get_number_opportunities, type='integer', readonly=True),
|
||||
'number_lead': fields.function(_get_number_leads, type='integer', readonly=True),
|
||||
'number_opportunity': fields.function(_get_number_opportunities, type='integer', readonly=True),
|
||||
'color': fields.integer('Color Index'),
|
||||
}
|
||||
|
||||
def _get_stage_common(self, cr, uid, context):
|
||||
|
|
|
@ -90,6 +90,13 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
context['dynamic_help_documents'] = _("leads")
|
||||
return super(crm_lead, self).dynamic_help(cr, uid, help, context=context)
|
||||
|
||||
def onchange_user_id(self, cr, uid, ids, section_id, user_id, context=None):
|
||||
if user_id:
|
||||
section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context)
|
||||
if section_ids and (not section_id or section_id not in section_ids):
|
||||
section_id = section_ids[0]
|
||||
return {'value': {'section_id': section_id}}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
|
|
@ -152,7 +152,7 @@
|
|||
-->
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_id"/>
|
||||
<field name="user_id" on_change="onchange_user_id(section_id, user_id)"/>
|
||||
<label for="section_id"/>
|
||||
<div>
|
||||
<field name="section_id"/>
|
||||
|
@ -424,7 +424,7 @@
|
|||
</group>
|
||||
|
||||
<group>
|
||||
<field name="user_id"/>
|
||||
<field name="user_id" on_change="onchange_user_id(section_id, user_id)"/>
|
||||
<label for="section_id"/>
|
||||
<div>
|
||||
<field name="section_id" widget="selection"/>
|
||||
|
|
|
@ -102,16 +102,18 @@
|
|||
<field name="member_ids"/>
|
||||
<field name="note"/>
|
||||
<field name="alias_id"/>
|
||||
<field name="color"/>
|
||||
<field name="number_lead"/>
|
||||
<field name="number_opportunity"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_card oe_kanban_crm_salesteams oe_kanban_global_click oe_kanban_crm_salesteams" style="width:220px;">
|
||||
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_project oe_kanban_global_click oe_kanban_crm_salesteams" style="width:220px;">
|
||||
<div class="oe_dropdown_toggle oe_dropdown_kanban" groups="base.group_user">
|
||||
<span class="oe_e">í</span>
|
||||
<ul class="oe_dropdown_menu">
|
||||
<t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Sales Teams Settings</a></li></t>
|
||||
<t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
|
||||
<li t-if="widget.view.is_action_enabled('edit')"><a type="edit">Sales Teams Settings</a></li>
|
||||
<li t-if="widget.view.is_action_enabled('delete')"><a type="delete">Delete</a></li>
|
||||
<li t-if="widget.view.is_action_enabled('edit')"><ul class="oe_kanban_colorpicker" data-field="color"/></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="oe_kanban_content">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
|
||||
.oe_kanban_crm_salesteams_alias {
|
||||
margin: -8px 0 8px 0;
|
||||
margin: -2px 0 8px 0;
|
||||
}
|
||||
|
||||
.oe_kanban_crm_salesteams_alias .oe_e {
|
||||
|
|
|
@ -32,23 +32,19 @@ class sale_order(osv.osv):
|
|||
class crm_case_section(osv.osv):
|
||||
_inherit = 'crm.case.section'
|
||||
|
||||
def get_number_saleorder(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
obj = self.pool.get('sale.order')
|
||||
for section_id in ids:
|
||||
res[section_id] = obj.search(cr, uid, [("section_id", "=", section_id), ('state','not in',('draft','sent','cancel'))], context=context, count=True)
|
||||
return res
|
||||
def _get_number_saleorder(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return self.get_number_items(cr, uid, ids, 'sale.order', [('state','not in',('draft','sent','cancel'))], context=context)
|
||||
|
||||
def get_number_quotation(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
obj = self.pool.get('sale.order')
|
||||
for section_id in ids:
|
||||
res[section_id] = obj.search(cr, uid, [("section_id", "=", section_id), ('state','in',('draft','sent','cancel'))], context=context, count=True)
|
||||
return res
|
||||
def _get_number_quotation(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return self.get_number_items(cr, uid, ids, 'sale.order', [('state','in',('draft','sent','cancel'))], context=context)
|
||||
|
||||
def _get_number_invoice(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return self.get_number_items(cr, uid, ids, 'account.invoice', [('state','not in',('draft','cancel'))], context=context)
|
||||
|
||||
_columns = {
|
||||
'number_saleorder': fields.function(get_number_saleorder, type='integer', readonly=True),
|
||||
'number_quotation': fields.function(get_number_quotation, type='integer', readonly=True),
|
||||
'number_saleorder': fields.function(_get_number_saleorder, type='integer', readonly=True),
|
||||
'number_quotation': fields.function(_get_number_quotation, type='integer', readonly=True),
|
||||
'number_invoice': fields.function(_get_number_invoice, type='integer', readonly=True),
|
||||
}
|
||||
|
||||
class res_users(osv.Model):
|
||||
|
|
|
@ -164,6 +164,17 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_invoice_salesteams" model="ir.actions.act_window">
|
||||
<field name="name">Invoices</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,calendar,graph</field>
|
||||
<field name="view_id" ref="account.invoice_tree"/>
|
||||
<field name="domain">[('state','not in',['draft','cancel'])]</field>
|
||||
<field name="context">{'search_default_section_id': [active_id], 'default_section_id': active_id}</field>
|
||||
<field name="search_view_id" ref="account.view_account_invoice_filter"/>
|
||||
</record>
|
||||
|
||||
<record id="crm_case_section_salesteams_view_kanban" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.kanban</field>
|
||||
<field name="model">crm.case.section</field>
|
||||
|
@ -173,6 +184,7 @@
|
|||
<xpath expr="//field[@name='number_opportunity']" position="after">
|
||||
<field name="number_quotation"/>
|
||||
<field name="number_saleorder"/>
|
||||
<field name="number_invoice"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_kanban_crm_salesteams_list']" position="inside">
|
||||
<a name="%(action_quotations_salesteams)d" type="action" style="margin-right: 10px">
|
||||
|
@ -181,6 +193,9 @@
|
|||
<a name="%(action_orders_salesteams)d" type="action" style="margin-right: 10px">
|
||||
<t t-raw="record.number_saleorder.raw_value"/>
|
||||
<t t-if="record.number_saleorder.raw_value >= 1">Sales Order</t><t t-if="record.number_saleorder.raw_value < 1">Sales Orders</t></a>
|
||||
<a name="%(action_invoice_salesteams)d" type="action" style="margin-right: 10px">
|
||||
<t t-raw="record.number_invoice.raw_value"/>
|
||||
<t t-if="record.number_invoice.raw_value >= 1">Invoice</t><t t-if="record.number_invoice.raw_value < 1">Invoices</t></a>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue