[IMP] salesteams: add sales order and quotation
bzr revid: chm@openerp.com-20130206094414-8f7kp19dam6su991
This commit is contained in:
parent
bfcbb3f619
commit
b76f4c7a45
|
@ -109,17 +109,17 @@ 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, section_ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(section_ids, 0)
|
||||
def get_number_leads(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 section_ids:
|
||||
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)
|
||||
return res
|
||||
|
||||
def get_number_opportunities(self, cr, uid, section_ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(section_ids, 0)
|
||||
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 section_ids:
|
||||
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
|
||||
|
||||
|
|
|
@ -85,28 +85,11 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
}
|
||||
|
||||
def dynamic_help(self, cr, uid, help, context=None):
|
||||
alias_txt = ""
|
||||
if context.get('default_section_id'):
|
||||
project_id = self.pool.get('crm.case.section').browse(cr, uid, context.get('default_section_id'), context=context)
|
||||
alias = project_id.alias_id and project_id.alias_id.name_get() or False
|
||||
if alias and alias[0] and alias[0][1]:
|
||||
alias_txt = alias[0][1]
|
||||
else:
|
||||
model_id = self.pool.get('ir.model').search(cr, uid, [("model", "=", self._name)], context=context)[0]
|
||||
alias_obj = self.pool.get('mail.alias')
|
||||
alias_nb = 0
|
||||
alias_ids = alias_obj.search(cr, uid, [("alias_model_id", "=", model_id)], context=context, limit=5)
|
||||
if alias_ids:
|
||||
for alias in alias_obj.browse(cr, uid, alias_ids, context=context):
|
||||
email = "%s@%s" % (alias.alias_name, alias.alias_domain)
|
||||
alias_txt = "%s%s%s" % (alias_txt, (alias_nb and ", " or " "), email)
|
||||
alias_nb += 1
|
||||
if alias_txt:
|
||||
if context.get('default_type', False) == "opportunity":
|
||||
help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create opportunities by sending an email to: <b>%s</b></div>" % alias_txt))
|
||||
else:
|
||||
help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create lead by sending an email to: <b>%s</b></div>" % alias_txt))
|
||||
return help
|
||||
if context.get('default_type', None) == 'lead':
|
||||
context['dynamic_help_model'] = 'crm.case.section'
|
||||
context['dynamic_help_id'] = context.get('default_section_id', None)
|
||||
context['dynamic_help_documents'] = _("leads")
|
||||
return super(crm_lead, self).dynamic_help(cr, uid, help, context=context)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<field name="view_mode">kanban,tree,graph,form,calendar</field>
|
||||
<field name="domain">[('type','=','opportunity')]</field>
|
||||
<field name="view_id" ref="crm.crm_case_kanban_view_leads"/>
|
||||
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
|
||||
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
|
||||
<field name="context">{
|
||||
'search_default_section_id': [active_id], 'default_section_id': active_id, 'stage_type': 'opportunity', 'default_type': 'opportunity', 'default_user_id': uid
|
||||
}</field>
|
||||
|
@ -120,12 +120,12 @@
|
|||
<span class="oe_e">%%</span><small><field name="alias_id"/></small>
|
||||
</div>
|
||||
<div class="oe_kanban_crm_salesteams_list">
|
||||
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action" style="margin-right: 10px">
|
||||
<field name="number_opportunity"/>
|
||||
<t t-if="record.number_opportunity.raw_value > 1">Opportunities</t><t t-if="record.number_opportunity.raw_value <= 1">Opportunity</t></a>
|
||||
<a name="%(crm_case_form_view_salesteams_lead)d" type="action" style="margin-right: 10px">
|
||||
<field name="number_lead"/>
|
||||
<t t-if="record.number_lead.raw_value > 1">Leads</t><t t-if="record.number_lead.raw_value <= 1">Lead</t></a>
|
||||
<t t-raw="record.number_lead.raw_value"/>
|
||||
<t t-if="record.number_lead.raw_value >= 1">Leads</t><t t-if="record.number_lead.raw_value < 1">Lead</t></a>
|
||||
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action" style="margin-right: 10px">
|
||||
<t t-raw="record.number_opportunity.raw_value"/>
|
||||
<t t-if="record.number_opportunity.raw_value >= 1">Opportunities</t><t t-if="record.number_opportunity.raw_value < 1">Opportunity</t></a>
|
||||
</div>
|
||||
<div class="oe_kanban_crm_salesteams_avatars">
|
||||
<t t-foreach="record.member_ids.raw_value.slice(0,11)" t-as="member">
|
||||
|
|
|
@ -36,4 +36,8 @@
|
|||
.oe_kanban_crm_salesteams_alias small {
|
||||
display: block;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.oe_kanban_crm_salesteams_list a {
|
||||
white-space: nowrap;
|
||||
}
|
|
@ -35,6 +35,7 @@ from openerp import SUPERUSER_ID
|
|||
from openerp.addons.mail.mail_message import decode
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
from openerp.tools.translate import _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -88,6 +89,31 @@ class mail_thread(osv.AbstractModel):
|
|||
# :param function lambda: returns whether the tracking should record using this subtype
|
||||
_track = {}
|
||||
|
||||
def dynamic_help(self, cr, uid, help, context=None):
|
||||
if not context.get('dynamic_help_model', None):
|
||||
return help
|
||||
|
||||
alias_txt = ""
|
||||
if context.get('dynamic_help_id', None):
|
||||
object_id = self.pool.get(context.get('dynamic_help_model')).browse(cr, uid, context.get('dynamic_help_id'), context=context)
|
||||
alias = object_id.alias_id and object_id.alias_id.name_get() or False
|
||||
if alias and alias[0] and alias[0][1]:
|
||||
alias_txt = alias[0][1]
|
||||
else:
|
||||
model_id = self.pool.get('ir.model').search(cr, uid, [("model", "=", self._name)], context=context)[0]
|
||||
alias_obj = self.pool.get('mail.alias')
|
||||
alias_nb = 0
|
||||
alias_ids = alias_obj.search(cr, uid, [("alias_model_id", "=", model_id)], context=context, limit=5)
|
||||
if alias_ids:
|
||||
for alias in alias_obj.browse(cr, uid, alias_ids, context=context):
|
||||
email = "%s@%s" % (alias.alias_name, alias.alias_domain)
|
||||
alias_txt = "%s%s%s" % (alias_txt, (alias_nb and ", " or " "), email)
|
||||
alias_nb += 1
|
||||
if alias_txt:
|
||||
help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create %s by sending an email to: <b>%s</b></div>" % (context.get('dynamic_help_documents', _("documents")), alias_txt)))
|
||||
|
||||
return help
|
||||
|
||||
def _get_message_data(self, cr, uid, ids, name, args, context=None):
|
||||
""" Computes:
|
||||
- message_unread: has uid unread message for the document
|
||||
|
|
|
@ -891,26 +891,12 @@ class task(base_stage, osv.osv):
|
|||
|
||||
|
||||
def dynamic_help(self, cr, uid, help, context=None):
|
||||
alias_txt = ""
|
||||
if context.get('default_project_id'):
|
||||
project_id = self.pool.get('project.project').browse(cr, uid, context.get('default_project_id'), context=context)
|
||||
alias = project_id.alias_id and project_id.alias_id.name_get() or False
|
||||
if alias and alias[0] and alias[0][1]:
|
||||
alias_txt = alias[0][1]
|
||||
else:
|
||||
model_id = self.pool.get('ir.model').search(cr, uid, [("model", "=", self._name)], context=context)[0]
|
||||
alias_obj = self.pool.get('mail.alias')
|
||||
alias_nb = 0
|
||||
alias_ids = alias_obj.search(cr, uid, [("alias_model_id", "=", model_id)], context=context, limit=5)
|
||||
if alias_ids:
|
||||
for alias in alias_obj.browse(cr, uid, alias_ids, context=context):
|
||||
email = "%s@%s" % (alias.alias_name, alias.alias_domain)
|
||||
alias_txt = "%s%s%s" % (alias_txt, (alias_nb and ", " or " "), email)
|
||||
alias_nb += 1
|
||||
if alias_txt:
|
||||
help = "%s %s" % (help, _("<div class='oe_view_nocontent_create_alias'>You can also create tasks by sending an email to: <b>%s</b></div>" % alias_txt))
|
||||
return help
|
||||
|
||||
context['dynamic_help_model'] = 'project.project'
|
||||
context['dynamic_help_id'] = context.get('default_project_id', None)
|
||||
context['dynamic_help_documents'] = _("tasks")
|
||||
print context
|
||||
return super(task, self).dynamic_help(cr, uid, help, context=context)
|
||||
|
||||
# ----------------------------------------
|
||||
# Case management
|
||||
# ----------------------------------------
|
||||
|
|
|
@ -340,6 +340,7 @@
|
|||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_orders" id="menu_sale_order" parent="base.menu_sales" sequence="5" groups="base.group_sale_salesman,base.group_sale_manager"/>
|
||||
|
||||
<record id="action_orders_exception" model="ir.actions.act_window">
|
||||
|
|
|
@ -29,6 +29,27 @@ class sale_order(osv.osv):
|
|||
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]")
|
||||
}
|
||||
|
||||
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_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
|
||||
|
||||
_columns = {
|
||||
'number_saleorder': fields.function(get_number_saleorder, type='integer', readonly=True),
|
||||
'number_quotation': fields.function(get_number_quotation, type='integer', readonly=True),
|
||||
}
|
||||
|
||||
class res_users(osv.Model):
|
||||
_inherit = 'res.users'
|
||||
|
|
|
@ -113,5 +113,78 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- search by Salesteams -->
|
||||
|
||||
<record id="action_orders_salesteams" model="ir.actions.act_window">
|
||||
<field name="name">Sales Orders</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,calendar,graph</field>
|
||||
<field name="search_view_id" ref="sale.view_sales_order_filter"/>
|
||||
<field name="domain">[('state','not in',('draft','sent','cancel'))]</field>
|
||||
<field name="context">{
|
||||
'search_default_section_id': [active_id], 'default_section_id': active_id
|
||||
}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a quotation that can be converted into a sales
|
||||
order.
|
||||
</p><p>
|
||||
OpenERP will help you efficiently handle the complete sales flow:
|
||||
quotation, sales order, delivery, invoicing and payment.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_quotations_salesteams" model="ir.actions.act_window">
|
||||
<field name="name">Quotations</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="sale.view_quotation_tree"/>
|
||||
<field name="view_mode">tree,form,calendar,graph</field>
|
||||
<field name="context">{
|
||||
'search_default_section_id': [active_id], 'default_section_id': active_id, 'show_address': 1
|
||||
}</field>
|
||||
<field name="domain">[('state','in',('draft','sent','cancel'))]</field>
|
||||
<field name="search_view_id" ref="sale.view_sales_order_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to create a quotation, the first step of a new sale.
|
||||
</p><p>
|
||||
OpenERP will help you handle efficiently the complete sale flow:
|
||||
from the quotation to the sales order, the
|
||||
delivery, the invoicing and the payment collection.
|
||||
</p><p>
|
||||
The social feature helps you organize discussions on each sales
|
||||
order, and allow your customers to keep track of the evolution
|
||||
of the sales order.
|
||||
</p>
|
||||
</field>
|
||||
</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>
|
||||
<field name="inherit_id" ref="crm.crm_case_section_salesteams_view_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='number_opportunity']" position="after">
|
||||
<field name="number_quotation"/>
|
||||
<field name="number_saleorder"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_kanban_crm_salesteams_list']" position="inside">
|
||||
<a name="%(action_quotations_salesteams)d" type="action" style="margin-right: 10px">
|
||||
<t t-raw="record.number_quotation.raw_value"/>
|
||||
<t t-if="record.number_quotation.raw_value >= 1">Quotation</t><t t-if="record.number_quotation.raw_value < 1">Quotations</t></a>
|
||||
<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>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue