[IMP] task-620 usability Improvement for sales menu in crm ,sale,base_calendar,product

bzr revid: ksa@tinyerp.co.in-20100514113309-grkxy5795dzkf220
This commit is contained in:
ksa (Open ERP) 2010-05-14 17:03:09 +05:30
parent 1a8ce11d22
commit 5c10570244
18 changed files with 83 additions and 147 deletions

View File

@ -13,37 +13,38 @@
<field name="type" />
<field name="send_mail" />
<newline />
<group col="1" colspan="4"
<group col="2" colspan="6"
attrs="{'invisible': [('type', '!=', 'external')]}">
<field name="email" colspan="4"
attrs="{'required': [('type', '=', 'external')]}" />
</group>
<group col="1" colspan="4"
<group col="2" colspan="6"
attrs="{'invisible': [('type', '!=', 'internal')]}">
<separator string="Users" colspan="4" />
<field name="user_ids" select="1" colspan="4"
nolabel="1" />
<newline />
</group>
<group col="2" colspan="4"
<group col="2" colspan="6"
attrs="{'invisible': [('type', '!=', 'partner')]}">
<field name="partner_id" colspan="2"
on_change="onchange_partner_id(partner_id)"
attrs="{'required': [('type', '=', 'partner')]}" />
<newline />
<separator string="Partner Contacts"
colspan="4" />
colspan="6" />
<field name="contact_ids" select="1" colspan="4"
nolabel="1" domain="[('partner_id', '=', partner_id)]"
attrs="{'readonly': [('type', '!=', 'partner')]}" />
</group>
<newline />
<separator string="" colspan="6" />
<label string="" colspan="2" />
<group col="4" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="do_invite" string="Invite"
type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>

View File

