1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
21
from openerp.osv.orm import TransientModel
23
class FetchmailInboxAttachExistingWizard(TransientModel):
24
_inherit = 'fetchmail.inbox.attach.existing.wizard'
26
def fields_view_get(self, cr, user, view_id=None, view_type='form',
27
context=None, toolbar=False, submenu=False):
28
result = super(FetchmailInboxAttachExistingWizard, self)\
30
cr, user, view_id=view_id, view_type=view_type,
31
context=context, toolbar=toolbar, submenu=submenu)
32
if context and context.get('default_mail_id') and\
33
context.get('default_res_model') == 'account.invoice':
34
mail = self.pool.get('mail.message').browse(
35
cr, user, context.get('default_mail_id'), context=context)
36
result['fields']['res_id']['domain'] = [
37
('type', 'in', ('in_invoice', 'in_refund'))]
38
result['fields']['res_id']['options'] = '{"quick_create": false}'
40
result['fields']['res_id']['context'].update(
41
search_default_partner_id=\
42
mail.author_id.commercial_partner_id.id)