diff --git a/README.md b/README.md index 45ac7ee4ced..7b3896022f0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ About Odoo ========== -Odoo is suite of open source Business apps. More info at http://www.odoo.com +Odoo is a suite of open source Business apps. More info at http://www.odoo.com Installation ============ diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 59d86351cd6..5ab8d385943 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -40,11 +40,11 @@ Financial and accounting module that covers: Creates a dashboard for accountants that includes: -------------------------------------------------- - * List of Customer Invoice to Approve + * List of Customer Invoices to Approve * Company Analysis * Graph of Treasury -The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal) +Processes like maintaining general ledgers are done through the defined Financial Journals (entry move line or grouping is maintained through a journal) for a particular financial year and for preparation of vouchers there is a module named account_voucher. """, 'website': 'http://www.openerp.com', diff --git a/addons/account/account.py b/addons/account/account.py index aa5d507b3d2..51700d30731 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2055,6 +2055,8 @@ class account_tax(osv.osv): amount = amount2 child_tax = self._unit_compute(cr, uid, tax.child_ids, amount, product, partner, quantity) res.extend(child_tax) + for child in child_tax: + amount2 += child.get('amount', 0.0) if tax.child_depend: for r in res: for name in ('base','ref_base'): diff --git a/addons/account/edi/invoice.py b/addons/account/edi/invoice.py index 2c2a754de3b..c82d041ef85 100644 --- a/addons/account/edi/invoice.py +++ b/addons/account/edi/invoice.py @@ -21,7 +21,7 @@ from openerp.osv import osv, fields from openerp.addons.edi import EDIMixin -from urllib import urlencode +from werkzeug import url_encode INVOICE_LINE_EDI_STRUCT = { 'name': True, @@ -274,7 +274,7 @@ class account_invoice(osv.osv, EDIMixin): "no_note": "1", "bn": "OpenERP_Invoice_PayNow_" + inv.currency_id.name, } - res[inv.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params) + res[inv.id] = "https://www.paypal.com/cgi-bin/webscr?" + url_encode(params) return res _columns = { diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index f6f0c90b1e2..2ad701a9bf5 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -59,9 +59,11 @@ class account_automatic_reconcile(osv.osv_memory): #TODO: cleanup and comment this code... For now, it is awfulllll # (way too complex, and really slow)... def do_reconcile(self, cr, uid, credits, debits, max_amount, power, writeoff_acc_id, period_id, journal_id, context=None): - # for one value of a credit, check all debits, and combination of them - # depending on the power. It starts with a power of one and goes up - # to the max power allowed + """ + for one value of a credit, check all debits, and combination of them + depending on the power. It starts with a power of one and goes up + to the max power allowed. + """ move_line_obj = self.pool.get('account.move.line') if context is None: context = {} @@ -87,11 +89,14 @@ class account_automatic_reconcile(osv.osv_memory): return res return False - # for a list of credit and debit and a given power, check if there - # are matching tuples of credit and debits, check all debits, and combination of them - # depending on the power. It starts with a power of one and goes up - # to the max power allowed + def check4(list1, list2, power): + """ + for a list of credit and debit and a given power, check if there + are matching tuples of credit and debits, check all debits, and combination of them + depending on the power. It starts with a power of one and goes up + to the max power allowed. + """ def check3(value, list1, list2, list1power, power): for i in range(len(list1)): move = list1[i] @@ -120,6 +125,7 @@ class account_automatic_reconcile(osv.osv_memory): res = check4(list1, list2, p) if res: return res + return False ok = True reconciled = 0 diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 6c71f940e8a..8d470f45637 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -62,22 +62,28 @@ class account_analytic_invoice_line(osv.osv): context = context or {} uom_obj = self.pool.get('product.uom') company_id = company_id or False - context.update({'company_id': company_id, 'force_company': company_id, 'pricelist_id': pricelist_id}) + local_context = dict(context, company_id=company_id, force_company=company_id, pricelist=pricelist_id) if not product: return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}} if partner_id: - part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) + part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=local_context) if part.lang: context.update({'lang': part.lang}) result = {} - res = self.pool.get('product.product').browse(cr, uid, product, context=context) - result.update({'name': name or res.description or False,'uom_id': uom_id or res.uom_id.id or False, 'price_unit': price_unit or res.list_price or 0.0}) + res = self.pool.get('product.product').browse(cr, uid, product, context=local_context) + if price_unit is not False: + price = price_unit + elif pricelist_id: + price = res.price + else: + price = res.list_price + result.update({'name': name or res.description or False,'uom_id': uom_id or res.uom_id.id or False, 'price_unit': price}) res_final = {'value':result} if result['uom_id'] != res.uom_id.id: - selected_uom = uom_obj.browse(cr, uid, result['uom_id'], context=context) + selected_uom = uom_obj.browse(cr, uid, result['uom_id'], context=local_context) new_price = uom_obj._compute_price(cr, uid, res.uom_id.id, res_final['value']['price_unit'], result['uom_id']) res_final['value']['price_unit'] = new_price return res_final @@ -746,8 +752,10 @@ class account_analytic_account(osv.osv): new_date = next_date+relativedelta(days=+interval) elif contract.recurring_rule_type == 'weekly': new_date = next_date+relativedelta(weeks=+interval) - else: + elif contract.recurring_rule_type == 'monthly': new_date = next_date+relativedelta(months=+interval) + else: + new_date = next_date+relativedelta(years=+interval) self.write(cr, uid, [contract.id], {'recurring_next_date': new_date.strftime('%Y-%m-%d')}, context=context) if automatic: cr.commit() diff --git a/addons/account_test/i18n/de.po b/addons/account_test/i18n/de.po new file mode 100644 index 00000000000..157223be184 --- /dev/null +++ b/addons/account_test/i18n/de.po @@ -0,0 +1,241 @@ +# German translation for openobject-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2012-12-21 17:05+0000\n" +"PO-Revision-Date: 2014-05-13 09:39+0000\n" +"Last-Translator: Claudia Haida \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-05-14 05:45+0000\n" +"X-Generator: Launchpad (build 17002)\n" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "" +"Code should always set a variable named `result` with the result of your " +"test, that can be a list or\n" +"a dictionary. If `result` is an empty list, it means that the test was " +"succesful. Otherwise it will\n" +"try to translate and print what is inside `result`.\n" +"\n" +"If the result of your test is a dictionary, you can set a variable named " +"`column_order` to choose in\n" +"what order you want to print `result`'s content.\n" +"\n" +"Should you need them, you can also use the following variables into your " +"code:\n" +" * cr: cursor to the database\n" +" * uid: ID of the current user\n" +"\n" +"In any ways, the code must be legal python statements with correct " +"indentation (if needed).\n" +"\n" +"Example: \n" +" sql = '''SELECT id, name, ref, date\n" +" FROM account_move_line \n" +" WHERE account_id IN (SELECT id FROM account_account WHERE type " +"= 'view')\n" +" '''\n" +" cr.execute(sql)\n" +" result = cr.dictfetchall()" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_02 +msgid "Test 2: Opening a fiscal year" +msgstr "Test2: Eröffnung eines Geschäftsjahres" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_05 +msgid "" +"Check that reconciled invoice for Sales/Purchases has reconciled entries for " +"Payable and Receivable Accounts" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_03 +msgid "" +"Check if movement lines are balanced and have the same date and period" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,name:0 +msgid "Test Name" +msgstr "" + +#. module: account_test +#: report:account.test.assert.print:0 +msgid "Accouting tests on" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_01 +msgid "Test 1: General balance" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_06 +msgid "Check that paid/reconciled invoices are not in 'Open' state" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_05_2 +msgid "" +"Check that reconciled account moves, that define Payable and Receivable " +"accounts, are belonging to reconciled invoices" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Tests" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,desc:0 +msgid "Test Description" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Description" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_06_1 +msgid "Check that there's no move for any account with « View » account type" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_08 +msgid "Test 9 : Accounts and partners on account moves" +msgstr "" + +#. module: account_test +#: model:ir.actions.act_window,name:account_test.action_accounting_assert +#: model:ir.actions.report.xml,name:account_test.account_assert_test_report +#: model:ir.ui.menu,name:account_test.menu_action_license +msgid "Accounting Tests" +msgstr "" + +#. module: account_test +#: code:addons/account_test/report/account_test_report.py:74 +#, python-format +msgid "The test was passed successfully" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,active:0 +msgid "Active" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_06 +msgid "Test 6 : Invoices status" +msgstr "" + +#. module: account_test +#: model:ir.model,name:account_test.model_accounting_assert_test +msgid "accounting.assert.test" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_05 +msgid "" +"Test 5.1 : Payable and Receivable accountant lines of reconciled invoices" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,code_exec:0 +msgid "Python code" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_07 +msgid "" +"Check on bank statement that the Closing Balance = Starting Balance + sum of " +"statement lines" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_07 +msgid "Test 8 : Closing balance on bank statements" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_03 +msgid "Test 3: Movement lines" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_05_2 +msgid "Test 5.2 : Reconcilied invoices and Payable/Receivable accounts" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Expression" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_04 +msgid "Test 4: Totally reconciled mouvements" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_04 +msgid "Check if the totally reconciled movements are balanced" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,sequence:0 +msgid "Sequence" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_02 +msgid "" +"Check if the balance of the new opened fiscal year matches with last year's " +"balance" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Python Code" +msgstr "" + +#. module: account_test +#: model:ir.actions.act_window,help:account_test.action_accounting_assert +msgid "" +"

