[MOD/IMP] crm : In lead,opportunity views type field added. sales : advance invoice wizard, when user create advance invoice form view open

bzr revid: vir@tinyerp.com-20100610130407-42ibe5pxl2n8k42u
This commit is contained in:
Vir (Open ERP) 2010-06-10 18:34:07 +05:30
parent fd58ff8578
commit 3b06f1f5be
5 changed files with 90 additions and 76 deletions

View File

@ -30,19 +30,19 @@ from tools.translate import _
MAX_LEVEL = 15
AVAILABLE_STATES = [
('draft', 'Draft'),
('open', 'Open'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('draft', 'Draft'),
('open', 'Open'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('pending', 'Pending'),
]
AVAILABLE_PRIORITIES = [
('1', 'Highest'),
('2', 'High'),
('3', 'Normal'),
('4', 'Low'),
('5', 'Lowest'),
('2', 'High'),
('3', 'Normal'),
('4', 'Low'),
('5', 'Lowest'),
]
class crm_case(object):
@ -107,10 +107,10 @@ class crm_case(object):
"""
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.context_section_id.id or False
def stage_next(self, cr, uid, ids, context=None):
"""This function computes next stage for case from its current stage
using available stage for that case type
using available stage for that case type
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@ -151,7 +151,7 @@ class crm_case(object):
def stage_previous(self, cr, uid, ids, context=None):
"""This function computes previous stage for case from its current stage
using available stage for that case type
using available stage for that case type
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@ -177,11 +177,11 @@ class crm_case(object):
@param uid: the current users ID for security checks,
@param ids: List of case IDs
@param part: Partner's id
@email: Partner's email ID
@email: Partner's email ID
"""
if not part:
return {'value': {'partner_address_id': False,
'email_from': False,
return {'value': {'partner_address_id': False,
'email_from': False,
}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact'])
data = {'partner_address_id': addr['contact']}
@ -195,13 +195,13 @@ class crm_case(object):
@param uid: the current users ID for security checks,
@param ids: List of case IDs
@param add: Id of Partner's address
@email: Partner's email ID
@email: Partner's email ID
"""
if not add:
return {'value': {'email_from': False}}
address = self.pool.get('res.partner.address').browse(cr, uid, add)
return {'value': {'email_from': address.email}}
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context={}):
mailgate_pool = self.pool.get('mailgate.thread')
return mailgate_pool._history(cr, uid, cases, keyword, history=history,\
@ -209,7 +209,7 @@ class crm_case(object):
details=details, email_from=email_from,\
message_id=message_id, attach=attach, \
context=context)
def case_open(self, cr, uid, ids, *args):
"""Opens Case
@param self: The object pointer
@ -265,7 +265,7 @@ class crm_case(object):
if case.section_id.parent_id.user_id:
data['user_id'] = case.section_id.parent_id.user_id.id
else:
raise osv.except_osv(_('Error !'), _('You can not escalate this case.\nYou are already at the top level.'))
raise osv.except_osv(_('Error !'), _('You can not escalate, You are already at the top level regarding your sales-team category.'))
self.write(cr, uid, [case.id], data)
cases = self.browse(cr, uid, ids)
self._history(cr, uid, cases, _('Escalate'))
@ -317,7 +317,7 @@ class crm_case(object):
self.write(cr, uid, ids, {'state': 'draft', 'active': True})
self._action(cr, uid, cases, 'draft')
return True
def remind_partner(self, cr, uid, ids, context={}, attach=False):
"""
@ -350,7 +350,7 @@ class crm_case(object):
src = case.email_from
dest = case.section_id.reply_to
body = ""
body = case.email_last or case.description
body = case.email_last or case.description
if not destination:
src, dest = dest, src
if body and case.user_id.signature:
@ -381,7 +381,7 @@ class crm_case(object):
# raise osv.except_osv(_('Email!'),("Email Successfully Sent"))
#else:
# raise osv.except_osv(_('Email Fail!'),("Email is not sent successfully"))
return True
return True
def _check(self, cr, uid, ids=False, context={}):
"""
@ -428,12 +428,12 @@ class crm_case_section(osv.osv):
_order = "name"
_columns = {
'name': fields.char('Sales Team', size=64, required=True, translate=True),
'code': fields.char('Code', size=8),
'name': fields.char('Sales Team', size=64, required=True, translate=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."),
'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
'user_id': fields.many2one('res.users', 'Responsible User'),
true, it will allow you to hide the sales team without removing it."),
'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"),
'user_id': fields.many2one('res.users', 'Responsible User'),
'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 Open ERP about cases in this sales team"),
@ -445,8 +445,8 @@ class crm_case_section(osv.osv):
}
_defaults = {
'active': lambda *a: 1,
'allow_unlink': lambda *a: 1,
'active': lambda *a: 1,
'allow_unlink': lambda *a: 1,
}
_sql_constraints = [
@ -463,7 +463,7 @@ class crm_case_section(osv.osv):
@param ids: List of Sales team ids
"""
level = 100
while len(ids):
cr.execute('select distinct parent_id from crm_case_section where id =ANY(%s)', (ids,))
ids = filter(None, map(lambda x: x[0], cr.fetchall()))
@ -509,9 +509,9 @@ class crm_case_categ(osv.osv):
_description = "Category of case"
_columns = {
'name': fields.char('Case Category Name', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'object_id': fields.many2one('ir.model', 'Object Name'),
'name': fields.char('Case Category Name', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'object_id': fields.many2one('ir.model', 'Object Name'),
}
def _find_object_id(self, cr, uid, context=None):
@ -541,9 +541,9 @@ class crm_case_resource_type(osv.osv):
_rec_name = "name"
_columns = {
'name': fields.char('Case Resource Type', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'object_id': fields.many2one('ir.model', 'Object Name'),
'name': fields.char('Case Resource Type', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'object_id': fields.many2one('ir.model', 'Object Name'),
}
def _find_object_id(self, cr, uid, context=None):
"""Finds id for case object
@ -572,14 +572,14 @@ class crm_case_stage(osv.osv):
_order = "sequence"
_columns = {
'name': fields.char('Stage Name', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'name': fields.char('Stage Name', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'sequence': fields.integer('Sequence', help="Gives the sequence order \
when displaying a list of case stages."),
'object_id': fields.many2one('ir.model', 'Object Name'),
'probability': fields.float('Probability (%)', required=True),
when displaying a list of case stages."),
'object_id': fields.many2one('ir.model', 'Object Name'),
'probability': fields.float('Probability (%)', required=True),
'on_change': fields.boolean('Change Probability Automatically', \
help="Change Probability on next and previous stages."),
help="Change Probability on next and previous stages."),
'requirements': fields.text('Requirements')
}
def _find_object_id(self, cr, uid, context=None):
@ -594,8 +594,8 @@ class crm_case_stage(osv.osv):
return ids and ids[0]
_defaults = {
'sequence': lambda *args: 1,
'probability': lambda *args: 0.0,
'sequence': lambda *args: 1,
'probability': lambda *args: 0.0,
'object_id' : _find_object_id
}
@ -619,7 +619,7 @@ class users(osv.osv):
_inherit = 'res.users'
_description = "Users"
_columns = {
'context_section_id': fields.many2one('crm.case.section', 'Sales Team'),
'context_section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
users()
@ -627,7 +627,7 @@ users()
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
res_partner()

View File

@ -48,7 +48,7 @@
<field name="date_deadline"/>
<button
name="convert_opportunity"
string="Convert"
string="Convert to Opportunity"
help="Convert to Opportunity"
icon="gtk-index"
type="object"/>
@ -66,6 +66,7 @@
states="open,pending" type="object"
icon="gtk-go-forward" />
</group>
<field name="type" readonly="1"/>
</group>
<notebook colspan="4">
<page string="Lead">

View File

@ -26,10 +26,10 @@
<field name="name">Opportunities</field>
<field name="res_model">crm.lead</field>
<field name="view_mode">tree,form,graph</field>
<field name="domain">[('type','=','opportunity')]</field>
<field name="context">{'search_default_current':1, 'default_type': 'opportunity'}</field>
<field name="domain">['|',('type','=','opportunity'),('state','=','draft')]</field>
<field name="context">{'search_default_user_id':uid,'search_default_current':1}</field>
<field name="view_id" ref="crm_case_tree_view_oppor"/>
<field name="context">{"search_default_user_id":uid}</field>
<field name="context">{'search_default_current':1, 'default_type': 'opportunity'}</field>
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
</record>

View File

@ -82,6 +82,7 @@
<newline/>
<field name="date_action"/>
<field name="priority" string="Priority"/>
<field name="type" readonly="1"/>
</group>
<notebook colspan="4">
<page string="Opportunity">

View File

@ -35,23 +35,23 @@ class sale_advance_payment_inv(osv.osv_memory):
'qtty' : lambda *a: 1
}
def create_invoices(self, cr, uid, ids, context={}):
"""
"""
To create invoices.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID or list of IDs if we want more than one
@param context: A standard dictionary
@return:
"""
@param ids: the ID or list of IDs if we want more than one
@param context: A standard dictionary
@return:
"""
list_inv = []
obj_sale = self.pool.get('sale.order')
obj_lines = self.pool.get('account.invoice.line')
inv_obj = self.pool.get('account.invoice')
for sale_adv_obj in self.browse(cr, uid, ids):
for sale in obj_sale.browse(cr, uid, context['active_ids']):
address_contact = False
@ -93,7 +93,7 @@ class sale_advance_payment_inv(osv.osv_memory):
'payment_term':sale.payment_term.id,
'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id
}
inv_id = inv_obj.create(cr, uid, inv)
for inv in sale.invoice_ids:
@ -119,6 +119,8 @@ class sale_advance_payment_inv(osv.osv_memory):
'tax_id': [(6, 0, val['value']['invoice_line_tax_id'])],
}, context)
context.update({'invoice_id':list_inv})
return {#'invoice_ids':list_inv,
'name': 'Open Invoice',
'view_type': 'form',
@ -126,7 +128,7 @@ class sale_advance_payment_inv(osv.osv_memory):
'res_model': 'sale.open.invoice',
'type': 'ir.actions.act_window',
'target': 'new',
'context': "{'invoice_ids'=%s}" % (list_inv)
'context':context
}
sale_advance_payment_inv()
@ -138,39 +140,49 @@ class sale_open_invoice(osv.osv_memory):
}
def open_invoice(self, cr, uid, ids, context):
"""
"""
To open invoice.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID or list of IDs if we want more than one
@param context: A standard dictionary
@return:
"""
@param ids: the ID or list of IDs if we want more than one
@param context: A standard dictionary
@return:
"""
record_id = context and context.get('active_id', False) or False
mod_obj = self.pool.get('ir.model.data')
obj_inv = self.pool.get('account.invoice')
invoices = []
#TODO: Can not get invoice ids here
invoice = obj_inv.browse(cr, uid, record_id, context=context)
for advance_pay in self.browse(cr, uid, ids):
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
model_data_ids = mod_obj.search(cr, uid,
[('model', '=', 'ir.ui.view'), ('name', '=', 'invoice_form')])
resource_id = mod_obj.read(cr, uid, model_data_ids,
fields=['res_id'])[0]['res_id']
form_id = mod_obj._get_id(cr, uid, 'account', 'invoice_form')
form_res = mod_obj.browse(cr, uid, form_id, context=context).res_id
tree_id = mod_obj._get_id(cr, uid, 'account', 'invoice_tree')
tree_res = mod_obj.browse(cr, uid, tree_id, context=context).res_id
return {
# 'domain': "[('id','in', ["+','.join(map(str, invoices))+"])]", # TODO
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'view_mode': 'form,tree',
'res_model': 'account.invoice',
'views': [(False, 'tree'), (resource_id, 'form')],
'res_id': int(context['invoice_id'][0]),
'view_id': False,
'views': [(form_res, 'form'), (tree_res, 'tree')],
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
sale_open_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: