[MERGE] [IMP] Added a website salesteam, used to handle ecommerce quotations and
contact leads. Also added use_opportunities and use_quotations boolean fields on sales team, like use_leads to ease the salesteam customization. Also removed some dead code in website_sale_crm and website_sale_delivery.
This commit is contained in:
@@ -39,6 +39,7 @@ class crm_case_section(osv.Model):
|
||||
'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
|
||||
'use_leads': fields.boolean('Leads',
|
||||
help="The first contact you get with a potential customer is a lead you qualify before converting it into a real business opportunity. Check this box to manage leads in this sales team."),
|
||||
'use_opportunities': fields.boolean('Opportunities', help="Check this box to manage opportunities in this sales team."),
|
||||
'monthly_open_leads': fields.function(_get_opportunities_data,
|
||||
type="string", readonly=True, multi='_get_opportunities_data',
|
||||
string='Open Leads per Month'),
|
||||
@@ -60,6 +61,7 @@ class crm_case_section(osv.Model):
|
||||
_defaults = {
|
||||
'stage_ids': _get_stage_common,
|
||||
'use_leads': True,
|
||||
'use_opportunities': True,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<xpath expr="//templates" position="before">
|
||||
<field name="alias_id"/>
|
||||
<field name="use_leads"/>
|
||||
<field name="use_opportunities"/>
|
||||
<field name="monthly_open_leads"/>
|
||||
<field name="monthly_planned_revenue"/>
|
||||
</xpath>
|
||||
@@ -103,7 +104,7 @@
|
||||
options="{'height': '20px', 'barWidth': 4, 'barSpacing': 1, 'delayIn': '3000', 'tooltip_suffix': ' Leads'}">Open Leads per Month<br/>Click to see a detailed analysis of leads.</field>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_salesteams_opportunities">
|
||||
<div class="oe_salesteams_opportunities" t-if="record.use_opportunities.raw_value">
|
||||
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action">Opportunities</a>
|
||||
<a name="%(action_report_crm_opportunity_salesteam)d" type="action">
|
||||
<field name="monthly_planned_revenue" widget="sparkline_bar"
|
||||
@@ -121,8 +122,9 @@
|
||||
<field name="model">crm.case.section</field>
|
||||
<field name="inherit_id" ref="sales_team.crm_case_section_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<h6><field name="use_leads"/><label for="use_leads" string="Leads"/></h6>
|
||||
<xpath expr="//div[@name='options_active']" position="inside">
|
||||
<field name="use_leads"/><label for="use_leads" string="Leads"/>
|
||||
<field name="use_opportunities" class="oe_inline"/><label for="use_opportunities"/>
|
||||
</xpath>
|
||||
<xpath expr="//group/field[@name='active']" position="inside">
|
||||
<group>
|
||||
|
||||
@@ -19,7 +19,7 @@ class crm_case_section(osv.osv):
|
||||
date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
for id in ids:
|
||||
res[id] = dict()
|
||||
created_domain = [('section_id', '=', id), ('state', '=', ['draft']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
created_domain = [('section_id', '=', id), ('state', '=', 'draft'), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
res[id]['monthly_quoted'] = self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)
|
||||
validated_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'sent', 'cancel']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
res[id]['monthly_confirmed'] = self.__get_bar_values(cr, uid, obj, validated_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)
|
||||
@@ -37,6 +37,7 @@ class crm_case_section(osv.osv):
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'use_quotations': fields.boolean('Opportunities', help="Check this box to manage quotations in this sales team."),
|
||||
'invoiced_forecast': fields.integer(string='Invoice Forecast',
|
||||
help="Forecast of the invoice revenue for the current month. This is the amount the sales \n"
|
||||
"team should invoice this month. It is used to compute the progression ratio \n"
|
||||
@@ -55,6 +56,10 @@ class crm_case_section(osv.osv):
|
||||
string='Rate of sent invoices per duration'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'use_quotations': True,
|
||||
}
|
||||
|
||||
def action_forecast(self, cr, uid, id, value, context=None):
|
||||
return self.write(cr, uid, [id], {'invoiced_forecast': round(float(value))}, context=context)
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
<field name="inherit_id" ref="sales_team.crm_case_section_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//div[@name='options_active']" position="inside">
|
||||
<field name="use_quotations" class="oe_inline"/><label for="use_quotations"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='code']" position="after">
|
||||
<field name="invoiced_target"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
@@ -22,6 +25,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="use_quotations"/>
|
||||
<field name="monthly_quoted"/>
|
||||
<field name="monthly_confirmed"/>
|
||||
<field name="monthly_invoiced"/>
|
||||
@@ -30,7 +34,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_clear']" position="before">
|
||||
<div class="oe_items_list">
|
||||
<div class="oe_salesteams_quotations">
|
||||
<div class="oe_salesteams_quotations" t-if="record.use_quotations.raw_value">
|
||||
<a name="%(action_quotations_salesteams)d" type="action" class="oe_sparkline_bar_link">Quotations</a>
|
||||
<a name="%(action_order_report_quotation_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_quoted" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
|
||||
@@ -32,5 +32,3 @@ class sale_order(osv.osv):
|
||||
'categ_ids': fields.many2many('crm.case.categ', 'sale_order_category_rel', 'order_id', 'category_id', 'Tags', \
|
||||
domain="['|', ('section_id', '=', section_id), ('section_id', '=', False), ('object_id.model', '=', 'crm.lead')]", context="{'object_name': 'crm.lead'}")
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
<h1>
|
||||
<field name="name" string="Salesteam"/>
|
||||
</h1>
|
||||
<div name="options_active"></div>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
|
||||
@@ -71,6 +71,7 @@ class contactus(http.Controller):
|
||||
if not hasattr(field_value, 'filename'):
|
||||
post['description'] = "%s\n%s: %s" % (post['description'], field_name, field_value)
|
||||
|
||||
post['section_id'] = request.registry['ir.model.data'].xmlid_to_res_id(request.cr, SUPERUSER_ID, 'website.salesteam_website_sales')
|
||||
lead_id = request.registry['crm.lead'].create(request.cr, SUPERUSER_ID, post, request.context)
|
||||
|
||||
for field_name, field_value in kwargs.items():
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
<field name="state">open</field>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.section" id="website.section_sales_department">
|
||||
<field name="name">Website</field>
|
||||
<field name="code">Website</field>
|
||||
<field name="use_leads">True</field>
|
||||
<record model="crm.case.section" id="website.salesteam_website_sales">
|
||||
<field name="name">Website Sales</field>
|
||||
<field name="code">WS</field>
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
|
||||
<field name="use_leads">True</field>
|
||||
<field name="use_opportunities" eval="False"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -15,6 +15,7 @@ OpenERP E-Commerce
|
||||
'views/views.xml',
|
||||
'views/templates.xml',
|
||||
'views/payment.xml',
|
||||
'views/sale_order.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_sale.xml',
|
||||
],
|
||||
|
||||
@@ -518,6 +518,7 @@ class website_sale(http.Controller):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
payment_obj = request.registry.get('payment.acquirer')
|
||||
transaction_obj = request.registry.get('payment.transaction')
|
||||
sale_order_obj = request.registry['sale.order']
|
||||
order = request.website.sale_get_order(context=context)
|
||||
|
||||
if not order or not order.order_line or acquirer_id is None:
|
||||
@@ -539,11 +540,20 @@ class website_sale(http.Controller):
|
||||
'sale_order_id': order.id,
|
||||
}, context=context)
|
||||
request.session['sale_transaction_id'] = tx_id
|
||||
elif tx.state == 'draft': # button cliked but no more info -> rewrite on tx or create a new one ?
|
||||
elif tx and tx.state == 'draft': # button cliked but no more info -> rewrite on tx or create a new one ?
|
||||
tx.write({
|
||||
'acquirer_id': acquirer_id,
|
||||
})
|
||||
|
||||
# update quotation
|
||||
sale_order_obj.write(
|
||||
cr, SUPERUSER_ID, [order.id], {
|
||||
'payment_acquirer_id': acquirer_id,
|
||||
'payment_tx_id': request.session['sale_transaction_id']
|
||||
}, context=context)
|
||||
# confirm the quotation
|
||||
sale_order_obj.action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
|
||||
|
||||
acquirer_form_post_url = payment_obj.get_form_action_url(cr, uid, acquirer_id, context=context)
|
||||
acquirer_total_url = '%s?%s' % (acquirer_form_post_url, werkzeug.url_encode(post))
|
||||
return request.redirect(acquirer_total_url)
|
||||
@@ -622,12 +632,7 @@ class website_sale(http.Controller):
|
||||
if not tx or not order:
|
||||
return request.redirect('/shop')
|
||||
|
||||
if not order.amount_total or tx.state == 'done':
|
||||
# confirm the quotation
|
||||
sale_order_obj.action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
|
||||
# send by email
|
||||
email_act = sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context)
|
||||
elif tx.state == 'pending':
|
||||
if not order.amount_total or tx.state in ['pending', 'done']:
|
||||
# send by email
|
||||
email_act = sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context)
|
||||
elif tx.state == 'cancel':
|
||||
|
||||
@@ -32,5 +32,12 @@
|
||||
<field name="html_class">oe_image_full</field>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.section" id="website.salesteam_website_sales">
|
||||
<field name="name">Website Sales</field>
|
||||
<field name="code">WS</field>
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
|
||||
<field name="use_quotations" eval="False"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -547,5 +547,10 @@ Weight: 1.1 ounces</field>
|
||||
<field name="price_discount">-0.2000</field>
|
||||
<field name="sequence">1</field>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.section" id="website.salesteam_website_sales">
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'), ref('base.user_demo'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -5,6 +5,7 @@ from openerp import SUPERUSER_ID
|
||||
from openerp.osv import osv, orm, fields
|
||||
from openerp.addons.web.http import request
|
||||
|
||||
|
||||
class payment_transaction(orm.Model):
|
||||
_inherit = 'payment.transaction'
|
||||
|
||||
@@ -17,7 +18,7 @@ class sale_order(osv.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
def _cart_qty(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict();
|
||||
res = dict()
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
res[order.id] = int(sum(l.product_uom_qty for l in (order.website_order_line or [])))
|
||||
return res
|
||||
@@ -28,7 +29,9 @@ class sale_order(osv.Model):
|
||||
string='Order Lines displayed on Website', readonly=True,
|
||||
help='Order Lines to be displayed on the website. They should not be used for computation purpose.',
|
||||
),
|
||||
'cart_quantity': fields.function(_cart_qty, type='integer', string='Main Menu'),
|
||||
'cart_quantity': fields.function(_cart_qty, type='integer', string='Cart Quantity'),
|
||||
'payment_acquirer_id': fields.many2one('payment.acquirer', 'Payment Acquirer', on_delete='set null'),
|
||||
'payment_tx_id': fields.many2one('payment.transaction', 'Transaction', on_delete='set null'),
|
||||
}
|
||||
|
||||
def _get_errors(self, cr, uid, order, context=None):
|
||||
@@ -138,6 +141,7 @@ class website(orm.Model):
|
||||
'user_id': w.user_id.id,
|
||||
'partner_id': partner.id,
|
||||
'pricelist_id': partner.property_product_pricelist.id,
|
||||
'section_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'website', 'salesteam_website_sales')[1],
|
||||
}
|
||||
sale_order_id = sale_order_obj.create(cr, SUPERUSER_ID, values, context=context)
|
||||
values = sale_order_obj.onchange_partner_id(cr, SUPERUSER_ID, [], partner.id, context=context)['value']
|
||||
|
||||
@@ -23,5 +23,10 @@
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- toggle multi salesteam mode -->
|
||||
<record id="base.group_user" model="res.groups">
|
||||
<field name="implied_ids" eval="[(3, ref('base.group_mono_salesteams')), (4, ref('base.group_multi_salesteams'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_order_form_acquirer" model="ir.ui.view">
|
||||
<field name="name">sale.order.form.acquirer</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='amount_total']" position="after">
|
||||
<field name="payment_acquirer_id" readonly="1" attrs="{'invisible': [('payment_acquirer_id', '=', False)]}"/>
|
||||
<field name="payment_tx_id" readonly="1" attrs="{'invisible': [('payment_acquirer_id', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
'name': 'eCommerce with CRM',
|
||||
'version': '0.1',
|
||||
'category': 'Hidden',
|
||||
'description': """
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website_sale', 'sale_crm'],
|
||||
'data': [
|
||||
'data/website_sale_crm.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record model="crm.case.section" id="website.section_sales_department">
|
||||
<field name="name">Website</field>
|
||||
<field name="code">Website</field>
|
||||
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1 +0,0 @@
|
||||
import website
|
||||
@@ -1,14 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp.osv import orm
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
class Website(orm.Model):
|
||||
_inherit = 'website'
|
||||
|
||||
def _ecommerce_create_quotation(self, cr, uid, context=None):
|
||||
order_id = super(Website, self)._ecommerce_create_quotation(cr, uid, context=context)
|
||||
section_ids = self.pool["crm.case.section"].search(cr, SUPERUSER_ID, [("code", "=", "Website")], context=context)
|
||||
if section_ids:
|
||||
self.pool["sale.order"].write(cr, SUPERUSER_ID, {'section_id': section_ids[0]}, context=context)
|
||||
return order_id
|
||||
@@ -1,2 +1 @@
|
||||
import sale_order
|
||||
import website
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp.osv import orm
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
class Website(orm.Model):
|
||||
_inherit = 'website'
|
||||
|
||||
def _ecommerce_create_quotation(self, cr, uid, context=None):
|
||||
order_id = super(Website, self)._ecommerce_create_quotation(cr, uid, context=context)
|
||||
order = self.pool['sale.order'].browse(cr, SUPERUSER_ID, order_id, context=context)
|
||||
self.pool['sale.order']._check_carrier_quotation(cr, uid, order, force_carrier_id=None, context=context)
|
||||
return order_id
|
||||
|
||||
def _ecommerce_add_product_to_cart(self, cr, uid, product_id=0, order_line_id=0, number=1, set_number=-1, context=None):
|
||||
quantity = super(Website, self)._ecommerce_add_product_to_cart(cr, uid,
|
||||
product_id=product_id, order_line_id=order_line_id, number=number, set_number=set_number,
|
||||
context=context)
|
||||
order = self.ecommerce_get_current_order(cr, uid, context=context)
|
||||
self.pool['sale.order']._check_carrier_quotation(cr, uid, order, force_carrier_id=None, context=context) and quantity or None
|
||||
return quantity
|
||||
Reference in New Issue
Block a user