\n" +" Click to create Accounting Test.\n" +"

\n" +" " +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_01 +msgid "Check the balance: Debit sum = Credit sum" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_08 +msgid "Check that general accounts and partners on account moves are active" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_06_1 +msgid "Test 7: « View  » account type" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Code Help" +msgstr "" diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index c1ea1f655d2..61e5c1166ea 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -220,7 +220,7 @@ class account_analytic_account(osv.osv): res['value']['description'] = template.description return res - def on_change_partner_id(self, cr, uid, ids,partner_id, name, context={}): + def on_change_partner_id(self, cr, uid, ids,partner_id, name, context=None): res={} if partner_id: partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) diff --git a/addons/auth_oauth/auth_oauth_data.xml b/addons/auth_oauth/auth_oauth_data.xml index 6abdab41b7c..fe64f42b2f6 100644 --- a/addons/auth_oauth/auth_oauth_data.xml +++ b/addons/auth_oauth/auth_oauth_data.xml @@ -2,13 +2,13 @@ - OpenERP.com Accounts - https://accounts.openerp.com/oauth2/auth + Odoo.com Accounts + https://accounts.odoo.com/oauth2/auth userinfo - https://accounts.openerp.com/oauth2/tokeninfo + https://accounts.odoo.com/oauth2/tokeninfo zocial openerp - Log in with OpenERP.com + Log in with Odoo.com diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 8a66d3ab075..3040fafaf2b 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -42,7 +42,7 @@ class AuthSignupHome(openerp.addons.web.controllers.main.Home): return http.redirect_with_hash(request.params.get('redirect')) return response - @http.route('/web/signup', type='http', auth='public', website=True, multilang=True) + @http.route('/web/signup', type='http', auth='public', website=True) def web_auth_signup(self, *args, **kw): qcontext = self.get_auth_signup_qcontext() @@ -58,7 +58,7 @@ class AuthSignupHome(openerp.addons.web.controllers.main.Home): return request.render('auth_signup.signup', qcontext) - @http.route('/web/reset_password', type='http', auth='public', website=True, multilang=True) + @http.route('/web/reset_password', type='http', auth='public', website=True) def web_auth_reset_password(self, *args, **kw): qcontext = self.get_auth_signup_qcontext() diff --git a/addons/auth_signup/i18n/de.po b/addons/auth_signup/i18n/de.po index 756a19cdf8f..c6e8f777d80 100644 --- a/addons/auth_signup/i18n/de.po +++ b/addons/auth_signup/i18n/de.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2012-12-21 17:05+0000\n" -"PO-Revision-Date: 2012-12-19 14:58+0000\n" -"Last-Translator: Ferdinand \n" +"PO-Revision-Date: 2014-05-14 11:25+0000\n" +"Last-Translator: Claudia Haida \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2014-04-22 07:50+0000\n" -"X-Generator: Launchpad (build 16985)\n" +"X-Launchpad-Export-Date: 2014-05-15 05:51+0000\n" +"X-Generator: Launchpad (build 17007)\n" #. module: auth_signup #: field:res.partner,signup_type:0 diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index c4b584100b6..46e8b024dd6 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -1,23 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (c) 2011-2014 OpenERP S.A. -# -# 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 . -# -############################################################################## import pytz import re @@ -188,7 +169,8 @@ class calendar_attendee(osv.Model): res = cal.serialize() return res - def _send_mail_to_attendees(self, cr, uid, ids, email_from=tools.config.get('email_from', False), template_xmlid='calendar_template_meeting_invitation', context=None): + def _send_mail_to_attendees(self, cr, uid, ids, email_from=tools.config.get('email_from', False), + template_xmlid='calendar_template_meeting_invitation', context=None): """ Send mail for event invitation to event attendees. @param email_from: email address for user sending the mail @@ -273,7 +255,8 @@ class calendar_attendee(osv.Model): meeting_obj = self.pool['calendar.event'] res = self.write(cr, uid, ids, {'state': 'accepted'}, context) for attendee in self.browse(cr, uid, ids, context=context): - meeting_obj.message_post(cr, uid, attendee.event_id.id, body=_(("%s has accepted invitation") % (attendee.cn)), subtype="calendar.subtype_invitation", context=context) + meeting_obj.message_post(cr, uid, attendee.event_id.id, body=_(("%s has accepted invitation") % (attendee.cn)), + subtype="calendar.subtype_invitation", context=context) return res @@ -1410,7 +1393,7 @@ class calendar_event(osv.Model): new_args.append(new_arg) if not context.get('virtual_id', True): - return super(calendar_event, self).search(cr, uid, new_args, offset=offset, limit=limit, order=order, context=context, count=count) + return super(calendar_event, self).search(cr, uid, new_args, offset=offset, limit=limit, order=order, count=count, context=context) # offset, limit, order and count must be treated separately as we may need to deal with virtual ids res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=None, context=context, count=False) @@ -1535,17 +1518,17 @@ class calendar_event(osv.Model): if (values.get('start_date') or values.get('start_datetime', False)) and values.get('active', True): the_id = new_id or (ids and int(ids[0])) + if the_id: + if attendees_create: + attendees_create = attendees_create[the_id] + mail_to_ids = list(set(attendees_create['old_attendee_ids']) - set(attendees_create['removed_attendee_ids'])) + else: + mail_to_ids = [att.id for att in self.browse(cr, uid, the_id, context=context).attendee_ids] - if attendees_create: - attendees_create = attendees_create[the_id] - mail_to_ids = list(set(attendees_create['old_attendee_ids']) - set(attendees_create['removed_attendee_ids'])) - else: - mail_to_ids = [att.id for att in self.browse(cr, uid, the_id, context=context).attendee_ids] - - if mail_to_ids: - current_user = self.pool['res.users'].browse(cr, uid, uid, context=context) - if self.pool['calendar.attendee']._send_mail_to_attendees(cr, uid, mail_to_ids, template_xmlid='calendar_template_meeting_changedate', email_from=current_user.email, context=context): - self.message_post(cr, uid, the_id, body=_("A email has been send to specify that the date has been changed !"), subtype="calendar.subtype_invitation", context=context) + if mail_to_ids: + current_user = self.pool['res.users'].browse(cr, uid, uid, context=context) + if self.pool['calendar.attendee']._send_mail_to_attendees(cr, uid, mail_to_ids, template_xmlid='calendar_template_meeting_changedate', email_from=current_user.email, context=context): + self.message_post(cr, uid, the_id, body=_("A email has been send to specify that the date has been changed !"), subtype="calendar.subtype_invitation", context=context) return res or True and False def create(self, cr, uid, vals, context=None): @@ -1624,7 +1607,7 @@ class calendar_event(osv.Model): continue if r['class'] == 'private': for f in r.keys(): - if f not in ('id', 'allday', 'start', 'stop', 'duration', 'user_id', 'state', 'interval', 'count', 'recurrent_id_date'): + if f not in ('id', 'allday', 'start', 'stop', 'duration', 'user_id', 'state', 'interval', 'count', 'recurrent_id_date', 'rrule'): if isinstance(r[f], list): r[f] = [] else: diff --git a/addons/crm/__init__.py b/addons/crm/__init__.py index e5c06c53d97..872d0390303 100644 --- a/addons/crm/__init__.py +++ b/addons/crm/__init__.py @@ -22,6 +22,7 @@ import crm import crm_segmentation import crm_lead +import sales_team import calendar_event import crm_phonecall import report diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index d53f785d174..15544dc3dff 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -51,13 +51,13 @@ Dashboard for CRM will include: 'depends': [ 'base_action_rule', 'base_setup', + 'sales_team', 'mail', 'email_template', 'calendar', 'resource', 'board', 'fetchmail', - 'web_kanban_sparkline', ], 'data': [ 'crm_data.xml', @@ -91,8 +91,7 @@ Dashboard for CRM will include: 'res_config_view.xml', 'base_partner_merge_view.xml', - 'crm_case_section_view.xml', - 'views/crm.xml', + 'sales_team_view.xml', ], 'demo': [ 'crm_demo.xml', diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 29aa900c16d..b114a6e24fe 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -88,154 +88,6 @@ class crm_case_stage(osv.osv): } -class crm_case_section(osv.osv): - """ Model for sales teams. """ - _name = "crm.case.section" - _inherits = {'mail.alias': 'alias_id'} - _inherit = "mail.thread" - _description = "Sales Teams" - _order = "complete_name" - # number of periods for lead/opportunities/... tracking in salesteam kanban dashboard/kanban view - _period_number = 5 - - 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_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None): - """ Generic method to generate data for bar chart values using SparklineBarWidget. - This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field). - - :param obj: the target model (i.e. crm_lead) - :param domain: the domain applied to the read_group - :param list read_fields: the list of fields to read in the read_group - :param str value_field: the field used to compute the value of the bar slice - :param str groupby_field: the fields used to group - - :return list section_result: a list of dicts: [ - { 'value': (int) bar_column_value, - 'tootip': (str) bar_column_tooltip, - } - ] - """ - month_begin = date.today().replace(day=1) - section_result = [{ - 'value': 0, - 'tooltip': (month_begin + relativedelta.relativedelta(months=-i)).strftime('%B %Y'), - } for i in range(self._period_number - 1, -1, -1)] - group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context) - pattern = tools.DEFAULT_SERVER_DATE_FORMAT if obj.fields_get(cr, uid, groupby_field)[groupby_field]['type'] == 'date' else tools.DEFAULT_SERVER_DATETIME_FORMAT - for group in group_obj: - group_begin_date = datetime.strptime(group['__domain'][0][2], pattern) - month_delta = relativedelta.relativedelta(month_begin, group_begin_date) - section_result[self._period_number - (month_delta.months + 1)] = {'value': group.get(value_field, 0), 'tooltip': group.get(groupby_field, 0)} - return section_result - - def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None): - """ Get opportunities-related data for salesteam kanban view - monthly_open_leads: number of open lead during the last months - monthly_planned_revenue: planned revenu of opportunities during the last months - """ - obj = self.pool.get('crm.lead') - res = dict.fromkeys(ids, False) - month_begin = date.today().replace(day=1) - date_begin = month_begin - relativedelta.relativedelta(months=self._period_number - 1) - date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]) - lead_pre_domain = [('create_date', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)), - ('create_date', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)), - ('type', '=', 'lead')] - opp_pre_domain = [('date_deadline', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)), - ('date_deadline', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)), - ('type', '=', 'opportunity')] - for id in ids: - res[id] = dict() - lead_domain = lead_pre_domain + [('section_id', '=', id)] - opp_domain = opp_pre_domain + [('section_id', '=', id)] - res[id]['monthly_open_leads'] = self.__get_bar_values(cr, uid, obj, lead_domain, ['create_date'], 'create_date_count', 'create_date', context=context) - res[id]['monthly_planned_revenue'] = self.__get_bar_values(cr, uid, obj, opp_domain, ['planned_revenue', 'date_deadline'], 'planned_revenue', 'date_deadline', context=context) - return res - - _columns = { - 'name': fields.char('Sales Team', size=64, required=True, translate=True), - 'complete_name': fields.function(get_full_name, type='char', size=256, readonly=True, store=True), - 'code': fields.char('Code', size=8), - 'active': fields.boolean('Active', help="If the active field is set to "\ - "true, it will allow you to hide the sales team without removing it."), - 'change_responsible': fields.boolean('Reassign Escalated', help="When escalating to this team override the salesman with the team leader."), - 'user_id': fields.many2one('res.users', 'Team Leader'), - 'member_ids': fields.many2many('res.users', 'sale_member_rel', 'section_id', 'member_id', 'Team Members'), - 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by OpenERP about cases in this sales team"), - 'parent_id': fields.many2one('crm.case.section', 'Parent Team'), - 'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Teams'), - 'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"), - 'note': fields.text('Description'), - 'working_hours': fields.float('Working Hours', digits=(16, 2)), - 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'), - 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, - help="The email address associated with this team. New emails received will automatically " - "create new leads assigned to the team."), - 'color': fields.integer('Color Index'), - '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."), - - 'monthly_open_leads': fields.function(_get_opportunities_data, - type="string", readonly=True, multi='_get_opportunities_data', - string='Open Leads per Month'), - 'monthly_planned_revenue': fields.function(_get_opportunities_data, - type="string", readonly=True, multi='_get_opportunities_data', - string='Planned Revenue per Month') - } - - def _get_stage_common(self, cr, uid, context): - ids = self.pool.get('crm.case.stage').search(cr, uid, [('case_default', '=', 1)], context=context) - return ids - - _defaults = { - 'active': 1, - 'stage_ids': _get_stage_common, - 'use_leads': True, - } - - _sql_constraints = [ - ('code_uniq', 'unique (code)', 'The code of the sales team must be unique !') - ] - - _constraints = [ - (osv.osv._check_recursion, 'Error ! You cannot create recursive Sales team.', ['parent_id']) - ] - - def name_get(self, cr, uid, ids, context=None): - """Overrides orm name_get method""" - if not isinstance(ids, list): - ids = [ids] - res = [] - if not ids: - return res - reads = self.read(cr, uid, ids, ['name', 'parent_id'], context) - - for record in reads: - name = record['name'] - if record['parent_id']: - name = record['parent_id'][1] + ' / ' + name - res.append((record['id'], name)) - return res - - def create(self, cr, uid, vals, context=None): - if context is None: - context = {} - create_context = dict(context, alias_model_name='crm.lead', alias_parent_model_name=self._name) - section_id = super(crm_case_section, self).create(cr, uid, vals, context=create_context) - section = self.browse(cr, uid, section_id, context=context) - self.pool.get('mail.alias').write(cr, uid, [section.alias_id.id], {'alias_parent_thread_id': section_id, 'alias_defaults': {'section_id': section_id, 'type': 'lead'}}, context=context) - return section_id - - def unlink(self, cr, uid, ids, context=None): - # Cascade-delete mail aliases as well, as they should not exist without the sales team. - mail_alias = self.pool.get('mail.alias') - alias_ids = [team.alias_id.id for team in self.browse(cr, uid, ids, context=context) if team.alias_id] - res = super(crm_case_section, self).unlink(cr, uid, ids, context=context) - mail_alias.unlink(cr, uid, alias_ids, context=context) - return res - class crm_case_categ(osv.osv): """ Category of Case """ _name = "crm.case.categ" diff --git a/addons/crm/crm_action_rule_demo.xml b/addons/crm/crm_action_rule_demo.xml index 8eac91c06e2..d77211a0f12 100644 --- a/addons/crm/crm_action_rule_demo.xml +++ b/addons/crm/crm_action_rule_demo.xml @@ -41,7 +41,7 @@ True ir.actions.server code - sales_team = self.pool.get('ir.model.data').get_object(cr, uid, 'crm', 'section_sales_department') + sales_team = self.pool.get('ir.model.data').get_object(cr, uid, 'sales_team', 'section_sales_department') object.write({'section_id': sales_team.id}) diff --git a/addons/crm/crm_case_section_view.xml b/addons/crm/crm_case_section_view.xml deleted file mode 100644 index 04ad124f652..00000000000 --- a/addons/crm/crm_case_section_view.xml +++ /dev/null @@ -1,331 +0,0 @@ - - - - - - - - Leads - crm.lead - tree,form - ['|', ('type','=','lead'), ('type','=',False)] - - - { - 'search_default_section_id': [active_id], - 'default_section_id': active_id, - 'default_type': 'lead', - 'stage_type': 'lead', - } - - -

