diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 8119e9f1002..723ec6da155 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -3,9 +3,15 @@ + SAL Sales sale + + PUR + Purchases + purchase + - - + subflow @@ -66,7 +69,7 @@ - + diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index be4169c4624..7671c4b3d86 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -140,6 +140,6 @@ class stock_picking_in(osv.osv): _columns = { 'purchase_id': fields.many2one('purchase.order', 'Purchase Order', ondelete='set null', select=True), - 'warehouse_id': fields.related('purchase_id', 'warehouse_id', type='many2one', relation='stock.warehouse', string='Destination Warehouse'), + 'warehouse_id': fields.related('purchase_id', 'warehouse_id', type='many2one', relation='stock.warehouse', string='Destination Warehouse', readonly=True), } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 88cd20bd786..6584d25bdad 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -997,9 +997,9 @@ class mail_compose_message(osv.Model): def send_mail(self, cr, uid, ids, context=None): context = context or {} - if context.get('active_model') == 'sale.order' and context.get('active_ids') and context.get('mark_so_as_sent'): + if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'): context = dict(context, mail_post_autofollow=True) - self.pool.get('sale.order').signal_quotation_sent(cr, uid, context['active_ids']) + self.pool.get('sale.order').signal_quotation_sent(cr, uid, [context['default_res_id']]) return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py index f1370841fe9..9bcb5adf6ae 100644 --- a/addons/sale_crm/sale_crm.py +++ b/addons/sale_crm/sale_crm.py @@ -26,6 +26,18 @@ from dateutil import relativedelta from openerp import tools from openerp.osv import osv, fields +class res_users(osv.Model): + _inherit = 'res.users' + _columns = { + 'default_section_id': fields.many2one('crm.case.section', 'Default Sales Team'), + } + + def __init__(self, pool, cr): + init_res = super(res_users, self).__init__(pool, cr) + # duplicate list to avoid modifying the original reference + self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS) + self.SELF_WRITEABLE_FIELDS.extend(['default_section_id']) + return init_res class sale_order(osv.osv): _inherit = 'sale.order' @@ -35,6 +47,17 @@ class sale_order(osv.osv): 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: @@ -92,21 +115,6 @@ class crm_case_section(osv.osv): def action_forecast(self, cr, uid, id, value, context=None): return self.write(cr, uid, [id], {'invoiced_forecast': round(float(value))}, context=context) - -class res_users(osv.Model): - _inherit = 'res.users' - _columns = { - 'default_section_id': fields.many2one('crm.case.section', 'Default Sales Team'), - } - - def __init__(self, pool, cr): - init_res = super(res_users, self).__init__(pool, cr) - # duplicate list to avoid modifying the original reference - self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS) - self.SELF_WRITEABLE_FIELDS.extend(['default_section_id']) - return init_res - - class sale_crm_lead(osv.Model): _inherit = 'crm.lead' diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 69d2c6e4791..1484397b5a8 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2106,7 +2106,7 @@ class stock_move(osv.osv): }) new_moves.append(self.browse(cr, uid, [new_id])[0]) if pickid: - self.signal_button_confirm(cr, uid, [pickid]) + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [pickid]) if new_moves: new_moves += self.create_chained_picking(cr, uid, new_moves, context) return new_moves diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 99f2e738709..0443b888ef7 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -1044,7 +1044,7 @@