~vauxoo/addons-vauxoo/7.0-addons-vauxoo-imp-datetime-dev-ernesto

« back to all changes in this revision

Viewing changes to invoice_datetime/invoice.py

  • Committer: Luis Ernesto Garcia Medina
  • Date: 2014-11-18 21:38:41 UTC
  • Revision ID: ernesto_gm@vauxoo.com-20141118213841-02438ixoucnobo5q
[FIX][invoice_datetime] fix error with time of invoice

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    _inherit = 'account.invoice'
58
58
    # _order = 'invoice_datetime asc'
59
59
 
60
 
    def _get_date_invoice_tz(self, cr, uid, ids, field_names=None, arg=False,
61
 
                             context=None):
62
 
        if context is None:
63
 
            context = {}
64
 
        res = {}
65
 
        if release.version >= '6':
66
 
            tz = self.pool.get('res.users').browse(cr, uid, uid).tz
67
 
            for invoice in self.browse(cr, uid, ids, context=context):
68
 
                res[invoice.id] = invoice.invoice_datetime and tools.\
69
 
                    server_to_local_timestamp(
70
 
                        invoice.invoice_datetime,
71
 
                        tools.DEFAULT_SERVER_DATETIME_FORMAT,
72
 
                        tools.DEFAULT_SERVER_DATETIME_FORMAT, tz) or False
73
 
        elif release.version < '6':
74
 
            # TODO: tz change for openerp5
75
 
            for invoice in self.browse(cr, uid, ids, context=context):
76
 
                res[invoice.id] = invoice.date_invoice
77
 
        return res
78
 
 
79
60
    def _get_field_params(self, cr, uid, ids, name, unknow_none, context=None):
80
61
        if context is None:
81
62
            context = {}
99
80
                'open': [('readonly', True)],
100
81
                'close': [('readonly', True)]},
101
82
            help="Keep empty to use the current date"),
102
 
        'date_invoice_tz': fields.function(
103
 
            _get_date_invoice_tz,
104
 
            method=True,
105
 
            type='datetime',
 
83
        'date_invoice_tz': fields.datetime(
106
84
            string='Date Invoiced with TZ',
107
 
            store=True,
108
85
            help='Date of Invoice with Time Zone'),
109
86
        'date_type': fields.function(_get_field_params, storage=False,
110
87
                                     type='char', string="Date type")