~vauxoo/addons-vauxoo/7.0-purchase_requisition_contract_analyst-dev-1482-kty

« back to all changes in this revision

Viewing changes to update_period/account.py

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-03 00:17:35 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20120103001735-udkkubcf4dupskar

[ADD] Added new module update_period.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
5
#    All Rights Reserved
 
6
###############Credits######################################################
 
7
#    Coded by: Javier Duran <javieredm@gmail.com>,
 
8
#    Planified by: Nhomar Hernandez
 
9
#    Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve
 
10
#    Audited by: Humberto Arocha humberto@openerp.com.ve
 
11
#############################################################################
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU General Public License as published by
 
14
#    the Free Software Foundation, either version 3 of the License, or
 
15
#    (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
##############################################################################
 
25
 
 
26
from osv import fields, osv
 
27
 
 
28
class account_move(osv.osv):
 
29
    _inherit = 'account.move'
 
30
 
 
31
    def action_update_period(self, cr, uid, ids, context={}):
 
32
        moves = self.browse(cr, uid, ids[0])
 
33
        period_ids = self.pool.get('account.period').search(cr,uid,[('date_start','<=',moves.date),('date_stop','>=',moves.date)])
 
34
        if len(period_ids):
 
35
            period_id = period_ids[0]
 
36
            cr.execute('UPDATE account_move_line SET period_id=%s ' \
 
37
                        'WHERE move_id =%s', (period_id, ids[0]))
 
38
 
 
39
            self.write(cr, uid, ids, {'period_id':period_id})
 
40
 
 
41
        return True
 
42
 
 
43
account_move()
 
44
 
 
45
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: