[MERGE]: Merge with lp:~openerp-dev/openobject-addons/atp-dev-addons2

bzr revid: rpa@tinyerp.com-20100428052027-0rug5wesyi8buy9r
This commit is contained in:
rpa (Open ERP)
2010-04-28 10:50:27 +05:30
38 changed files with 508 additions and 320 deletions
-2
View File
@@ -24,8 +24,6 @@ import crm_mailgate
import crm_action_rule
import crm_segmentation
import crm_meeting
import crm_opportunity
import crm_lead
import crm_phonecall
import crm_fundraising
import crm_helpdesk
-8
View File
@@ -70,16 +70,8 @@ between mails and Open ERP.""",
'process/crm_configuration_process.xml',
],
'demo_xml': [
'test/test_crm_meeting.yml',
'crm_demo.xml',
],
'test': ['test/test_crm_lead.yml',
'test/test_crm_opportunity.yml',
'test/test_crm_phonecall.yml',
'test/test_crm_fund.yml',
'test/test_crm_claim.yml',
'test/test_crm_helpdesk.yml',
],
'installable': True,
'active': False,
'certificate': '0079056041421',
-1
View File
@@ -30,4 +30,3 @@
"access_crm_opportunity2phonecall","crm.opportunity2phonecall","model_crm_opportunity2phonecall","crm.group_crm_user",1,1,1,1
"access_crm_send_mail","crm.send.mail","model_crm_send_mail","crm.group_crm_user",1,1,1,1
"access_crm_partner2opportunity","crm.partner2opportunity","model_crm_partner2opportunity","crm.group_crm_user",1,1,1,1
"access_crm_lead2opportunity_partner","crm.lead2opportunity.partner","model_crm_lead2opportunity_partner","crm.group_crm_user",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
30 access_crm_opportunity2phonecall crm.opportunity2phonecall model_crm_opportunity2phonecall crm.group_crm_user 1 1 1 1
31 access_crm_send_mail crm.send.mail model_crm_send_mail crm.group_crm_user 1 1 1 1
32 access_crm_partner2opportunity crm.partner2opportunity model_crm_partner2opportunity crm.group_crm_user 1 1 1 1
access_crm_lead2opportunity_partner crm.lead2opportunity.partner model_crm_lead2opportunity_partner crm.group_crm_user 1 1 1 1
+1
View File
@@ -25,6 +25,7 @@ import crm_email_add_cc
import crm_lead_to_partner
import crm_lead_to_opportunity
import crm_opportunity_to_phonecall
import crm_partner_to_opportunity
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+28
View File
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import crm_lead
import crm_opportunity
import wizard
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+56
View File
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Customer & Supplier Relationship Management',
'version': '1.0',
'category': 'Generic Modules/CRM & SRM',
'description': """Lead and business Opportunity """,
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['crm'],
'init_xml': [
'crm_lead_data.xml',
'crm_opportunity_data.xml',
],
'update_xml': [
'wizard/crm_lead_to_partner_view.xml',
'wizard/crm_lead_to_opportunity_view.xml',
'wizard/crm_opportunity_to_phonecall_view.xml',
'crm_lead_view.xml',
'crm_lead_menu.xml',
'crm_opportunity_view.xml',
'crm_opportunity_menu.xml',
],
'demo_xml': [
'crm_lead_demo.xml',
'crm_opportunity_demo.xml',
],
'test': ['test/test_crm_lead.yml',
#'test/test_crm_opportunity.yml',
],
'installable': True,
'active': False,
'certificate': '0079056041421',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -27,6 +27,15 @@ import time
import mx.DateTime
from tools.translate import _
AVAILABLE_PRIORITIES = [
('5', 'Lowest'),
('4', 'Low'),
('3', 'Normal'),
('2', 'High'),
('1', 'Highest')
]
class crm_lead(osv.osv):
""" CRM Lead Case """
@@ -115,7 +124,11 @@ class crm_lead(osv.osv):
('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Contact Name", size=64),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'priority': fields.selection([('5', 'Lowest'),
('4', 'Low'),
('3', 'Normal'),
('2', 'High'),
('1', 'Highest')], 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', \
domain="[('section_id','=',section_id),\
@@ -134,10 +147,9 @@ class crm_lead(osv.osv):
_defaults = {
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
# 'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
def convert_opportunity(self, cr, uid, ids, context=None):
""" Precomputation for converting lead to opportunity
@param cr: the current row, from the database cursor,
@@ -151,7 +163,7 @@ class crm_lead(osv.osv):
context.update({'active_ids': ids})
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
data_id = data_obj._get_id(cr, uid, 'crm_sale', 'view_crm_lead2opportunity_create')
value = {}
view_id = False
@@ -161,7 +173,7 @@ class crm_lead(osv.osv):
context.update({'opportunity_id': case.id})
context.update({'active_id': case.id})
if not case.partner_id:
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_partner')
data_id = data_obj._get_id(cr, uid, 'crm_sale', 'view_crm_lead2opportunity_partner')
view_id1 = False
if data_id:
view_id1 = data_obj.browse(cr, uid, data_id, context=context).res_id
@@ -6,74 +6,74 @@
<!-- CASE STATUS(stage_id) -->
<record model="crm.case.stage" id="stage_lead1">
<field name="name">New</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead2">
<field name="name">Assigned</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead3">
<field name="name">In Process</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead4">
<field name="name">Converted</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead5">
<field name="name">Recycled</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_lead6">
<field name="name">Dead</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<!-- CASE CATEGORY2(category2_id) -->
<record model="crm.case.resource.type" id="type_lead1">
<field name="name">Telesales</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead2">
<field name="name">Mail</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead3">
<field name="name">Email</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead4">
<field name="name">Print</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead5">
<field name="name">Web</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead6">
<field name="name">Radio</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead7">
<field name="name">Television</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_lead8">
<field name="name">Newsletter</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
</record>
@@ -7,7 +7,7 @@
<!--For Leads-->
<record id="crm_case_itisatelesalescampaign0" model="crm.lead">
<field name="type_id" ref="crm.type_lead1"/>
<field name="type_id" ref="crm_sale.type_lead1"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Luc Latour'" name="name"/>
@@ -15,13 +15,13 @@
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(726) 782-0636'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor6"/>
<field name="stage_id" ref="crm.stage_lead1"/>
<field name="categ_id" ref="crm_sale.categ_oppor6"/>
<field name="stage_id" ref="crm_sale.stage_lead1"/>
<field eval="'The Oil Company'" name="partner_name"/>
<field eval="'(769) 703-274'" name="phone"/>
</record>
<record id="crm_case_electonicgoodsdealer0" model="crm.lead">
<field name="type_id" ref="crm.type_lead7"/>
<field name="type_id" ref="crm_sale.type_lead7"/>
<field eval="'4'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Marc Dufour'" name="name"/>
@@ -29,13 +29,13 @@
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(392) 895-7917'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor2"/>
<field name="stage_id" ref="crm.stage_lead2"/>
<field name="categ_id" ref="crm_sale.categ_oppor2"/>
<field name="stage_id" ref="crm_sale.stage_lead2"/>
<field eval="'Le Club SARL'" name="partner_name"/>
<field eval="'(956) 293-2595'" name="phone"/>
</record>
<record id="crm_case_developingwebapplications0" model="crm.lead">
<field name="type_id" ref="crm.type_lead5"/>
<field name="type_id" ref="crm_sale.type_lead5"/>
<field eval="'2'" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="'Fabien Pinckaers'" name="name"/>
@@ -43,14 +43,14 @@
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(820) 167-3208'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor4"/>
<field name="stage_id" ref="crm.stage_lead4"/>
<field name="categ_id" ref="crm_sale.categ_oppor4"/>
<field name="stage_id" ref="crm_sale.stage_lead4"/>
<field eval="'TheKompany'" name="partner_name"/>
<field eval="'(079) 681-2139'" name="phone"/>
<field eval="'contact@tecsas.fr'" name="email_from"/>
</record>
<record id="crm_case_qrecorp0" model="crm.lead">
<field name="type_id" ref="crm.type_lead8"/>
<field name="type_id" ref="crm_sale.type_lead8"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Henry Mc Coy'" name="name"/>
@@ -58,13 +58,13 @@
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(077) 582-4035'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor1"/>
<field name="stage_id" ref="crm.stage_lead1"/>
<field name="categ_id" ref="crm_sale.categ_oppor1"/>
<field name="stage_id" ref="crm_sale.stage_lead1"/>
<field eval="'The Gas Company'" name="partner_name"/>
<field eval="'(514) 698-4118'" name="phone"/>
</record>
<record id="crm_case_itdeveloper0" model="crm.lead">
<field name="type_id" ref="crm.type_lead4"/>
<field name="type_id" ref="crm_sale.type_lead4"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Carrie Helle'" name="name"/>
@@ -72,15 +72,15 @@
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(333) 715-1450'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor6"/>
<field name="stage_id" ref="crm.stage_lead3"/>
<field name="categ_id" ref="crm_sale.categ_oppor6"/>
<field name="stage_id" ref="crm_sale.stage_lead3"/>
<field eval="'Stonage IT'" name="partner_name"/>
<field eval="'(855) 924-4364'" name="phone"/>
</record>
<record id="crm_case_mgroperations0" model="crm.lead">
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_lead3"/>
<field name="type_id" ref="crm_sale.type_lead3"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
@@ -88,23 +88,23 @@
<field eval="'cancel'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(468) 017-2684'" name="mobile"/>
<field name="categ_id" ref="crm.categ_oppor8"/>
<field name="stage_id" ref="crm.stage_lead6"/>
<field name="categ_id" ref="crm_sale.categ_oppor8"/>
<field name="stage_id" ref="crm_sale.stage_lead6"/>
<field eval="'Opensides SPRL'" name="partner_name"/>
<field eval="'(373) 907-1009'" name="phone"/>
<field eval="'info@opensides.be'" name="email_from"/>
</record>
<record id="crm_case_vpoperations0" model="crm.lead">
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_lead8"/>
<field name="type_id" ref="crm_sale.type_lead8"/>
<field eval="'3'" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="'Wendi Baltz'" name="name"/>
<field eval="'done'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(463) 014-1208'" name="mobile"/>
<field name="categ_id" ref="crm.categ_oppor4"/>
<field name="stage_id" ref="crm.stage_lead4"/>
<field name="categ_id" ref="crm_sale.categ_oppor4"/>
<field name="stage_id" ref="crm_sale.stage_lead4"/>
<field eval="'Gardner Group'" name="partner_name"/>
<field eval="'(282) 603-7489'" name="phone"/>
</record>
@@ -7,7 +7,7 @@
<field name="res_model">crm.lead</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="crm_case_tree_view_leads"/>
<field name="search_view_id" ref="crm.view_crm_case_leads_filter"/>
<field name="search_view_id" ref="crm_sale.view_crm_case_leads_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_leads_all">
<field name="sequence" eval="1"/>
@@ -169,7 +169,7 @@
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_send_mail)d"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'reply', 'model': 'crm.lead', 'include_original' : True}"
icon="gtk-undo" type="action" />
</form>
@@ -180,7 +180,7 @@
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.lead'}"
icon="gtk-go-forward" type="action" />
</page>
@@ -19,10 +19,12 @@
#
##############################################################################
from crm.report import crm_report
from datetime import datetime
from osv import fields,osv,orm
from tools.translate import _
import crm
from crm import crm
import time
import mx.DateTime
@@ -119,7 +121,7 @@ class crm_opportunity(osv.osv):
'categ_id': fields.many2one('crm.case.categ', 'Category', \
domain="[('section_id','=',section_id), \
('object_id.model', '=', 'crm.opportunity')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'priority': fields.selection(crm_report.AVAILABLE_PRIORITIES, 'Priority'),
'referred': fields.char('Referred By', size=64),
'probability': fields.float('Probability (%)'),
'planned_revenue': fields.float('Expected Revenue'),
@@ -231,7 +233,7 @@ class crm_opportunity(osv.osv):
}
value = {
'name': _('Meetings'),
'domain': "[('user_id','=',%s),('opportunity_id','=',%s)]" % (uid,opp.id),
'domain': "[('user_id','=',%s)]" % (uid),
'context': context,
'view_type': 'form',
'view_mode': 'calendar,form,tree',
@@ -242,6 +244,7 @@ class crm_opportunity(osv.osv):
'search_view_id': res['res_id'],
'nodestroy': True
}
return value
crm_opportunity()
@@ -3,91 +3,91 @@
<data noupdate="1">
<record model="crm.case.categ" id="categ_oppor1">
<field name="name">Existing Customer</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor2">
<field name="name">Self Generated</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor3">
<field name="name">Employee</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor4">
<field name="name">Partner</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor5">
<field name="name">Campaign</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor6">
<field name="name">Website</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor7">
<field name="name">Word of mouth</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.categ" id="categ_oppor8">
<field name="name">Other</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<!-- CASE STATUS(stage_id) -->
<record model="crm.case.stage" id="stage_oppor1">
<field name="name">Prospecting</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor2">
<field name="name">Needs Analysis</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor3">
<field name="name">Value Proposition</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor4">
<field name="name">Proposal/Price Quote</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor5">
<field name="name">Negotiation/Review</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor6">
<field name="name">Closed Won</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.stage" id="stage_oppor7">
<field name="name">Closed Lost</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<!-- Case Resource(type_id) -->
<record model="crm.case.resource.type" id="type_oppor1">
<field name="name">Existing Business</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
<record model="crm.case.resource.type" id="type_oppor2">
<field name="name">New Business</field>
<field name="section_id" ref="section_sales_department"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="object_id" search="[('model','=','crm.opportunity')]" model="ir.model"/>
</record>
@@ -11,21 +11,21 @@
<field eval="60" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="type_id" ref="crm_sale.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="85000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor1"/>
<field name="stage_id" ref="crm.stage_oppor3"/>
<field name="categ_id" ref="crm_sale.categ_oppor1"/>
<field name="stage_id" ref="crm_sale.stage_oppor3"/>
<field eval="&quot;CONS TRUST (AZ) 529701 - 1000 units&quot;" name="name"/>
</record>
<record id="crm_case_rdroundfundingunits0" model="crm.opportunity">
<field name="partner_address_id" ref="base.res_partner_address_15"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor2"/>
<field name="type_id" ref="crm_sale.type_oppor2"/>
<field name="partner_id" ref="base.res_partner_11"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
@@ -33,15 +33,15 @@
<field eval="45000.0" name="planned_revenue"/>
<field eval="50" name="probability"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor5"/>
<field name="stage_id" ref="crm.stage_oppor1"/>
<field name="categ_id" ref="crm_sale.categ_oppor5"/>
<field name="stage_id" ref="crm_sale.stage_oppor1"/>
<field eval="&quot;3rd Round Funding - 1000 units &quot;" name="name"/>
</record>
<record id="crm_case_mediapoleunits0" model="crm.opportunity">
<field eval="10" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_3"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="type_id" ref="crm_sale.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_8"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
@@ -49,8 +49,8 @@
<field eval="55000.0" name="planned_revenue"/>
<field eval="70" name="probability"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor7"/>
<field name="stage_id" ref="crm.stage_oppor5"/>
<field name="categ_id" ref="crm_sale.categ_oppor7"/>
<field name="stage_id" ref="crm_sale.stage_oppor5"/>
<field eval="&quot;Mediapole - 5000 units&quot;" name="name"/>
<field eval="&quot;info@mediapole.net&quot;" name="email_from"/>
</record>
@@ -58,15 +58,15 @@
<field eval="40" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="1" name="active"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="type_id" ref="crm_sale.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="45000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor5"/>
<field name="stage_id" ref="crm.stage_oppor4"/>
<field name="categ_id" ref="crm_sale.categ_oppor5"/>
<field name="stage_id" ref="crm_sale.stage_oppor4"/>
<field eval="&quot;ABC FUEL CO 829264 - 1000 units &quot;" name="name"/>
<field eval="&quot;info@opensides.be&quot;" name="email_from"/>
</record>
@@ -80,8 +80,8 @@
<field eval="&quot;done&quot;" name="state"/>
<field eval="42000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field name="categ_id" ref="crm.categ_oppor2"/>
<field name="stage_id" ref="crm.stage_oppor6"/>
<field name="categ_id" ref="crm_sale.categ_oppor2"/>
<field name="stage_id" ref="crm_sale.stage_oppor6"/>
<field eval="&quot;Dirt Mining Ltd 271742 - 1000 units&quot;" name="name"/>
</record>
</data>
@@ -18,8 +18,8 @@
res_model="crm.phonecall"
src_model="crm.opportunity"
view_mode="calendar,tree,form"
context="{'default_duration': 1.0 ,'default_opportunity_id': active_id}"
domain="[('user_id','=',uid),('opportunity_id', '=', active_id)]"
context="{'default_duration': 1.0}"
domain="[('user_id','=',uid)]"
view_type="form"/>
<record model="ir.actions.act_window" id="crm_case_category_act_oppor11">
@@ -27,7 +27,7 @@
<field name="res_model">crm.opportunity</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_case_tree_view_oppor"/>
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
<field name="search_view_id" ref="crm_sale.view_crm_case_opportunities_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_oppor11">
<field name="sequence" eval="1"/>
@@ -71,14 +71,14 @@
</group>
<field name="user_id"/>
<button name="action_makeMeeting" type="object"
string="Schedule Meeting" icon="gtk-redo" />
<!-- <button name="action_makeMeeting" type="object"-->
<!-- string="Schedule Meeting" icon="gtk-redo" />-->
<field name="planned_revenue"/>
<field name="probability"/>
<field name="date_deadline" string="Expected Closing"/>
<button string="Schedule Call"
name="%(opportunity2phonecall_act)d" icon="gtk-redo" type="action" />
<!-- <button string="Schedule Call"-->
<!-- name="%(opportunity2phonecall_act)d" icon="gtk-redo" type="action" />-->
<newline/>
<field name="date_action"/>
@@ -180,7 +180,7 @@
<field name="description" colspan="4" nolabel="1"/>
<button colspan="4"
string="Reply to Last Email"
name="%(action_crm_send_mail)d"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'reply', 'model': 'crm.opportunity'}"
icon="gtk-undo" type="action" />
</form>
@@ -191,7 +191,7 @@
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(action_crm_send_mail)d"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.opportunity'}"
icon="gtk-go-forward" type="action" />
</page>
+32
View File
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
#import report_businessopp
#import crm_report
#import crm_claim_report
import crm_lead_report
#import crm_phonecall_report
#import crm_fundraising_report
import crm_opportunity_report
#import crm_helpdesk_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -19,9 +19,11 @@
#
##############################################################################
from crm.report import crm_report
from osv import fields,osv
import tools
AVAILABLE_STATES = [
('draft','Draft'),
('open','Open'),
@@ -0,0 +1,8 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_crm_lead","crm.lead","model_crm_lead","crm.group_crm_manager",1,1,1,1
"access_crm_opportunity","crm.opportunity","model_crm_opportunity","crm.group_crm_manager",1,1,1,1
"access_crm_lead_report_user","crm.lead.report","model_crm_lead_report","crm.group_crm_user",1,0,0,0
"access_crm_opportunity_report_user","crm.opportunity.report","model_crm_opportunity_report","crm.group_crm_user",1,0,0,0
"access_crm_lead2partner","crm.lead2partner","model_crm_lead2partner","crm.group_crm_user",1,1,1,1
"access_crm_lead2opportunity","crm.lead2opportunity","model_crm_lead2opportunity","crm.group_crm_user",1,1,1,1
"access_crm_lead2opportunity_partner","crm.lead2opportunity.partner","model_crm_lead2opportunity_partner","crm.group_crm_user",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_crm_lead crm.lead model_crm_lead crm.group_crm_manager 1 1 1 1
3 access_crm_opportunity crm.opportunity model_crm_opportunity crm.group_crm_manager 1 1 1 1
4 access_crm_lead_report_user crm.lead.report model_crm_lead_report crm.group_crm_user 1 0 0 0
5 access_crm_opportunity_report_user crm.opportunity.report model_crm_opportunity_report crm.group_crm_user 1 0 0 0
6 access_crm_lead2partner crm.lead2partner model_crm_lead2partner crm.group_crm_user 1 1 1 1
7 access_crm_lead2opportunity crm.lead2opportunity model_crm_lead2opportunity crm.group_crm_user 1 1 1 1
8 access_crm_lead2opportunity_partner crm.lead2opportunity.partner model_crm_lead2opportunity_partner crm.group_crm_user 1 1 1 1
+28
View File
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import crm_lead_to_partner
import crm_lead_to_opportunity
import crm_opportunity_to_phonecall
#import crm_phonecall_to_phonecall
#import crm_phonecall_to_partner
#import crm_phonecall_to_opportunity
#import crm_partner_to_opportunity
@@ -62,10 +62,10 @@ class crm_lead2opportunity(osv.osv_memory):
model_obj = self.pool.get('ir.model')
# Get Opportunity views
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter')
result = data_obj._get_id(cr, uid, 'crm_sale', 'view_crm_case_opportunities_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_oppor')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_oppor')
id2 = data_obj._get_id(cr, uid, 'crm_sale', 'crm_case_form_view_oppor')
id3 = data_obj._get_id(cr, uid, 'crm_sale', 'crm_case_tree_view_oppor')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
@@ -182,7 +182,6 @@ Leads Could not convert into Opportunity"))
crm_lead2opportunity()
class crm_lead2opportunity_partner(osv.osv_memory):
_name = 'crm.lead2opportunity.partner'
_description = 'Lead To Opportunity Partner'
@@ -248,7 +247,8 @@ class crm_lead2opportunity_partner(osv.osv_memory):
res = mod_obj.read(cr, uid, result, ['res_id'])
value = {}
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
data_id = data_obj._get_id(cr, uid, 'crm_sale', 'view_crm_lead2opportunity_create')
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
@@ -280,7 +280,7 @@ class crm_lead2opportunity_partner(osv.osv_memory):
"""
value = {}
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
data_id = data_obj._get_id(cr, uid, 'crm_sale', 'view_crm_lead2opportunity_create')
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
@@ -29,10 +29,10 @@ class crm_opportunity2phonecall(osv.osv_memory):
_description = 'Opportunity to Phonecall'
_columns = {
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users', "Assign To"),
'date': fields.datetime('Date' , required=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'name' : fields.char('Call summary', size=64, required=True, select=1),
'user_id' : fields.many2one('res.users', "Assign To"),
'date': fields.datetime('Date' , required=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
def default_get(self, cr, uid, fields, context=None):
@@ -43,9 +43,9 @@ class crm_opportunity2phonecall(osv.osv_memory):
@param uid: the current user’s ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
opp_obj = self.pool.get('crm.opportunity')
record_ids = context and context.get('active_ids', []) or []
res = super(crm_opportunity2phonecall, self).default_get(cr, uid, fields, context=context)
@@ -92,7 +92,7 @@ class crm_opportunity2phonecall(osv.osv_memory):
data_obj = self.pool.get('ir.model.data')
categ_id = mod_obj._get_id(cr, uid, 'crm', 'categ_phone1')
categ_id = data_obj.browse(cr, uid, categ_id, context=context).res_id
# Select the view
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
@@ -104,32 +104,31 @@ class crm_opportunity2phonecall(osv.osv_memory):
for this in self.browse(cr, uid, ids, context=context):
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
new_case = phonecall_obj.create(cr, uid, {
'name' : opp.name,
'case_id' : opp.id ,
'user_id' : this.user_id and this.user_id.id or False,
'categ_id' : categ_id,
'description' : opp.description or False,
'date' : this.date,
'section_id' : opp.section_id and opp.section_id.id or False,
'partner_id': opp.partner_id and opp.partner_id.id or False,
'partner_address_id': opp.partner_address_id and opp.partner_address_id.id or False,
'partner_phone' : opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False),
'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
'priority': opp.priority,
'name' : opp.name,
'case_id' : opp.id ,
'user_id' : this.user_id and this.user_id.id or False,
'categ_id' : categ_id,
'description' : opp.description or False,
'date' : this.date,
'section_id' : opp.section_id and opp.section_id.id or False,
'partner_id': opp.partner_id and opp.partner_id.id or False,
'partner_address_id': opp.partner_address_id and opp.partner_address_id.id or False,
'partner_phone' : opp.phone or (opp.partner_address_id and opp.partner_address_id.phone or False),
'partner_mobile' : opp.partner_address_id and opp.partner_address_id.mobile or False,
'priority': opp.priority,
'opp_id': opp.id
}, context=context)
phonecall_obj.case_open(cr, uid, [new_case])
value = {
'name': _('Phone Call'),
'domain': "[('user_id','=',%s),('opportunity_id','=',%s)]" % (uid,opp.id),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'crm.phonecall',
'res_id' : new_case,
'views': [(id3, 'form'), (id2, 'tree'), (False, 'calendar'), (False, 'graph')],
'type': 'ir.actions.act_window',
'name': _('Phone Call'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'crm.phonecall',
'res_id' : new_case,
'views': [(id3, 'form'), (id2, 'tree'), (False, 'calendar'), (False, 'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
+1 -1
View File
@@ -38,7 +38,7 @@ crm modules.
'website': 'http://www.openerp.com',
'depends': ['sale', 'crm'],
'init_xml': [],
'update_xml': ['sale_crm_wizard.xml',
'update_xml': ['wizard/crm_make_sale_view.xml',
'sale_crm_view.xml',
'process/sale_crm_process.xml',
'security/sale_crm_security.xml',
+1 -1
View File
@@ -9,7 +9,7 @@
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<field name="priority" position="after">
<button string="Convert to Quote" icon="terp-sale" name="%(sale_crm_wizard)d" type="action"/>
<button string="Convert to Quote" icon="terp-sale" name="%(action_crm_make_sale)d" type="action"/>
<label colspan="2" string=""/>
</field>
</field>
-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<wizard
string="Make Quotation"
model="crm.opportunity"
name="crm.opportunity.make_order"
keyword="client_action_multi"
multi="True"
id="sale_crm_wizard"/>
</data>
</openerp>
+1 -1
View File
@@ -19,7 +19,7 @@
#
##############################################################################
import makesale
import crm_make_sale
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+177
View File
@@ -0,0 +1,177 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
from mx.DateTime import now
class crm_make_sale(osv.osv_memory):
""" Make sale order for crm """
_name = "crm.make.sale"
_description = "Make sale"
def _selectPartner(self, cr, uid, context=None):
"""
This function gets default value for partner_id field.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param context: A standard dictionary for contextual values
@return : default value of partner_id field.
"""
if not context:
context = {}
data = context and context.get('active_ids', []) or []
case_obj = self.pool.get('crm.opportunity')
case = case_obj.read(cr, uid, data, ['partner_id'])
return case[0]['partner_id']
def makeOrder(self, cr, uid, ids, context=None):
"""
This function create Quotation on given case.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of crm make sale' ids
@param context: A standard dictionary for contextual values
@return : Dictionary value of created sale order.
"""
if not context:
context = {}
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'sale', 'view_sales_order_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
case_obj = self.pool.get('crm.opportunity')
sale_obj = self.pool.get('sale.order')
partner_obj = self.pool.get('res.partner')
sale_line_obj = self.pool.get('sale.order.line')
data = context and context.get('active_ids', []) or []
for make in self.browse(cr, uid, ids):
default_partner_addr = partner_obj.address_get(cr, uid, [make.partner_id.id],
['invoice', 'delivery', 'contact'])
default_pricelist = partner_obj.browse(cr, uid, make.partner_id.id,
context).property_product_pricelist.id
fpos_data = partner_obj.browse(cr, uid, make.partner_id.id, context).property_account_position
new_ids = []
for case in case_obj.browse(cr, uid, data):
if case.partner_id and case.partner_id.id:
partner_id = case.partner_id.id
fpos = case.partner_id.property_account_position and case.partner_id.property_account_position.id or False
partner_addr = partner_obj.address_get(cr, uid, [case.partner_id.id],
['invoice', 'delivery', 'contact'])
pricelist = partner_obj.browse(cr, uid, case.partner_id.id,
context).property_product_pricelist.id
else:
partner_id = make.partner_id.id
fpos = fpos_data and fpos_data.id or False
partner_addr = default_partner_addr
pricelist = default_pricelist
if False in partner_addr.values():
raise osv.except_osv(_('Data Insufficient!'),_('Customer has no addresses defined!'))
vals = {
'origin': 'CRM-Opportunity:%s' % str(case.id),
'section_id': case.section_id and case.section_id.id or False,
'picking_policy': make.picking_policy,
'shop_id': make.shop_id.id,
'partner_id': partner_id,
'pricelist_id': pricelist,
'partner_invoice_id': partner_addr['invoice'],
'partner_order_id': partner_addr['contact'],
'partner_shipping_id': partner_addr['delivery'],
'order_policy': 'manual',
'date_order': now(),
'fiscal_position': fpos,
}
if partner_id:
partner = partner_obj.browse(cr, uid, partner_id, context=context)
vals['user_id'] = partner.user_id and partner.user_id.id or uid
if make.analytic_account.id:
vals['project_id'] = make.analytic_account.id
new_id = sale_obj.create(cr, uid, vals)
for product_id in make.product_ids:
value = sale_line_obj.product_id_change(cr, uid, [], pricelist,
product_id.id, qty=1, partner_id=partner_id, fiscal_position=fpos)['value']
value['product_id'] = product_id.id
value['order_id'] = new_id
value['tax_id'] = [(6,0,value['tax_id'])]
sale_line_obj.create(cr, uid, value)
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id})
new_ids.append(new_id)
if make.close:
case_obj.case_close(cr, uid, data)
if not new_ids:
return {}
if len(new_ids)<=1:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': new_ids and new_ids[0]
}
else:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id':new_ids
}
return value
_columns = {
'shop_id': fields.many2one('sale.shop', 'Shop', required = True),
'partner_id': fields.many2one('res.partner', 'Customer', required = True, help = 'Use this partner if there is no partner on the case'),
'picking_policy': fields.selection([('direct','Direct Delivery'),
('one','All at once')], 'Picking Policy', required = True),
'product_ids': fields.many2many('product.product', 'product_sale_rel',\
'sale_id', 'product_id', 'Products'),
'analytic_account': fields.many2one('account.analytic.account', 'Analytic Account'),
'close': fields.boolean('Close Case', help = 'Check this to close the case after having created the sale order.'),
}
_defaults = {
'partner_id': _selectPartner,
'close': lambda *a: 1
}
crm_make_sale()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,41 @@
<openerp>
<data>
<!-- crm make sale's view -->
<record id="view_crm_make_sale" model="ir.ui.view">
<field name="name">crm.make.sale.form</field>
<field name="model">crm.make.sale</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Convert to Quote">
<field name="partner_id"/>
<field name="shop_id"/>
<field name="analytic_account"/>
<field name="picking_policy"/>
<field name="close"/>
<newline/>
<field name="product_ids" colspan="4"/>
<separator colspan="4"/>
<group col="4" colspan="4">
<label string="" colspan="2"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="makeOrder" string="Create Quote" type="object" icon='gtk-go-forward'/>
</group>
</form>
</field>
</record>
<!-- crm make sale's action -->
<record id="action_crm_make_sale" model="ir.actions.act_window">
<field name="name">Make Quotation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.make.sale</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
-174
View File
@@ -1,174 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
from tools.translate import _
sale_form = """<?xml version="1.0"?>
<form string="Convert to Quote">
<field name="partner_id" required="True"/>
<field name="shop_id" required="True"/>
<field name="analytic_account"/>
<field name="picking_policy" required="True"/>
<field name="close"/>
<newline/>
<field name="products" colspan="4"/>
</form>"""
sale_fields = {
'shop_id': {'string': 'Shop', 'type': 'many2one', 'relation': 'sale.shop'},
'partner_id': {'string': 'Customer', 'type': 'many2one',
'relation': 'res.partner',
'help': 'Use this partner if there is no partner on the case'},
'picking_policy': {'string': 'Picking Policy', 'type': 'selection',
'selection': [('direct','Direct Delivery'),('one','All at once')]},
'products': {'string': 'Products', 'type': 'many2many',
'relation': 'product.product'},
'analytic_account': {'string': 'Analytic Account', 'type': 'many2one',
'relation': 'account.analytic.account'},
'close': {'string': 'Close Case', 'type': 'boolean', 'default': lambda *a: 1,
'help': 'Check this to close the case after having created the sale order.'},
}
class make_sale(wizard.interface):
def _selectPartner(self, cr, uid, data, context):
case_obj = pooler.get_pool(cr.dbname).get('crm.opportunity')
case = case_obj.read(cr, uid, data['ids'], ['partner_id'])
return {'partner_id': case[0]['partner_id']}
def _makeOrder(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'sale', 'view_sales_order_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
case_obj = pool.get('crm.opportunity')
sale_obj = pool.get('sale.order')
partner_obj = pool.get('res.partner')
sale_line_obj = pool.get('sale.order.line')
default_partner_addr = partner_obj.address_get(cr, uid, [data['form']['partner_id']],
['invoice', 'delivery', 'contact'])
default_pricelist = partner_obj.browse(cr, uid, data['form']['partner_id'],
context).property_product_pricelist.id
fpos_data = partner_obj.browse(cr, uid, data['form']['partner_id'],context).property_account_position
new_ids = []
for case in case_obj.browse(cr, uid, data['ids']):
if case.partner_id and case.partner_id.id:
partner_id = case.partner_id.id
fpos = case.partner_id.property_account_position and case.partner_id.property_account_position.id or False
partner_addr = partner_obj.address_get(cr, uid, [case.partner_id.id],
['invoice', 'delivery', 'contact'])
pricelist = partner_obj.browse(cr, uid, case.partner_id.id,
context).property_product_pricelist.id
else:
partner_id = data['form']['partner_id']
fpos = fpos_data and fpos_data.id or False
partner_addr = default_partner_addr
pricelist = default_pricelist
if False in partner_addr.values():
raise wizard.except_wizard(_('Data Insufficient!'),_('Customer has no addresses defined!'))
vals = {
'origin': 'CRM-Opportunity:%s' % str(case.id),
'section_id': case.section_id and case.section_id.id or False,
'picking_policy': data['form']['picking_policy'],
'shop_id': data['form']['shop_id'],
'partner_id': partner_id,
'pricelist_id': pricelist,
'partner_invoice_id': partner_addr['invoice'],
'partner_order_id': partner_addr['contact'],
'partner_shipping_id': partner_addr['delivery'],
'order_policy': 'manual',
'date_order': now(),
'fiscal_position': fpos,
}
if partner_id:
partner = partner_obj.browse(cr, uid, partner_id, context=context)
vals['user_id'] = partner.user_id and partner.user_id.id or uid
if data['form']['analytic_account']:
vals['project_id'] = data['form']['analytic_account']
new_id = sale_obj.create(cr, uid, vals)
for product_id in data['form']['products'][0][2]:
value = sale_line_obj.product_id_change(cr, uid, [], pricelist,
product_id, qty=1, partner_id=partner_id, fiscal_position=fpos)['value']
value['product_id'] = product_id
value['order_id'] = new_id
value['tax_id'] = [(6,0,value['tax_id'])]
sale_line_obj.create(cr, uid, value)
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id})
new_ids.append(new_id)
if data['form']['close']:
case_obj.case_close(cr, uid, data['ids'])
if not new_ids:
return {}
if len(new_ids)<=1:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id': new_ids and new_ids[0]
}
else:
value = {
'domain': str([('id', 'in', new_ids)]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'type': 'ir.actions.act_window',
'res_id':new_ids
}
return value
states = {
'init': {
'actions': [_selectPartner],
'result': {'type': 'form', 'arch': sale_form, 'fields': sale_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'),('order', 'Create Quote', 'gtk-go-forward')]}
},
'order': {
'actions': [],
'result': {'type': 'action', 'action': _makeOrder, 'state': 'end'}
}
}
make_sale('crm.opportunity.make_order')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: