[FIX]sale_crm: quotation/sale order default section_id based on res_users default_section_id
bzr revid: dle@openerp.com-20131217124201-kha2717b4ka51aih
This commit is contained in:
parent
ea1129b8f5
commit
df0a13ab4c
|
@ -21,21 +21,6 @@
|
||||||
|
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
|
|
||||||
class sale_order(osv.osv):
|
|
||||||
_inherit = 'sale.order'
|
|
||||||
_columns = {
|
|
||||||
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
|
||||||
'categ_ids': fields.many2many('crm.case.categ', 'sale_order_category_rel', 'order_id', 'category_id', 'Categories', \
|
|
||||||
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]", context="{'object_name': 'crm.lead'}")
|
|
||||||
}
|
|
||||||
|
|
||||||
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
|
||||||
invoice_vals = super(sale_order, self)._prepare_invoice(cr, uid, order, lines, context=context)
|
|
||||||
if order.section_id and order.section_id.id:
|
|
||||||
invoice_vals['section_id'] = order.section_id.id
|
|
||||||
return invoice_vals
|
|
||||||
|
|
||||||
|
|
||||||
class res_users(osv.Model):
|
class res_users(osv.Model):
|
||||||
_inherit = 'res.users'
|
_inherit = 'res.users'
|
||||||
_columns = {
|
_columns = {
|
||||||
|
@ -49,6 +34,31 @@ class res_users(osv.Model):
|
||||||
self.SELF_WRITEABLE_FIELDS.extend(['default_section_id'])
|
self.SELF_WRITEABLE_FIELDS.extend(['default_section_id'])
|
||||||
return init_res
|
return init_res
|
||||||
|
|
||||||
|
class sale_order(osv.osv):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
_columns = {
|
||||||
|
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
||||||
|
'categ_ids': fields.many2many('crm.case.categ', 'sale_order_category_rel', 'order_id', 'category_id', 'Categories', \
|
||||||
|
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]", context="{'object_name': 'crm.lead'}")
|
||||||
|
}
|
||||||
|
|
||||||
|
def _get_default_section_id(self, cr, uid, context=None):
|
||||||
|
""" Gives default section by checking if present in the context """
|
||||||
|
section_id = self.pool.get('crm.lead')._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
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'section_id': lambda s, cr, uid, c: s._get_default_section_id(cr, uid, c),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
||||||
|
invoice_vals = super(sale_order, self)._prepare_invoice(cr, uid, order, lines, context=context)
|
||||||
|
if order.section_id and order.section_id.id:
|
||||||
|
invoice_vals['section_id'] = order.section_id.id
|
||||||
|
return invoice_vals
|
||||||
|
|
||||||
|
|
||||||
class sale_crm_lead(osv.Model):
|
class sale_crm_lead(osv.Model):
|
||||||
_inherit = 'crm.lead'
|
_inherit = 'crm.lead'
|
||||||
|
|
Loading…
Reference in New Issue