~therp-nl/therp-addons/7.0_lp1219418

« back to all changes in this revision

Viewing changes to fetchmail_inbox_invoice/wizard/fetchmail_inbox_attach_existing_wizard.py

  • Committer: Ronald Portier
  • Date: 2014-03-28 13:12:43 UTC
  • mfrom: (81.5.17 therp-addons-7.0)
  • Revision ID: ronald@therp.nl-20140328131243-d06yj7u2o9fhshrw
[MERGE] Merge upstream changes
    - resolve text conflict in fetchmail_invoice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    This module copyright (C) 2014 Therp BV (<http://therp.nl>).
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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/>.
 
19
#
 
20
##############################################################################
 
21
from openerp.osv.orm import TransientModel
 
22
 
 
23
class FetchmailInboxAttachExistingWizard(TransientModel):
 
24
    _inherit = 'fetchmail.inbox.attach.existing.wizard'
 
25
 
 
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)\
 
29
                .fields_view_get(
 
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}'
 
39
            if mail.author_id:
 
40
                result['fields']['res_id']['context'].update(
 
41
                    search_default_partner_id=\
 
42
                        mail.author_id.commercial_partner_id.id)
 
43
        return result