- Use leads if you need a qualification step before creating an - opportunity or a customer. It can be a business card you received, - a contact form filled in your website, or a file of unqualified - prospects you import, etc. -

- Once qualified, the lead can be converted into a business - opportunity and/or a new customer in your address book. -

-
-
- - - - - Opportunities - crm.lead - kanban,tree,graph,form,calendar - [('type','=','opportunity')] - - - { - 'search_default_section_id': [active_id], - 'default_section_id': active_id, - 'stage_type': 'opportunity', - 'default_type': 'opportunity', - 'default_user_id': uid, - } - - -

- OpenERP helps you keep track of your sales pipeline to follow - up potential sales and better forecast your future revenues. -

- You will be able to plan meetings and phone calls from - opportunities, convert them into quotations, attach related - documents, track all discussions, and much more. -

-
-
- - - Leads Analysis - crm.lead.report - {"search_default_month":1} - graph - - [('type','=', 'lead'),('section_id', '=', active_id)] - Leads Analysis allows you to check different CRM related information like the treatment delays or number of leads per state. You can sort out your leads analysis by different groups to get accurate grained analysis. - - - - Opportunities Analysis - crm.lead.report - graph - - [('type','=', 'opportunity'), ('section_id', '=', active_id)] - Opportunities Analysis gives you an instant access to your opportunities with information such as the expected revenue, planned cost, missed deadlines or the number of interactions per opportunity. This report is mainly used by the sales manager in order to do the periodic review with the teams of the sales pipeline. - - - - - - crm.case.section.kanban - crm.case.section - - - - - - - - - - - - - - - - - - - - - - - - Case Sections - Search - crm.case.section - - - - - - - - - - - - - - - - - - - - Sales Teams - crm.case.section - form - kanban,tree,form - {'search_default_personal': True} - - -

- Click here to define a new sales team. -

- Use sales team to organize your different salespersons or - departments into separate teams. Each team will work in - its own list of opportunities. -

-
-
- - - - - crm.case.section.form - crm.case.section - -
- -
-
- - - - - - - - - - - - - - - - - - -
- X -
-
- -
-
-
-
-
-
-
-
- - - - - - - -
-
-
- - -
-
-
-
- - - - - crm.case.section.tree - crm.case.section - child_ids - - - - - - - - - - - - - - kanban - - - - - - - tree - - - - - - - form - - - - - - Cases by Sales Team - crm.case.section - [('parent_id','=',False)] - tree - - - - - Sales Teams - crm.case.section - form - - -

- Click here to define a new sales team. -

- Use sales team to organize your different salespersons or - departments into separate teams. Each team will work in - its own list of opportunities. -

