diff --git a/addons/crm/sales_team.py b/addons/crm/sales_team.py
index aeaf2cd8ec6..8a1e9f938af 100644
--- a/addons/crm/sales_team.py
+++ b/addons/crm/sales_team.py
@@ -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):
diff --git a/addons/crm/sales_team_view.xml b/addons/crm/sales_team_view.xml
index 0a1b1933385..7e0eb2e8ad6 100644
--- a/addons/crm/sales_team_view.xml
+++ b/addons/crm/sales_team_view.xml
@@ -88,6 +88,7 @@
+
@@ -103,7 +104,7 @@
options="{'height': '20px', 'barWidth': 4, 'barSpacing': 1, 'delayIn': '3000', 'tooltip_suffix': ' Leads'}">Open Leads per Month Click to see a detailed analysis of leads.
-
+
Opportunities
crm.case.section
-
-
+
+
+
diff --git a/addons/sale/sales_team.py b/addons/sale/sales_team.py
index 10acac1dddc..ba9f3e3f5e1 100644
--- a/addons/sale/sales_team.py
+++ b/addons/sale/sales_team.py
@@ -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)
diff --git a/addons/sale/sales_team_view.xml b/addons/sale/sales_team_view.xml
index c577a67713f..922caa9f033 100644
--- a/addons/sale/sales_team_view.xml
+++ b/addons/sale/sales_team_view.xml
@@ -7,6 +7,9 @@
+
+
+
@@ -22,6 +25,7 @@
+
@@ -30,7 +34,7 @@
-
+
Quotations
diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py
index 92c0abf2df0..da6fde90300 100644
--- a/addons/sale_crm/sale_crm.py
+++ b/addons/sale_crm/sale_crm.py
@@ -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:
diff --git a/addons/sales_team/sales_team.xml b/addons/sales_team/sales_team.xml
index 67907c38c7e..5ac8e24d8bb 100644
--- a/addons/sales_team/sales_team.xml
+++ b/addons/sales_team/sales_team.xml
@@ -123,6 +123,7 @@
+
diff --git a/addons/website_crm/controllers/main.py b/addons/website_crm/controllers/main.py
index 163e3ee9793..59949b984c3 100644
--- a/addons/website_crm/controllers/main.py
+++ b/addons/website_crm/controllers/main.py
@@ -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():
diff --git a/addons/website_crm/data/website_crm_data.xml b/addons/website_crm/data/website_crm_data.xml
index 80c8530935d..ba131d22f34 100644
--- a/addons/website_crm/data/website_crm_data.xml
+++ b/addons/website_crm/data/website_crm_data.xml
@@ -12,11 +12,12 @@
open
-
- Website
- Website
- True
+
+ Website Sales
+ WS
+ True
+
diff --git a/addons/website_sale/__openerp__.py b/addons/website_sale/__openerp__.py
index 28c65b80519..68556cd8081 100644
--- a/addons/website_sale/__openerp__.py
+++ b/addons/website_sale/__openerp__.py
@@ -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',
],
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index c31cd970344..7bc2eb13712 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -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':
diff --git a/addons/website_sale/data/data.xml b/addons/website_sale/data/data.xml
index fa1f9b88800..5d0f33bd3a2 100644
--- a/addons/website_sale/data/data.xml
+++ b/addons/website_sale/data/data.xml
@@ -32,5 +32,12 @@
oe_image_full
+
+ Website Sales
+ WS
+
+
+
+
diff --git a/addons/website_sale/data/demo.xml b/addons/website_sale/data/demo.xml
index ad3b472c49d..f64b6e905ec 100644
--- a/addons/website_sale/data/demo.xml
+++ b/addons/website_sale/data/demo.xml
@@ -547,5 +547,10 @@ Weight: 1.1 ounces
-0.2000
1
+
+
+
+
+
diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index a83bb26b6c8..56162cb2139 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -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']
diff --git a/addons/website_sale/security/website_sale.xml b/addons/website_sale/security/website_sale.xml
index 5f623a7bec2..90bf72bd21c 100644
--- a/addons/website_sale/security/website_sale.xml
+++ b/addons/website_sale/security/website_sale.xml
@@ -23,5 +23,10 @@
+
+
+
+
+
diff --git a/addons/website_sale/views/sale_order.xml b/addons/website_sale/views/sale_order.xml
new file mode 100644
index 00000000000..ad90e1e7c43
--- /dev/null
+++ b/addons/website_sale/views/sale_order.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ sale.order.form.acquirer
+ sale.order
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/website_sale_crm/__init__.py b/addons/website_sale_crm/__init__.py
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/addons/website_sale_crm/__openerp__.py b/addons/website_sale_crm/__openerp__.py
deleted file mode 100644
index e7e6393ab73..00000000000
--- a/addons/website_sale_crm/__openerp__.py
+++ /dev/null
@@ -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:
diff --git a/addons/website_sale_crm/data/website_sale_crm.xml b/addons/website_sale_crm/data/website_sale_crm.xml
deleted file mode 100644
index 716bce75766..00000000000
--- a/addons/website_sale_crm/data/website_sale_crm.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
- Website
- Website
-
-
-
-
-
diff --git a/addons/website_sale_crm/models/__init__.py b/addons/website_sale_crm/models/__init__.py
deleted file mode 100644
index b8b239729b6..00000000000
--- a/addons/website_sale_crm/models/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-import website
\ No newline at end of file
diff --git a/addons/website_sale_crm/models/website.py b/addons/website_sale_crm/models/website.py
deleted file mode 100644
index 50cb70d7009..00000000000
--- a/addons/website_sale_crm/models/website.py
+++ /dev/null
@@ -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
diff --git a/addons/website_sale_delivery/models/__init__.py b/addons/website_sale_delivery/models/__init__.py
index d37550d1cbb..553da9fc56b 100644
--- a/addons/website_sale_delivery/models/__init__.py
+++ b/addons/website_sale_delivery/models/__init__.py
@@ -1,2 +1 @@
import sale_order
-import website
diff --git a/addons/website_sale_delivery/models/website.py b/addons/website_sale_delivery/models/website.py
deleted file mode 100644
index 0de2506d3dc..00000000000
--- a/addons/website_sale_delivery/models/website.py
+++ /dev/null
@@ -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