2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) Vauxoo (<http://vauxoo.com>).
7
###############Credits######################################################
8
# Coded by: Julio Cesar Serna Hernandez(julio@vauxoo.com)
9
#############################################################################
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU Affero General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU Affero General Public License for more details.
20
# You should have received a copy of the GNU Affero General Public License
21
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
################################################################################
24
from openerp.osv import fields, osv
25
from openerp import netsvc
26
import openerp.addons.decimal_precision as dp
27
from openerp.tools.translate import _
30
class account_voucher_tax_sat(osv.Model):
32
_name = 'account.voucher.tax.sat'
35
'name': fields.many2one('res.partner', 'Partner'),
36
'period_id': fields.many2one('account.period', 'Period'),
37
'aml_ids': fields.many2many('account.move.line', 'voucher_tax_sat_rel',
38
'voucher_tax_sat_id', 'move_line_id',
40
'journal_id':fields.many2one('account.journal', 'Journal'),
41
'move_id': fields.many2one('account.move', 'Journal Entry')
44
def action_close_tax(self, cr, uid, ids, context=None):
45
aml_obj = self.pool.get('account.move.line')
46
context = context or {}
47
ids= isinstance(ids,(int,long)) and [ids] or ids
48
for voucher_tax_sat in self.browse(cr, uid, ids, context=context):
50
move_id = self.create_move_sat(cr, uid, ids, context=context)
51
print move_id,'move_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_idmove_id'
52
self.write(cr, uid, ids, {'move_id': move_id})
54
amount_tax_sat = sum([move_line_tax_sat.credit
55
for move_line_tax_sat in voucher_tax_sat.aml_ids])
57
self.create_move_line_sat(cr, uid, voucher_tax_sat,
58
amount_tax_sat, context=context)
60
move_line_copy = [ aml_obj.copy(cr, uid, move_line_tax.id,
63
'period_id': voucher_tax_sat.period_id.id,
64
'journal_id': voucher_tax_sat.journal_id.id,
66
'debit': move_line_tax.credit,
67
}) for move_line_tax in voucher_tax_sat.aml_ids ]
71
def create_move_line_sat(self, cr, uid, voucher_tax_sat, amount, context=None):
72
print voucher_tax_sat,'voucher_tax_sat'
73
aml_obj = self.pool.get('account.move.line')
75
'move_id': voucher_tax_sat.move_id.id,
76
'journal_id': voucher_tax_sat.journal_id.id,
77
'date' : fields.datetime.now(),
78
'period_id' : voucher_tax_sat.period_id.id,
80
'name' : _('Payment with Advance'),
81
'partner_id' : voucher_tax_sat.name.id,
82
'account_id' : voucher_tax_sat.name.property_account_payable.id,
85
return aml_obj.create(cr, uid, vals, context=context)
87
def create_move_sat(self, cr, uid, ids, context=None):
88
account_move_obj = self.pool.get('account.move')
89
context = context or {}
90
ids= isinstance(ids,(int,long)) and [ids] or ids
91
for move_tax_sat in self.browse(cr, uid, ids, context=context):
92
vals_move_tax= account_move_obj.account_move_prepare(cr, uid,
93
move_tax_sat.journal_id.id,
94
ref='Entry SAT', context=context)
95
return account_move_obj.create(cr, uid, vals_move_tax, context=context)
b'\\ No newline at end of file'