~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to msf_instance/msf_instance_installer.py

  • Committer: Quentin THEURET
  • Date: 2016-03-04 12:15:00 UTC
  • Revision ID: qt@tempo-consulting.fr-20160304121500-u2ay8zrf83ih9fu3
US-826 [IMP] Change the way to check if products is not consistent on add multiple line wizard

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
from osv import fields, osv
 
4
import tools
 
5
from os.path import join as opj
 
6
from tools.translate import _
 
7
 
 
8
 
 
9
class msf_instance_setup(osv.osv_memory):
 
10
    _name = 'msf_instance.setup'
 
11
    _inherit = 'res.config'
 
12
 
 
13
    _columns = {
 
14
         'instance_id': fields.many2one('msf.instance', string="Proprietary instance", required=True),
 
15
    }
 
16
 
 
17
    def get_instance(self, cr, uid, context=None):
 
18
        instance_ids = self.pool.get('msf.instance').search(cr, uid, [], limit=1)
 
19
        return instance_ids and instance_ids[0] or False
 
20
 
 
21
    _defaults = {
 
22
        'instance_id': get_instance,
 
23
    }
 
24
 
 
25
    def execute(self, cr, uid, ids, context=None):
 
26
        res = self.read(cr, uid, ids)
 
27
        self.pool.get('res.company').write(cr, uid, [self.pool.get('res.users').browse(cr, uid, uid).company_id.id], {'instance_id': res[0]['instance_id']})
 
28
        return {}
 
29
 
 
30
msf_instance_setup()