-
-
- - -
-
\ No newline at end of file diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index 231a7124824..a5a732747ab 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -26,34 +26,31 @@ Email - - Direct Sales - DM + True sales - Cash - + Check - + Credit Card - + Demand Draft - + diff --git a/addons/crm/crm_demo.xml b/addons/crm/crm_demo.xml index 82bdcd8fcd9..df776f92350 100644 --- a/addons/crm/crm_demo.xml +++ b/addons/crm/crm_demo.xml @@ -2,26 +2,6 @@ - - - - - - - - - - Indirect Sales - IM - - - - - Marketing - SPD - - - OpenERP partners True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index cfec1a3d931..a209bba4890 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -90,7 +90,10 @@ class crm_lead(format_address, osv.osv): def _get_default_section_id(self, cr, uid, context=None): """ Gives default section by checking if present in the context """ - return self._resolve_section_id_from_context(cr, uid, context=context) or False + section_id = self._resolve_section_id_from_context(cr, uid, context=context) or False + if not section_id: + section_id = self.pool.get('res.users').browse(cr, uid, uid, context).default_section_id.id or False + return section_id def _get_default_stage_id(self, cr, uid, context=None): """ Gives default stage_id """ @@ -167,9 +170,6 @@ class crm_lead(format_address, osv.osv): """ :return dict: difference between current date and log date """ - cal_obj = self.pool.get('resource.calendar') - res_obj = self.pool.get('resource.resource') - res = {} for lead in self.browse(cr, uid, ids, context=context): for field in fields: @@ -181,39 +181,14 @@ class crm_lead(format_address, osv.osv): date_create = datetime.strptime(lead.create_date, "%Y-%m-%d %H:%M:%S") date_open = datetime.strptime(lead.date_open, "%Y-%m-%d %H:%M:%S") ans = date_open - date_create - date_until = lead.date_open elif field == 'day_close': if lead.date_closed: date_create = datetime.strptime(lead.create_date, "%Y-%m-%d %H:%M:%S") date_close = datetime.strptime(lead.date_closed, "%Y-%m-%d %H:%M:%S") - date_until = lead.date_closed ans = date_close - date_create if ans: - resource_id = False - if lead.user_id: - resource_ids = res_obj.search(cr, uid, [('user_id','=',lead.user_id.id)]) - if len(resource_ids): - resource_id = resource_ids[0] - - duration = float(ans.days) - if lead.section_id and lead.section_id.resource_calendar_id: - duration = float(ans.days) * 24 - new_dates = cal_obj.interval_get(cr, - uid, - lead.section_id.resource_calendar_id and lead.section_id.resource_calendar_id.id or False, - datetime.strptime(lead.create_date, '%Y-%m-%d %H:%M:%S'), - duration, - resource=resource_id - ) - no_days = [] - date_until = datetime.strptime(date_until, '%Y-%m-%d %H:%M:%S') - for in_time, out_time in new_dates: - if in_time.date not in no_days: - no_days.append(in_time.date) - if out_time > date_until: - break - duration = len(no_days) - res[lead.id][field] = abs(int(duration)) + duration = abs(int(ans.days)) + res[lead.id][field] = duration return res def _meeting_count(self, cr, uid, ids, field_name, arg, context=None): Event = self.pool['calendar.event'] @@ -258,7 +233,7 @@ class crm_lead(format_address, osv.osv): 'day_open': fields.function(_compute_day, string='Days to Open', \ multi='day_open', type="float", store=True), 'day_close': fields.function(_compute_day, string='Days to Close', \ - multi='day_close', type="float", store=True), + multi='day_open', type="float", store=True), 'date_last_stage_update': fields.datetime('Last Stage Update', select=True), # Messaging and marketing @@ -969,7 +944,7 @@ class crm_lead(format_address, osv.osv): if obj.type == 'opportunity': model, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'crm_case_form_view_oppor') else: - view_id = super(crm_lead, self).get_formview_id(cr, uid, id, model='crm.lead', context=context) + view_id = super(crm_lead, self).get_formview_id(cr, uid, id, context=context) return view_id def message_get_suggested_recipients(self, cr, uid, ids, context=None): diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index fef80bb8a53..9ea859937a2 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -61,7 +61,7 @@ opportunity - + Telesales - + Email Campaign - Services - + Email Campaign - Products - + Twitter Ads - + Google Adwords - + Banner Ads - + Television - + Newsletter - + Product - + Software - + Services - + Information - + Design - + Training - + Consulting - + Other - + diff --git a/addons/crm/crm_lead_demo.xml b/addons/crm/crm_lead_demo.xml index 50a5a369850..8acefd5c610 100644 --- a/addons/crm/crm_lead_demo.xml +++ b/addons/crm/crm_lead_demo.xml @@ -20,7 +20,7 @@ 1 - + Hello, @@ -55,7 +55,7 @@ Could you please send me the details ? 1 - + @@ -84,7 +84,7 @@ Could you please send me the details ? 2 - + @@ -105,7 +105,7 @@ Could you please send me the details ? 2 - + @@ -130,7 +130,7 @@ Could you please send me the details ? 2 - + Hi, @@ -157,7 +157,7 @@ Contact: +1 813 494 5005 2 - + @@ -175,7 +175,7 @@ Contact: +1 813 494 5005 0 - + @@ -194,7 +194,7 @@ Contact: +1 813 494 5005 1 - + @@ -213,7 +213,7 @@ Contact: +1 813 494 5005 2 - + @@ -231,7 +231,7 @@ Contact: +1 813 494 5005 2 - + Hi, @@ -254,7 +254,7 @@ Andrew 2 - + @@ -272,7 +272,7 @@ Andrew 2 - + @@ -310,7 +310,7 @@ Andrew Meeting for pricing information. - + @@ -335,7 +335,7 @@ Andrew Send Catalogue by Email - + @@ -356,7 +356,7 @@ Andrew Call to ask system requirement - + @@ -383,7 +383,7 @@ Andrew Convert to quote - + @@ -408,7 +408,7 @@ Andrew Send price list regarding our interventions - + @@ -435,7 +435,7 @@ Andrew Call to define real needs about training - + @@ -462,7 +462,7 @@ Andrew Ask for the good receprion of the proposition - + @@ -479,7 +479,7 @@ Andrew 2 - + @@ -493,7 +493,7 @@ Andrew 2 - + @@ -511,7 +511,7 @@ Andrew 1 - + @@ -526,7 +526,7 @@ Andrew 0 - + @@ -545,7 +545,7 @@ Andrew 0 - + @@ -568,7 +568,7 @@ Andrew 2 Conf call with technical service - + @@ -592,7 +592,7 @@ Andrew Send Catalogue by Email - + diff --git a/addons/crm/crm_lead_menu.xml b/addons/crm/crm_lead_menu.xml index dffe03dd4b3..60dc307cc0f 100644 --- a/addons/crm/crm_lead_menu.xml +++ b/addons/crm/crm_lead_menu.xml @@ -81,7 +81,7 @@ action="crm_case_category_act_leads_all"/> + groups="base.group_sale_salesman,base.group_sale_manager"/>
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 2441e4197c4..995a1ddea43 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -1,11 +1,9 @@ - - Stage - Search @@ -570,12 +568,12 @@ help="Opportunities that are assigned to me"/> + help="Opportunities that are assigned to any sales teams I am member of" groups="base.group_multi_salesteams"/> - + diff --git a/addons/crm/crm_phonecall_data.xml b/addons/crm/crm_phonecall_data.xml index 0e2bb6511c5..ce82a9a7b51 100644 --- a/addons/crm/crm_phonecall_data.xml +++ b/addons/crm/crm_phonecall_data.xml @@ -6,13 +6,13 @@ --> Inbound - + Outbound - + diff --git a/addons/crm/crm_phonecall_demo.xml b/addons/crm/crm_phonecall_demo.xml index 90cda34cc01..8563a38b075 100644 --- a/addons/crm/crm_phonecall_demo.xml +++ b/addons/crm/crm_phonecall_demo.xml @@ -11,7 +11,7 @@ Left the message done +34 934 340 230 - + @@ -24,7 +24,7 @@ Need more information on the proposed deal done +44 121 690 4596 - + @@ -37,7 +37,7 @@ Ask for convenient time of meeting open +1 786 525 0724 - + @@ -50,7 +50,7 @@ done (077) 582-4035 (077) 341-3591 - + @@ -63,7 +63,7 @@ More information on the proposed deal pending +1 312 349 2324 - + @@ -74,7 +74,7 @@ Proposal for discount offer open +34 230 953 485 - + diff --git a/addons/crm/report/crm_lead_report_view.xml b/addons/crm/report/crm_lead_report_view.xml index 1dda471c2f2..239579a70c2 100644 --- a/addons/crm/report/crm_lead_report_view.xml +++ b/addons/crm/report/crm_lead_report_view.xml @@ -81,7 +81,7 @@ - + diff --git a/addons/crm/report/crm_phonecall_report_view.xml b/addons/crm/report/crm_phonecall_report_view.xml index 32ae9704064..98f4a58d7c4 100644 --- a/addons/crm/report/crm_phonecall_report_view.xml +++ b/addons/crm/report/crm_phonecall_report_view.xml @@ -47,7 +47,7 @@ - + diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py index 1cd31cd0dd0..d48e66e286c 100644 --- a/addons/crm/res_config.py +++ b/addons/crm/res_config.py @@ -27,33 +27,6 @@ class crm_configuration(osv.TransientModel): _name = 'sale.config.settings' _inherit = ['sale.config.settings', 'fetchmail.config.settings'] - def set_group_multi_salesteams(self, cr, uid, ids, context=None): - """ This method is automatically called by res_config as it begins - with set. It is used to implement the 'one group or another' - behavior. We have to perform some group manipulation by hand - because in res_config.execute(), set_* methods are called - after group_*; therefore writing on an hidden res_config file - could not work. - If group_multi_salesteams is checked: remove group_mono_salesteams - from group_user, remove the users. Otherwise, just add - group_mono_salesteams in group_user. - The inverse logic about group_multi_salesteams is managed by the - normal behavior of 'group_multi_salesteams' field. - """ - def ref(xml_id): - mod, xml = xml_id.split('.', 1) - return self.pool['ir.model.data'].get_object(cr, uid, mod, xml, context) - - for obj in self.browse(cr, uid, ids, context=context): - config_group = ref('base.group_mono_salesteams') - base_group = ref('base.group_user') - if obj.group_multi_salesteams: - base_group.write({'implied_ids': [(3, config_group.id)]}) - config_group.write({'users': [(3, u.id) for u in base_group.users]}) - else: - base_group.write({'implied_ids': [(4, config_group.id)]}) - return True - _columns = { 'group_fund_raising': fields.boolean("Manage Fund Raising", implied_group='crm.group_fund_raising', @@ -64,9 +37,6 @@ class crm_configuration(osv.TransientModel): 'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support", help='Allows you to communicate with Customer, process Customer query, and provide better help and support.\n' '-This installs the module crm_helpdesk.'), - 'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams", - implied_group='base.group_multi_salesteams', - help="""Allows you to use Sales Teams to manage your leads and opportunities."""), 'alias_prefix': fields.char('Default Alias Name for Leads'), 'alias_domain' : fields.char('Alias Domain'), 'group_scheduled_calls': fields.boolean("Schedule calls to manage call center", diff --git a/addons/crm/res_config_view.xml b/addons/crm/res_config_view.xml index ce3c8242f99..cc7bb6b2e4a 100644 --- a/addons/crm/res_config_view.xml +++ b/addons/crm/res_config_view.xml @@ -32,17 +32,6 @@ - - - diff --git a/addons/crm/sales_team.py b/addons/crm/sales_team.py new file mode 100644 index 00000000000..8a1e9f938af --- /dev/null +++ b/addons/crm/sales_team.py @@ -0,0 +1,82 @@ +import calendar +from datetime import date +from dateutil import relativedelta + +from openerp import tools +from openerp.osv import fields, osv + + +class crm_case_section(osv.Model): + _inherit = 'crm.case.section' + _inherits = {'mail.alias': 'alias_id'} + + def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None): + """ Get opportunities-related data for salesteam kanban view + monthly_open_leads: number of open lead during the last months + monthly_planned_revenue: planned revenu of opportunities during the last months + """ + obj = self.pool.get('crm.lead') + res = dict.fromkeys(ids, False) + month_begin = date.today().replace(day=1) + date_begin = month_begin - relativedelta.relativedelta(months=self._period_number - 1) + date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]) + lead_pre_domain = [('create_date', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)), + ('create_date', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)), + ('type', '=', 'lead')] + opp_pre_domain = [('date_deadline', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)), + ('date_deadline', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)), + ('type', '=', 'opportunity')] + for id in ids: + res[id] = dict() + lead_domain = lead_pre_domain + [('section_id', '=', id)] + opp_domain = opp_pre_domain + [('section_id', '=', id)] + res[id]['monthly_open_leads'] = self.__get_bar_values(cr, uid, obj, lead_domain, ['create_date'], 'create_date_count', 'create_date', context=context) + res[id]['monthly_planned_revenue'] = self.__get_bar_values(cr, uid, obj, opp_domain, ['planned_revenue', 'date_deadline'], 'planned_revenue', 'date_deadline', context=context) + return res + + _columns = { + 'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"), + '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'), + 'monthly_planned_revenue': fields.function(_get_opportunities_data, + type="string", readonly=True, multi='_get_opportunities_data', + string='Planned Revenue per Month'), + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="The email address associated with this team. New emails received will automatically create new leads assigned to the team."), + } + + def _auto_init(self, cr, context=None): + """Installation hook to create aliases for all lead and avoid constraint errors.""" + return self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(crm_case_section, self)._auto_init, + 'crm.lead', self._columns['alias_id'], 'name', alias_prefix='Lead+', alias_defaults={}, context=context) + + def _get_stage_common(self, cr, uid, context): + ids = self.pool.get('crm.case.stage').search(cr, uid, [('case_default', '=', 1)], context=context) + return ids + + _defaults = { + 'stage_ids': _get_stage_common, + 'use_leads': True, + 'use_opportunities': True, + } + + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + create_context = dict(context, alias_model_name='crm.lead', alias_parent_model_name=self._name) + section_id = super(crm_case_section, self).create(cr, uid, vals, context=create_context) + section = self.browse(cr, uid, section_id, context=context) + self.pool.get('mail.alias').write(cr, uid, [section.alias_id.id], {'alias_parent_thread_id': section_id, 'alias_defaults': {'section_id': section_id, 'type': 'lead'}}, context=context) + return section_id + + def unlink(self, cr, uid, ids, context=None): + # Cascade-delete mail aliases as well, as they should not exist without the sales team. + mail_alias = self.pool.get('mail.alias') + alias_ids = [team.alias_id.id for team in self.browse(cr, uid, ids, context=context) if team.alias_id] + res = super(crm_case_section, self).unlink(cr, uid, ids, context=context) + mail_alias.unlink(cr, uid, alias_ids, context=context) + return res diff --git a/addons/crm/sales_team_view.xml b/addons/crm/sales_team_view.xml new file mode 100644 index 00000000000..7e0eb2e8ad6 --- /dev/null +++ b/addons/crm/sales_team_view.xml @@ -0,0 +1,185 @@ + + + + + + + + Leads + crm.lead + tree,form + ['|', ('type','=','lead'), ('type','=',False)] + + + { + 'search_default_section_id': [active_id], + 'default_section_id': active_id, + 'default_type': 'lead', + 'stage_type': 'lead', + } + + +

+ Use leads if you need a qualification step before creating an + opportunity or a customer. It can be a business card you received, + a contact form filled in your website, or a file of unqualified + prospects you import, etc. +

+ Once qualified, the lead can be converted into a business + opportunity and/or a new customer in your address book. +

+
+
+ + + + + Opportunities + crm.lead + kanban,tree,graph,form,calendar + [('type','=','opportunity')] + + + { + 'search_default_section_id': [active_id], + 'default_section_id': active_id, + 'stage_type': 'opportunity', + 'default_type': 'opportunity', + 'default_user_id': uid, + } + + +

+ OpenERP helps you keep track of your sales pipeline to follow + up potential sales and better forecast your future revenues. +

+ You will be able to plan meetings and phone calls from + opportunities, convert them into quotations, attach related + documents, track all discussions, and much more. +

+
+
+ + + Leads Analysis + crm.lead.report + {"search_default_month":1} + graph + + [('type','=', 'lead'),('section_id', '=', active_id)] + Leads Analysis allows you to check different CRM related information like the treatment delays or number of leads per state. You can sort out your leads analysis by different groups to get accurate grained analysis. + + + + Opportunities Analysis + crm.lead.report + graph + + [('type','=', 'opportunity'), ('section_id', '=', active_id)] + Opportunities Analysis gives you an instant access to your opportunities with information such as the expected revenue, planned cost, missed deadlines or the number of interactions per opportunity. This report is mainly used by the sales manager in order to do the periodic review with the teams of the sales pipeline. + + + + crm.case.section.kanban + crm.case.section + + + + + + + + + + + +
+ %% +
+ +
+
+
+
+ + + crm.case.section.form + crm.case.section + + + + + + + + + + + + + + + + + + + + + kanban + + + + + + + tree + + + + + + + form + + + + + + Cases by Sales Team + crm.case.section + [('parent_id','=',False)] + tree + + +
+
diff --git a/addons/crm/security/crm_security.xml b/addons/crm/security/crm_security.xml index f58be62393f..10477260d27 100644 --- a/addons/crm/security/crm_security.xml +++ b/addons/crm/security/crm_security.xml @@ -24,19 +24,6 @@
- - Do Not Use Sales Teams - - - - - - - - Manage Sales Teams - - - Manage Fund Raising diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv index 73237ecba6a..3c6fc05a70d 100644 --- a/addons/crm/security/ir.model.access.csv +++ b/addons/crm/security/ir.model.access.csv @@ -5,15 +5,12 @@ access_crm_segmentation,crm.segmentation,model_crm_segmentation,base.group_sale_ access_crm_segmentation_line,crm.segmentation.line,model_crm_segmentation_line,base.group_sale_manager,1,1,1,1 access_crm_case_channel_user,crm.case.channel user,model_crm_case_channel,base.group_sale_salesman,1,0,0,0 access_crm_case_channel_manager,crm.case.channel manager,model_crm_case_channel,base.group_sale_manager,1,1,1,1 -access_crm_case_section,crm.case.section,model_crm_case_section,base.group_user,1,0,0,0 access_crm_case_categ,crm.case.categ,model_crm_case_categ,base.group_sale_salesman,1,1,1,0 access_crm_lead_manager,crm.lead.manager,model_crm_lead,base.group_sale_manager,1,1,1,1 access_crm_phonecall_manager,crm.phonecall.manager,model_crm_phonecall,base.group_sale_manager,1,1,1,1 access_crm_case_categ,crm.case.categ,model_crm_case_categ,base.group_user,1,0,0,0 access_crm_lead,crm.lead,model_crm_lead,base.group_sale_salesman,1,1,1,0 access_crm_phonecall,crm.phonecall,model_crm_phonecall,base.group_sale_salesman,1,1,1,0 -access_crm_case_section_user,crm.case.section.user,model_crm_case_section,base.group_sale_salesman,1,0,0,0 -access_crm_case_section_manager,crm.case.section.manager,model_crm_case_section,base.group_sale_manager,1,1,1,1 access_crm_case_stage,crm.case.stage,model_crm_case_stage,,1,0,0,0 access_crm_case_stage_manager,crm.case.stage,model_crm_case_stage,base.group_sale_manager,1,1,1,1 access_crm_case_resource_type_user,crm_case_resource_type user,model_crm_case_resource_type,base.group_sale_salesman,1,1,1,0 diff --git a/addons/crm/static/src/css/Makefile b/addons/crm/static/src/css/Makefile deleted file mode 100644 index a2ced24a13d..00000000000 --- a/addons/crm/static/src/css/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -crm.css: crm.sass - sass --trace -t expanded crm.sass:crm.css diff --git a/addons/crm/test/crm_lead_cancel.yml b/addons/crm/test/crm_lead_cancel.yml index dd475d54919..eca85e4b7a1 100644 --- a/addons/crm/test/crm_lead_cancel.yml +++ b/addons/crm/test/crm_lead_cancel.yml @@ -5,7 +5,7 @@ uid: 'crm_res_users_salesmanager' - !python {model: crm.lead}: | - section_id = self.pool.get('crm.case.section').create(cr, uid, {'name': "Phone Marketing", 'parent_id': ref("crm.crm_case_section_2")}) + section_id = self.pool.get('crm.case.section').create(cr, uid, {'name': "Phone Marketing", 'parent_id': ref("sales_team.crm_case_section_2")}) self.write(cr, uid, [ref("crm_case_1")], {'section_id': section_id}) - Salesman check unqualified lead . diff --git a/addons/crm/test/crm_lead_find_stage.yml b/addons/crm/test/crm_lead_find_stage.yml index b8a11a4af9e..19bed36fc7e 100644 --- a/addons/crm/test/crm_lead_find_stage.yml +++ b/addons/crm/test/crm_lead_find_stage.yml @@ -6,7 +6,7 @@ name: 'Test lead new' partner_id: base.res_partner_1 description: This is the description of the test new lead. - section_id: crm.section_sales_department + section_id: sales_team.section_sales_department - I check default stage of lead. - diff --git a/addons/crm/test/lead2opportunity2win.yml b/addons/crm/test/lead2opportunity2win.yml index 0650838e4cc..1bae79bf983 100644 --- a/addons/crm/test/lead2opportunity2win.yml +++ b/addons/crm/test/lead2opportunity2win.yml @@ -65,7 +65,7 @@ - !python {model: crm.lead2opportunity.partner.mass}: | context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_13"), ref("crm_case_2")], 'active_id': ref("crm_case_13")}) - id = self.create(cr, uid, {'user_ids': [(6, 0, [ref('base.user_root')])], 'section_id': ref('crm.section_sales_department')}, context=context) + id = self.create(cr, uid, {'user_ids': [(6, 0, [ref('base.user_root')])], 'section_id': ref('sales_team.section_sales_department')}, context=context) self.mass_convert(cr, uid, [id], context=context) - Now I check first lead converted on opportunity. diff --git a/addons/crm/test/lead2opportunity_assign_salesmen.yml b/addons/crm/test/lead2opportunity_assign_salesmen.yml index 76b35be531d..9ac3e954f88 100644 --- a/addons/crm/test/lead2opportunity_assign_salesmen.yml +++ b/addons/crm/test/lead2opportunity_assign_salesmen.yml @@ -66,7 +66,7 @@ - !python {model: crm.lead2opportunity.partner.mass}: | context.update({'active_model': 'crm.lead', 'active_ids': [ref("test_crm_lead_01"), ref("test_crm_lead_02"), ref("test_crm_lead_03"), ref("test_crm_lead_04"), ref("test_crm_lead_05"), ref("test_crm_lead_06")], 'active_id': ref("test_crm_lead_01")}) - id = self.create(cr, uid, {'user_ids': [(6, 0, [ref('test_res_user_01'), ref('test_res_user_02'), ref('test_res_user_03'), ref('test_res_user_04')])], 'section_id': ref('crm.section_sales_department'), 'deduplicate': False, 'force_assignation': True}, context=context) + id = self.create(cr, uid, {'user_ids': [(6, 0, [ref('test_res_user_01'), ref('test_res_user_02'), ref('test_res_user_03'), ref('test_res_user_04')])], 'section_id': ref('sales_team.section_sales_department'), 'deduplicate': False, 'force_assignation': True}, context=context) self.mass_convert(cr, uid, [id], context=context) - The leads should now be opps with a salesman and a salesteam. Also, salesmen should have been assigned following a round-robin method. diff --git a/addons/crm/views/crm.xml b/addons/crm/views/crm.xml deleted file mode 100644 index c28ba723d24..00000000000 --- a/addons/crm/views/crm.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 40654f464f4..7964e4a4a3a 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -276,7 +276,7 @@ class crm_lead2opportunity_mass_convert(osv.osv_memory): active_ids = active_ids.difference(merged_lead_ids) active_ids = active_ids.union(remaining_lead_ids) ctx['active_ids'] = list(active_ids) - ctx['no_force_assignation'] = not data.force_assignation + ctx['no_force_assignation'] = context.get('no_force_assignation', not data.force_assignation) return self.action_apply(cr, uid, ids, context=ctx) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/wizard/crm_lead_to_opportunity_view.xml b/addons/crm/wizard/crm_lead_to_opportunity_view.xml index 0f8f676d92d..58bbcf4d934 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity_view.xml +++ b/addons/crm/wizard/crm_lead_to_opportunity_view.xml @@ -12,7 +12,7 @@ - + diff --git a/addons/crm/wizard/crm_merge_opportunities_view.xml b/addons/crm/wizard/crm_merge_opportunities_view.xml index f88a6fe6f17..92007d52e42 100644 --- a/addons/crm/wizard/crm_merge_opportunities_view.xml +++ b/addons/crm/wizard/crm_merge_opportunities_view.xml @@ -10,7 +10,7 @@
- + diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index d897fe2bcb3..fca7ac51178 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -8,19 +8,19 @@ Factual Claims - + Value Claims - + Policy Claims - + @@ -30,12 +30,12 @@ Corrective - + Preventive - + diff --git a/addons/point_of_sale/controllers/main.py b/addons/point_of_sale/controllers/main.py index 3cd10993d07..694f59f386c 100644 --- a/addons/point_of_sale/controllers/main.py +++ b/addons/point_of_sale/controllers/main.py @@ -36,6 +36,7 @@ html_template = """ + + + + + + diff --git a/addons/sales_team/sales_team_data.xml b/addons/sales_team/sales_team_data.xml new file mode 100644 index 00000000000..2f296143ec0 --- /dev/null +++ b/addons/sales_team/sales_team_data.xml @@ -0,0 +1,10 @@ + + + + + Direct Sales + DM + + + + diff --git a/addons/sales_team/sales_team_demo.xml b/addons/sales_team/sales_team_demo.xml new file mode 100644 index 00000000000..0e698d8f1fa --- /dev/null +++ b/addons/sales_team/sales_team_demo.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + Indirect Sales + IM + + + + + Marketing + SPD + + + + \ No newline at end of file diff --git a/addons/sales_team/security/ir.model.access.csv b/addons/sales_team/security/ir.model.access.csv new file mode 100644 index 00000000000..f983a2abb9d --- /dev/null +++ b/addons/sales_team/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_crm_case_section,crm.case.section,model_crm_case_section,base.group_user,1,0,0,0 +access_crm_case_section_user,crm.case.section.user,model_crm_case_section,base.group_sale_salesman,1,0,0,0 +access_crm_case_section_manager,crm.case.section.manager,model_crm_case_section,base.group_sale_manager,1,1,1,1 diff --git a/addons/sales_team/security/sales_team_security.xml b/addons/sales_team/security/sales_team_security.xml new file mode 100644 index 00000000000..d9002f8332f --- /dev/null +++ b/addons/sales_team/security/sales_team_security.xml @@ -0,0 +1,17 @@ + + + + + Do Not Use Sales Teams + + + + + + + + Manage Sales Teams + + + + diff --git a/addons/sales_team/static/src/css/Makefile b/addons/sales_team/static/src/css/Makefile new file mode 100644 index 00000000000..523f4a1e81e --- /dev/null +++ b/addons/sales_team/static/src/css/Makefile @@ -0,0 +1,2 @@ +sales_team.css: sales_team.sass + sass --trace -t expanded sales_team.sass:sales_team.css diff --git a/addons/crm/static/src/css/crm.css b/addons/sales_team/static/src/css/sales_team.css similarity index 100% rename from addons/crm/static/src/css/crm.css rename to addons/sales_team/static/src/css/sales_team.css diff --git a/addons/crm/static/src/css/crm.sass b/addons/sales_team/static/src/css/sales_team.sass similarity index 100% rename from addons/crm/static/src/css/crm.sass rename to addons/sales_team/static/src/css/sales_team.sass diff --git a/addons/crm/static/src/js/crm_case_section.js b/addons/sales_team/static/src/js/sales_team.js similarity index 100% rename from addons/crm/static/src/js/crm_case_section.js rename to addons/sales_team/static/src/js/sales_team.js diff --git a/addons/stock/controllers/main.py b/addons/stock/controllers/main.py index 48742c6c19a..dda444c8627 100644 --- a/addons/stock/controllers/main.py +++ b/addons/stock/controllers/main.py @@ -26,6 +26,7 @@ html_template = """ + @@ -137,6 +136,7 @@ + + diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py index e33905272a3..a36e9fcfafe 100644 --- a/addons/website_blog/controllers/main.py +++ b/addons/website_blog/controllers/main.py @@ -51,7 +51,7 @@ class WebsiteBlog(http.Controller): blog_post_obj = request.registry['blog.post'] groups = blog_post_obj.read_group( request.cr, request.uid, [], ['name', 'create_date'], - groupby="create_date", orderby="create_date asc", context=request.context) + groupby="create_date", orderby="create_date desc", context=request.context) for group in groups: begin_date = datetime.datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATETIME_FORMAT).date() end_date = datetime.datetime.strptime(group['__domain'][1][2], tools.DEFAULT_SERVER_DATETIME_FORMAT).date() @@ -62,7 +62,7 @@ class WebsiteBlog(http.Controller): @http.route([ '/blog', '/blog/page/', - ], type='http', auth="public", website=True, multilang=True) + ], type='http', auth="public", website=True) def blogs(self, page=1, **post): cr, uid, context = request.cr, request.uid, request.context blog_obj = request.registry['blog.post'] @@ -87,7 +87,7 @@ class WebsiteBlog(http.Controller): '/blog//page/', '/blog//tag/', '/blog//tag//page/', - ], type='http', auth="public", website=True, multilang=True) + ], type='http', auth="public", website=True) def blog(self, blog=None, tag=None, page=1, **opt): """ Prepare all values to display the blog. @@ -122,7 +122,7 @@ class WebsiteBlog(http.Controller): blog_url = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end) post_url = QueryURL('', ['blogpost'], tag_id=tag and tag.id or None, date_begin=date_begin, date_end=date_end) - blog_post_ids = blog_post_obj.search(cr, uid, domain, order="create_date asc", context=context) + blog_post_ids = blog_post_obj.search(cr, uid, domain, order="create_date desc", context=context) blog_posts = blog_post_obj.browse(cr, uid, blog_post_ids, context=context) pager = request.website.pager( @@ -156,7 +156,7 @@ class WebsiteBlog(http.Controller): @http.route([ '''/blog//post/

- + &nbsp; @@ -187,6 +187,7 @@

+
diff --git a/addons/website_certification/controllers/main.py b/addons/website_certification/controllers/main.py index ab955bc12dd..303af758a09 100644 --- a/addons/website_certification/controllers/main.py +++ b/addons/website_certification/controllers/main.py @@ -28,7 +28,7 @@ class WebsiteCertifiedPartners(http.Controller): @http.route(['/certifications', '/certifications/'], type='http', auth='public', - website=True, multilang=True) + website=True) def certified_partners(self, cert_type=None, **post): cr, uid, context = request.cr, request.uid, request.context certification_obj = request.registry['certification.certification'] diff --git a/addons/website_crm/controllers/main.py b/addons/website_crm/controllers/main.py index 163e3ee9793..fb4535bf3a6 100644 --- a/addons/website_crm/controllers/main.py +++ b/addons/website_crm/controllers/main.py @@ -16,45 +16,36 @@ class contactus(http.Controller): ) return url - @http.route(['/page/website.contactus'], type='http', auth="public", website=True, multilang=True) + @http.route(['/page/website.contactus', '/page/contactus'], type='http', auth="public", website=True) def contact(self, **kwargs): values = {} for field in ['description', 'partner_name', 'phone', 'contact_name', 'email_from', 'name']: if kwargs.get(field): values[field] = kwargs.pop(field) values.update(kwargs=kwargs.items()) - print values return request.website.render("website.contactus", values) - @http.route(['/crm/contactus'], type='http', auth="public", website=True, multilang=True) + @http.route(['/crm/contactus'], type='http', auth="public", website=True) def contactus(self, description=None, partner_name=None, phone=None, contact_name=None, email_from=None, name=None, **kwargs): - post = {} - post['description'] = description - post['partner_name'] = partner_name - post['phone'] = phone - post['contact_name'] = contact_name - post['email_from'] = email_from - post['name'] = name - - required_fields = ['contact_name', 'email_from', 'description'] - error = set() - values = dict((key, post.get(key)) for key in post) - values['error'] = error + post = { + 'description': description, + 'partner_name': partner_name, + 'phone': phone, + 'contact_name': contact_name, + 'email_from': email_from, + 'name': name or contact_name, + 'user_id': False, + } # fields validation - for field in required_fields: - if not post.get(field): - error.add(field) + error = set(field for field in ['contact_name', 'email_from', 'description'] + if not post.get(field)) + + values = dict(post, error=error) if error: values.update(kwargs=kwargs.items()) return request.website.render("website.contactus", values) - # if not given: subject is contact name - if not post.get('name'): - post['name'] = post.get('contact_name') - - post['user_id'] = False - try: post['channel_id'] = request.registry['ir.model.data'].get_object_reference(request.cr, SUPERUSER_ID, 'crm', 'crm_case_channel_website')[1] except ValueError: @@ -71,6 +62,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_crm_partner_assign/__openerp__.py b/addons/website_crm_partner_assign/__openerp__.py index 82b16173666..06b6dc9410e 100644 --- a/addons/website_crm_partner_assign/__openerp__.py +++ b/addons/website_crm_partner_assign/__openerp__.py @@ -10,6 +10,7 @@ Publish and Assign Partner 'author': 'OpenERP SA', 'depends': ['crm_partner_assign','website_partner', 'website_google_map'], 'data': [ + 'views/partner_grade.xml', 'views/website_crm_partner_assign.xml', ], 'qweb': ['static/src/xml/*.xml'], diff --git a/addons/website_crm_partner_assign/controllers/main.py b/addons/website_crm_partner_assign/controllers/main.py index 4f5639237f4..c23bddc5ea2 100644 --- a/addons/website_crm_partner_assign/controllers/main.py +++ b/addons/website_crm_partner_assign/controllers/main.py @@ -1,121 +1,172 @@ # -*- coding: utf-8 -*- - +import logging +import re import werkzeug -import openerp +_logger = logging.getLogger(__name__) +try: + import GeoIP +except ImportError: + GeoIP = None + _logger.warn("Please install GeoIP python module to use events localisation.") + from openerp import SUPERUSER_ID from openerp.addons.web import http -from openerp.tools.translate import _ from openerp.addons.web.http import request -from openerp.addons.website_partner.controllers import main as website_partner +from openerp.addons.website.models.website import slug +from openerp.tools.translate import _ + class WebsiteCrmPartnerAssign(http.Controller): - _references_per_page = 20 + _references_per_page = 40 + + def _get_current_country_code(self): + if not GeoIP: + return False + GI = GeoIP.open('/usr/share/GeoIP/GeoIP.dat', 0) + return GI.country_code_by_addr(request.httprequest.remote_addr) @http.route([ '/partners', '/partners/page/', - '/partners/grade/', - '/partners/grade//page/', + '/partners/grade/', + '/partners/grade//page/', - '/partners/country/', - '/partners/country/-', - '/partners/country//page/', - '/partners/country/-/page/', - - '/partners/grade//country/', - '/partners/grade//country/-', - '/partners/grade//country//page/', - '/partners/grade//country/-/page/', - - ], type='http', auth="public", website=True, multilang=True) - def partners(self, country_id=0, grade_id=0, page=0, **post): - country_obj = request.registry['res.country'] + '/partners/country/', + '/partners/country//page/', + + '/partners/grade//country/', + '/partners/grade//country//page/', + ], type='http', auth="public", website=True) + def partners(self, country=None, grade=None, page=0, **post): + country_all = post.pop('country_all', False) partner_obj = request.registry['res.partner'] - post_name = post.get('search', '') - country = None + country_obj = request.registry['res.country'] + search = post.get('search', '') - # format displayed membership lines domain - base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)] - partner_domain = list(base_partner_domain) - if post_name: - partner_domain += ['|', ('name', 'ilike', post_name), ('website_description', 'ilike', post_name)] - if grade_id and grade_id != "all": - partner_domain += [('grade_id', '=', int(grade_id))] # try/catch int - - # group by country - countries = partner_obj.read_group( - request.cr, openerp.SUPERUSER_ID, partner_domain, ["id", "country_id"], - groupby="country_id", orderby="country_id", context=request.context) - countries_partners = partner_obj.search( - request.cr, openerp.SUPERUSER_ID, partner_domain, - context=request.context, count=True) - - if country_id: - country = country_obj.browse(request.cr, request.uid, country_id, request.context) - partner_domain += [('country_id', '=', country_id)] - if not any(x['country_id'][0] == country_id for x in countries): - countries.append({ - 'country_id_count': 0, - 'country_id': (country_id, country.name) - }) - countries.sort(key=lambda d: d['country_id'][1]) - - countries.insert(0, { - 'country_id_count': countries_partners, - 'country_id': (0, _("All Countries")) - }) - - - # format pager - partner_ids = partner_obj.search( - request.cr, openerp.SUPERUSER_ID, partner_domain, - context=request.context) - pager = request.website.pager(url="/partners", total=len(partner_ids), page=page, step=self._references_per_page, scope=7, url_args=post) - - # search for partners to display - partners_data = partner_obj.search_read(request.cr, openerp.SUPERUSER_ID, - domain=partner_domain, - fields=request.website.get_partner_white_list_fields(), - offset=pager['offset'], - limit=self._references_per_page, - order="grade_id DESC,partner_weight DESC", - context=request.context) - google_map_partner_ids = ",".join([str(p['id']) for p in partners_data]) + base_partner_domain = [('is_company', '=', True), ('grade_id.website_published', '=', True), ('website_published', '=', True)] + if search: + base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)] # group by grade + grade_domain = list(base_partner_domain) + if not country and not country_all: + country_code = self._get_current_country_code() + if country_code: + country_ids = country_obj.search(request.cr, request.uid, [('code', '=', country_code)], context=request.context) + if country_ids: + country = country_obj.browse(request.cr, request.uid, country_ids[0], context=request.context) + if country: + grade_domain += [('country_id', '=', country.id)] grades = partner_obj.read_group( - request.cr, openerp.SUPERUSER_ID, base_partner_domain, ["id", "grade_id"], - groupby="grade_id", orderby="grade_id", context=request.context) + request.cr, SUPERUSER_ID, grade_domain, ["id", "grade_id"], + groupby="grade_id", orderby="grade_id DESC", context=request.context) grades_partners = partner_obj.search( - request.cr, openerp.SUPERUSER_ID, base_partner_domain, + request.cr, SUPERUSER_ID, grade_domain, context=request.context, count=True) + # flag active grade + for grade_dict in grades: + grade_dict['active'] = grade and grade_dict['grade_id'][0] == grade.id grades.insert(0, { 'grade_id_count': grades_partners, - 'grade_id': (0, _("All Categories")) + 'grade_id': (0, _("All Categories")), + 'active': bool(grade is None), }) + # group by country + country_domain = list(base_partner_domain) + if grade: + country_domain += [('grade_id', '=', grade.id)] + countries = partner_obj.read_group( + request.cr, SUPERUSER_ID, country_domain, ["id", "country_id"], + groupby="country_id", orderby="country_id", context=request.context) + countries_partners = partner_obj.search( + request.cr, SUPERUSER_ID, country_domain, + context=request.context, count=True) + # flag active country + for country_dict in countries: + country_dict['active'] = country and country_dict['country_id'] and country_dict['country_id'][0] == country.id + countries.insert(0, { + 'country_id_count': countries_partners, + 'country_id': (0, _("All Countries")), + 'active': bool(country is None), + }) + + # current search + if grade: + base_partner_domain += [('grade_id', '=', grade.id)] + if country: + base_partner_domain += [('country_id', '=', country.id)] + + # format pager + if grade and not country: + url = '/partners/grade/' + slug(grade) + elif country and not grade: + url = '/partners/country/' + slug(country) + elif country and grade: + url = '/partners/grade/' + slug(grade) + '/country/' + slug(country) + else: + url = '/partners' + url_args = {} + if search: + url_args['search'] = search + partner_count = partner_obj.search_count( + request.cr, SUPERUSER_ID, base_partner_domain, + context=request.context) + pager = request.website.pager( + url=url, total=partner_count, page=page, step=self._references_per_page, scope=7, + url_args=url_args) + + # search partners matching current search parameters + partner_ids = partner_obj.search( + request.cr, SUPERUSER_ID, base_partner_domain, + order="grade_id DESC", + context=request.context) # todo in trunk: order="grade_id DESC, implemented_count DESC", offset=pager['offset'], limit=self._references_per_page + partners = partner_obj.browse(request.cr, SUPERUSER_ID, partner_ids, request.context) + # remove me in trunk + partners.sort(key=lambda x: (-1 * (x.grade_id and x.grade_id.id or 0), len(x.implemented_partner_ids)), reverse=True) + partners = partners[pager['offset']:pager['offset'] + self._references_per_page] + + google_map_partner_ids = ','.join(map(str, [p.id for p in partners])) + values = { 'countries': countries, - 'current_country_id': country_id, 'current_country': country, 'grades': grades, - 'grade_id': grade_id, - 'partners_data': partners_data, + 'current_grade': grade, + 'partners': partners, 'google_map_partner_ids': google_map_partner_ids, 'pager': pager, 'searches': post, - 'search_path': "?%s" % werkzeug.url_encode(post), + 'search_path': "%s" % werkzeug.url_encode(post), } return request.website.render("website_crm_partner_assign.index", values) # Do not use semantic controller due to SUPERUSER_ID - @http.route(['/partners/', '/partners/-'], type='http', auth="public", website=True, multilang=True) - def partners_ref(self, partner_id, **post): - partner = request.registry['res.partner'].browse(request.cr, SUPERUSER_ID, partner_id, context=request.context) - values = website_partner.get_partner_template_value(partner) - if not values: - return self.partners(**post) - values['main_object'] = values['partner'] - return request.website.render("website_crm_partner_assign.partner", values) + @http.route(['/partners/'], type='http', auth="public", website=True) + def partners_detail(self, partner_id, partner_name='', **post): + mo = re.search('-([-0-9]+)$', str(partner_id)) + current_grade, current_country = None, None + grade_id = post.get('grade_id') + country_id = post.get('country_id') + if grade_id: + grade_ids = request.registry['res.partner.grade'].exists(request.cr, request.uid, int(grade_id), context=request.context) + if grade_ids: + current_grade = request.registry['res.partner.grade'].browse(request.cr, request.uid, grade_ids[0], context=request.context) + if country_id: + country_ids = request.registry['res.country'].exists(request.cr, request.uid, int(country_id), context=request.context) + if country_ids: + current_country = request.registry['res.country'].browse(request.cr, request.uid, country_ids[0], context=request.context) + if mo: + partner_id = int(mo.group(1)) + partner = request.registry['res.partner'].browse(request.cr, SUPERUSER_ID, partner_id, context=request.context) + if partner.exists() and partner.website_published: + values = { + 'main_object': partner, + 'partner': partner, + 'current_grade': current_grade, + 'current_country': current_country + } + return request.website.render("website_crm_partner_assign.partner", values) + return self.partners(**post) diff --git a/addons/website_crm_partner_assign/models/__init__.py b/addons/website_crm_partner_assign/models/__init__.py index 20036e92f6c..4e5bc1614d1 100644 --- a/addons/website_crm_partner_assign/models/__init__.py +++ b/addons/website_crm_partner_assign/models/__init__.py @@ -1,2 +1 @@ import res_partner -import website diff --git a/addons/website_crm_partner_assign/models/res_partner.py b/addons/website_crm_partner_assign/models/res_partner.py index e295c7ab0b1..cc00f8bd6e1 100644 --- a/addons/website_crm_partner_assign/models/res_partner.py +++ b/addons/website_crm_partner_assign/models/res_partner.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- - from openerp.osv import osv, fields class res_partner_grade(osv.osv): _inherit = 'res.partner.grade' _columns = { - 'website_description': fields.html('Description for the website'), + 'website_published': fields.boolean('Published On Website'), } diff --git a/addons/website_crm_partner_assign/models/website.py b/addons/website_crm_partner_assign/models/website.py deleted file mode 100644 index f0d428ae5fa..00000000000 --- a/addons/website_crm_partner_assign/models/website.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -from openerp.osv import orm - - -class Website(orm.Model): - _inherit = 'website' - - def get_partner_white_list_fields(self, cr, uid, ids, context=None): - fields = super(Website, self).get_partner_white_list_fields(cr, uid, ids, context=context) - fields += ["grade_id"] - return fields diff --git a/addons/website_crm_partner_assign/views/partner_grade.xml b/addons/website_crm_partner_assign/views/partner_grade.xml new file mode 100644 index 00000000000..2acf8e1eb24 --- /dev/null +++ b/addons/website_crm_partner_assign/views/partner_grade.xml @@ -0,0 +1,18 @@ + + + + + + res.partner.grade.website + res.partner.grade + + + + + + + + + + + diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml index 56ac22d1eee..6d5b93793ad 100644 --- a/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml +++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml @@ -15,7 +15,7 @@ Resellers
-
+
@@ -36,13 +36,13 @@
-
+
-
-
+