2009-12-30 13:32:22 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2009-12-30 13:32:22 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import osv,fields
|
2009-12-30 13:32:22 +00:00
|
|
|
|
|
|
|
class sale_order(osv.osv):
|
|
|
|
_inherit = 'sale.order'
|
|
|
|
_columns = {
|
2010-05-12 17:09:20 +00:00
|
|
|
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
2012-07-06 11:06:21 +00:00
|
|
|
'categ_ids': fields.many2many('crm.case.categ', 'sale_order_category_rel', 'order_id', 'category_id', 'Categories', \
|
2011-06-01 10:25:01 +00:00
|
|
|
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]")
|
2010-01-08 11:05:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-26 16:02:33 +00:00
|
|
|
def write(self, cr, uid, ids, vals, context=None):
|
2012-12-18 18:17:18 +00:00
|
|
|
# TDE todo: will be replaced by automatic in mail.thread
|
2012-09-27 04:10:11 +00:00
|
|
|
if vals.get('section_id'):
|
|
|
|
section_id = self.pool.get('crm.case.section').browse(cr, uid, vals.get('section_id'), context=context)
|
2012-12-17 09:14:02 +00:00
|
|
|
vals['message_follower_ids'] = [(6, 0, [follower.id]) for follower in section_id.message_follower_ids]
|
2012-12-06 06:49:27 +00:00
|
|
|
res = super(sale_order, self).write(cr, uid, ids, vals, context=context)
|
2012-12-13 11:58:10 +00:00
|
|
|
# subscribe new salesteam followers & subtypes to the sale order
|
2012-09-27 04:10:11 +00:00
|
|
|
if vals.get('section_id'):
|
2012-12-17 07:38:17 +00:00
|
|
|
self._subscribe_followers_subtype(cr, uid, ids, vals.get('section_id'), 'crm.case.section', context=context)
|
2012-12-06 06:49:27 +00:00
|
|
|
return res
|
2012-09-26 16:02:33 +00:00
|
|
|
|
2010-01-08 11:05:05 +00:00
|
|
|
sale_order()
|
2009-12-30 13:32:22 +00:00
|
|
|
|
2012-11-21 10:50:07 +00:00
|
|
|
class res_users(osv.Model):
|
2012-11-21 12:41:28 +00:00
|
|
|
_inherit = 'res.users'
|
2012-11-21 10:50:07 +00:00
|
|
|
_columns = {
|
|
|
|
'default_section_id': fields.many2one('crm.case.section', 'Default Sales Team'),
|
|
|
|
}
|
|
|
|
|
2012-11-20 13:39:40 +00:00
|
|
|
class account_invoice(osv.osv):
|
|
|
|
_inherit = 'account.invoice'
|
|
|
|
_columns = {
|
|
|
|
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
|
|
|
}
|
|
|
|
_defaults = {
|
2012-11-26 08:33:31 +00:00
|
|
|
'section_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).default_section_id.id or False,
|
2012-11-20 13:39:40 +00:00
|
|
|
}
|
|
|
|
|
2010-09-08 09:29:57 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|