@ -74,7 +74,7 @@ class crm_lead(osv.osv, crm_case):
duration = float(ans.days)
if lead.section_id and lead.section_id.resource_calendar_id:
duration = float(ans.days) * 24
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,
@ -95,18 +95,18 @@ class crm_lead(osv.osv, crm_case):
_columns = {
# From crm.case
'email_from': fields.char('Email', size=128, help="These people will receive email."),
'email_from': fields.char('Email', size=128, help="These people will receive email."),
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
select=True, help='Sales team to which Case belongs to.\
Define Responsible user and Email account for mail gateway.'),
Define Responsible user and Email account for mail gateway.'),
'create_date': fields.datetime('Creation Date' , readonly=True),
'email_cc': fields.text('Watchers Emails', size=252 , help="These \
people will receive a copy of the future communication between partner \
and users by email"),
'description': fields.text('Description'),
'write_date': fields.datetime('Update Date' , readonly=True),
'description': fields.text('Description'),
'write_date': fields.datetime('Update Date' , readonly=True),
# Lead fields
# Lead fields
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
@ -117,34 +117,34 @@ and users by email"),
'type':fields.selection([
('lead','Lead'),
('opportunity','Opportunity'),
],'Type', help="Type is used to separate Leads and Opportunities"),
],'Type', help="Type is used to separate Leads and Opportunities"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'user_id': fields.many2one('res.users', 'Salesman'),
'user_id': fields.many2one('res.users', 'Salesman',help='By Default Salesman is Administrator when create New User'),
'referred': fields.char('Referred By', size=64),
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="float", store=True),
'function_name': fields.char('Function', size=64),
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
'function_name': fields.char('Function', size=64),
'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True,
help='The state is set to \'Draft\', when a case is created.\
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
}
_defaults = {
'active': lambda *a: 1,
'user_id': crm_case._get_default_user,
'email_from': crm_case._get_default_email,
'state': lambda *a: 'draft',
'section_id': crm_case._get_section,
'active': lambda *a: 1,
'user_id': crm_case._get_default_user,
'email_from': crm_case._get_default_email,
'state': lambda *a: 'draft',
'section_id': crm_case._get_section,
'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],
}
@ -160,7 +160,7 @@ and users by email"),
res = super(crm_lead, self).case_open(cr, uid, ids, *args)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
return res
def case_close(self, cr, uid, ids, *args):
"""Overrides close for crm_case for setting close date
@param self: The object pointer

View File

@ -47,7 +47,7 @@
name="convert_opportunity"
string="Convert"
help="Convert to Opportunity"
icon="gtk-index"
icon="gtk-index"
type="object"/>
<newline />
<field name="section_id" colspan="1"
@ -175,7 +175,7 @@
<field name="email_to"/>
<field name="description"/>
</tree>
</field>
</field>
<button colspan="2" string="Send New Email"
name="%(action_crm_send_mail)d"
context="{'mail':'new', 'model': 'crm.lead'}"

View File

@ -110,7 +110,8 @@
<menuitem id="menu_attendee_invitations"
name="Meeting Invitations" parent="crm.menu_meeting_sale"
sequence="10" action="action_view_attendee_form" />
sequence="10" action="action_view_attendee_form"
groups="base.group_extended" />
</data>
</openerp>

View File

@ -217,7 +217,6 @@
<field name="partner_id" string="Partner" />
<field name="date" string="Meeting Date" />
<field name="duration" />
<field name="user_id" />
<field name="state"/>
</tree>
</field>

View File

@ -40,81 +40,12 @@ class crm_opportunity(osv.osv):
_name = "crm.lead"
_description = "Opportunity Cases"
_order = "priority,date_action,id desc"
def case_open(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case's Ids
@param *args: Give Tuple Value
"""
res = super(crm_opportunity, self).case_open(cr, uid, ids, *args)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
return res
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Opendays IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
cal_obj = self.pool.get('resource.calendar')
res_obj = self.pool.get('resource.resource')
res = {}
for opportunity in self.browse(cr, uid, ids , context):
for field in fields:
res[opportunity.id] = {}
duration = 0
ans = False
if field == 'day_open':
if opportunity.date_open:
date_create = datetime.strptime(opportunity.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(opportunity.date_open, "%Y-%m-%d %H:%M:%S")
ans = date_open - date_create
date_until = opportunity.date_open
elif field == 'day_close':
if opportunity.date_closed:
date_create = datetime.strptime(opportunity.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(opportunity.date_closed, "%Y-%m-%d %H:%M:%S")
date_until = opportunity.date_closed
ans = date_close - date_create
if ans:
resource_id = False
if opportunity.user_id:
resource_ids = res_obj.search(cr, uid, [('user_id','=',opportunity.user_id.id)])
if resource_ids and len(resource_ids):
resource_id = resource_ids[0]
duration = float(ans.days)
if opportunity.section_id and opportunity.section_id.resource_calendar_id:
duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr,
uid,
opportunity.section_id.resource_calendar_id and opportunity.section_id.resource_calendar_id.id or False,
mx.DateTime.strptime(opportunity.create_date, '%Y-%m-%d %H:%M:%S'),
duration,
resource=resource_id
)
no_days = []
date_until = mx.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[opportunity.id][field] = abs(int(duration))
return res
_inherit = 'crm.lead'
_columns = {
# From crm.case
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
domain="[('partner_id','=',partner_id)]"),
domain="[('partner_id','=',partner_id)]"),
# Opportunity fields
'probability': fields.float('Probability (%)'),
@ -125,7 +56,7 @@ class crm_opportunity(osv.osv):
'date_deadline': fields.date('Expected Closing'),
'date_action': fields.date('Next Action'),
}
def case_close(self, cr, uid, ids, *args):
"""Overrides close for crm_case for setting probability and close date
@param self: The object pointer
@ -149,7 +80,7 @@ class crm_opportunity(osv.osv):
res = super(crm_opportunity, self).case_cancel(cr, uid, ids, args)
self.write(cr, uid, ids, {'probability' : 0.0})
return res
def case_open(self, cr, uid, ids, *args):
"""Overrides cancel for crm_case for setting Open Date
@param self: The object pointer

View File

@ -2,16 +2,6 @@
<openerp>
<data noupdate="1">
<act_window
id="act_crm_opportunity_crm_meeting_new"
name="Meetings"
res_model="crm.meeting"
src_model="crm.lead"
view_mode="tree,form,calendar,"
context="{'default_duration': 4.0, 'default_opportunity_id': active_id}"
domain="[('user_id','=',uid), ('opportunity_id', '=', active_id)]"
view_type="form"/>
<act_window
id="act_crm_opportunity_crm_phonecall_new"
name="Phone calls"
@ -22,6 +12,16 @@
domain="[('user_id','=',uid),('opportunity_id', '=', active_id)]"
view_type="form"/>
<act_window
id="act_crm_opportunity_crm_meeting_new"
name="Meetings"
res_model="crm.meeting"
src_model="crm.lead"
view_mode="tree,form,calendar,"
context="{'default_duration': 4.0, 'default_opportunity_id': active_id}"
domain="[('user_id','=',uid), ('opportunity_id', '=', active_id)]"
view_type="form"/>
<record model="ir.actions.act_window" id="crm_case_category_act_oppor11">
<field name="name">Opportunities</field>
<field name="res_model">crm.lead</field>

View File

@ -315,8 +315,6 @@
domain="[]" context="{'group_by':'categ_id'}" />
<separator orientation="vertical" />
<filter string="Partner" icon="terp-crm" domain="[]"
context="{'group_by':'partner_id'}" />
<filter string="Salesman" icon="terp-crm"
domain="[('user_id','=',uid)]" context="{'group_by':'user_id'}" />
<separator orientation="vertical" />

View File

@ -10,6 +10,7 @@
view_mode="calendar,tree,form"
context="{'default_partner_id': active_id, 'default_duration': 1.0}"
domain="[('partner_id', '=', active_id)]"
groups="base.group_extended"
/>
<!-- PHONE CALLS (menu) -->

View File

@ -63,7 +63,7 @@
</record>
<!-- Leads by user and section Search View -->
<record id="view_report_crm_lead_filter" model="ir.ui.view">
<field name="name">crm.lead.report.select</field>
<field name="model">crm.lead.report</field>
@ -119,7 +119,7 @@
</field>
</group>
<newline/>
<group expand="1" string="Extended options..." colspan="10" col="12">
<group expand="1" string="Extended options..." colspan="10" col="12" groups="base.group_extended">
<filter icon="terp-sale"
string="Done"
domain="[('state','=','done')]"/>
@ -144,14 +144,14 @@
<filter string="Section" icon="terp-sale"
domain="[]"
context="{'group_by':'section_id'}" />
<separator orientation="vertical" />
<filter string="State" icon="terp-sale"
domain="[]" context="{'group_by':'state'}" />
<filter string="Stage" icon="terp-sale" domain="[]"
context="{'group_by':'stage_id'}" />
<filter string="Category" icon="terp-sale"
domain="[]" context="{'group_by':'categ_id'}" />
@ -180,9 +180,9 @@
<tree string="Opportunities">
<field name="name" invisible="1"/>
<field name="month" invisible="1"/>
<field name="section_id" invisible="1"/>
<field name="section_id" invisible="1" groups="base.group_extended"/>
<field name="user_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="company_id" invisible="1" groups="base.group_extended"/>
<field name="partner_id" invisible="1"/>
<field name="day" invisible="1"/>
<field name="nbr" string="#Opportunities" sum="#Opportunities"/>
@ -220,7 +220,7 @@
<field name="view_id" ref="view_report_crm_lead_graph"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
<field name="name">Opportunities</field>
<field name="res_model">crm.lead.report</field>
@ -244,7 +244,7 @@
<field name="view_id" ref="view_report_crm_lead_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
<menuitem name="Leads" id="menu_report_crm_leads_tree"
groups="base.group_extended"
parent="base.next_id_64" action="action_report_crm_lead" />

View File

@ -39,7 +39,8 @@
key2="client_action_multi" name="Create Opportunity"
res_model="crm.partner2opportunity" src_model="res.partner"
view_id="view_crm_lead2partner_create"
view_mode="form" target="new" view_type="form" />
view_mode="form" target="new" view_type="form"
groups="base.group_extended"/>
</data>
</openerp>

View File

@ -446,7 +446,7 @@ class product_product(osv.osv):
'outgoing_qty': fields.function(_product_outgoing_qty, method=True, type='float', string='Outgoing'),
'price': fields.function(_product_price, method=True, type='float', string='Pricelist', digits_compute=dp.get_precision('Sale Price')),
'lst_price' : fields.function(_product_lst_price, method=True, type='float', string='List Price', digits_compute=dp.get_precision('Sale Price')),
'code': fields.function(_product_code, method=True, type='char', string='Code'),
'code': fields.function(_product_code, method=True, type='char', string='Reference'),
'partner_ref' : fields.function(_product_partner_ref, method=True, type='char', string='Customer ref'),
'default_code' : fields.char('Reference', size=64),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the product without removing it."),

View File

@ -49,7 +49,6 @@ def _incoterm_get(self, cr, uid, context=None):
cr.execute('select code, code||\', \'||name from stock_incoterms where active')
return cr.fetchall()
class sale_order(osv.osv):
_name = "sale.order"
_description = "Sale Order"
@ -1043,7 +1042,7 @@ class sale_order_line(osv.osv):
if product_obj.uos_id.category_id.id != uos2.category_id.id:
uos = False
else:
uos = False
uos = False
if product_obj.description_sale:
result['notes'] = product_obj.description_sale
fpos = fiscal_position and self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position) or False

View File

@ -193,6 +193,7 @@
<field name="amount_tax"/>
<field name="amount_total" sum="Total amount"/>
<button name="button_dummy" states="draft" string="Compute" type="object" icon="gtk-execute"/>
<button name="%(action_view_sale_advance_payment_inv)d" string="Advance Invoice" type="action" icon="gtk-execute"/>
</group>
<group col="13" colspan="4">
<field name="state"/>
@ -384,6 +385,11 @@
<field colspan="4" name="tax_id" domain="[('parent_id','=',False),('type_tax_use','&lt;&gt;','purchase')]"/>
<separator colspan="4" string="States"/>
<field name="state"/>
<button colspan="1"
name="%(action_view_sale_order_line_make_invoice)d"
string="Make Invoice"
type="action"
icon="gtk-print" />
<group col="2" colspan="2">
<button name="button_done"
states="confirmed,exception"

View File

@ -16,13 +16,14 @@
</field>
</record>
<act_window name="Make Invoices"
res_model="sale.order.line.make.invoice"
src_model="sale.order.line"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_sale_order_line_make_invoice"/>
<record id="action_view_sale_order_line_make_invoice" model="ir.actions.act_window">
<field name="name">Make Invoices</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order.line.make.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_sale_advance_payment_inv" model="ir.ui.view">
@ -20,15 +19,14 @@
</field>
</record>
<act_window name="Advance Invoice"
res_model="sale.advance.payment.inv"
src_model="sale.order"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_sale_advance_payment_inv"/>
<record id="action_view_sale_advance_payment_inv" model="ir.actions.act_window">
<field name="name">Advance Invoice</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.advance.payment.inv</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="view_sale_open_invoice" model="ir.ui.view">
<field name="name">Open Invoice</field>

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="Create a Sale Order" icon="terp-sale" name="%(sale_crm_wizard)d" type="action"/>
<label colspan="2" string=""/>
</field>
</field>

View File

@ -28,7 +28,7 @@ import pooler
from tools.translate import _
sale_form = """<?xml version="1.0"?>
<form string="Convert to Quote">
<form string="Create a Sale Order">
<field name="partner_id" required="True"/>
<field name="shop_id" required="True"/>
<field name="analytic_account"/>
@ -130,10 +130,10 @@ class make_sale(wizard.interface):
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)]),
@ -154,14 +154,14 @@ class make_sale(wizard.interface):
'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')]}
'state' : [('end', 'Cancel', 'gtk-cancel'),('order', 'Create', 'gtk-go-forward')]}
},
'order': {
'actions': [],