~openerp-dev/openobject-addons/6.1-opw-579908-msh

« back to all changes in this revision

Viewing changes to l10n_ch_chart_c2c_pcg/wizard/config.py

  • Committer: qdp-launchpad at tinyerp
  • Author(s): niv at openerp
  • Date: 2010-11-09 12:31:13 UTC
  • mfrom: (3164.136.49 addons)
  • Revision ID: qdp-launchpad@tinyerp.com-20101109123113-fjx90w5eeqo0imkd
Tags: openerp-buildfail-1-3151
[MERGE] merged the localization branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
#
3
 
#  config.py
4
 
#
5
 
#  Created by Nicolas Bessi on 12.02.09.
6
 
#  Copyright (c) 2009 CamptoCamp. All rights reserved.
7
 
#
8
 
from osv import fields, osv
9
 
 
10
 
class Tax_template(osv.osv_memory):
11
 
    """Creat account.journal.todo class in order
12
 
        to add configuration wizzard"""
13
 
    _name ="account.tax.template.todo"
14
 
    _inherit = 'res.config'
15
 
 
16
 
    def _ensure_step(self):
17
 
        if getattr(self, '_inner_steps', None) is None:
18
 
            self._inner_steps = 0
19
 
 
20
 
    def _current_tax_template(self, cr, uid):
21
 
        ids = self.pool.get('account.tax.template').search(cr,uid,[])
22
 
        return self.pool.get('account.tax.template').browse(
23
 
            cr, uid, ids[self._inner_steps]
24
 
            )
25
 
 
26
 
    def _get_tax(self, cr, uid, ctx):
27
 
        self._ensure_step()
28
 
        return self.pool.get('account.tax.template')\
29
 
            .search(cr,uid,[])[self._inner_steps]
30
 
 
31
 
    def _get_collected(self, cr, uid, ctx):
32
 
        self._ensure_step()
33
 
        return self._current_tax_template(cr, uid).account_collected_id.id
34
 
 
35
 
    def _get_paid(self, cr, uid, ctx):
36
 
        self._ensure_step()
37
 
        return self._current_tax_template(cr, uid).account_paid_id.id
38
 
 
39
 
    _columns = {
40
 
        'name': fields.many2one(
41
 
            'account.tax.template',
42
 
            'Tax to set',
43
 
             readonly=True,
44
 
             help="The tax template you are currently editing"
45
 
        ),
46
 
        'account_collected_id':fields.many2one(
47
 
            'account.account.template',
48
 
            'Invoice Tax Account',
49
 
            help="You can set here the invoice tax account"
50
 
            ),
51
 
        'account_paid_id':fields.many2one(
52
 
            'account.account.template',
53
 
            'Refund Tax Account',
54
 
            help="You can set here the refund tax account"
55
 
            ),
56
 
        }
57
 
 
58
 
    _defaults = {
59
 
        'name': _get_tax,
60
 
        'account_collected_id': _get_collected,
61
 
        'account_paid_id': _get_paid,
62
 
        }
63
 
 
64
 
    def _on_change(self, cr, uid, id, tax, vals):
65
 
        if tax:
66
 
            self.pool.get('account.tax.template').write(cr, uid, tax, vals=vals)
67
 
        return {}
68
 
 
69
 
    def on_change_collected(self, cr, uid, ids, tax, account):
70
 
        return self._on_change(cr, uid, ids, tax, vals={'account_collected_id': account})
71
 
 
72
 
    def on_change_paid(self, cr, uid, id, tax, account):
73
 
        return self._on_change(
74
 
            cr, uid, id, tax, vals={'account_paid_id': account})
75
 
 
76
 
    def execute(self,cr,uid,ids,context={}):
77
 
        jids = self.pool.get('account.tax.template').search(cr, uid, [])
78
 
        if self._inner_steps < len(jids)-1 :
79
 
            self._inner_steps += 1
80
 
            return {
81
 
                'view_type': 'form',
82
 
                "view_mode": 'form',
83
 
                'res_model': 'account.tax.template.todo',
84
 
                'view_id':self.pool.get('ir.ui.view').search(
85
 
                    cr, uid, [('name','=','account.tax.template.todo')]),
86
 
                'type': 'ir.actions.act_window',
87
 
                'target':'new',
88
 
                }
89
 
Tax_template()
90
 
 
91
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: