1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (c) 2009 Alejandro Sanchez (http://www.asr-oss.com) All Rights Reserved.
6
# Alejandro Sanchez <alejandro@asr-oss.com>
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
24
from osv import osv,fields
28
class l10n_es_aeat_mod340_config(osv.osv):
29
_name = 'l10n.es.aeat.mod340.config'
30
_description = 'Config Model 340'
32
'name' : fields.char('Name',size=40),
33
'taxes_id': fields.many2many('account.tax', 'mod340_config_taxes_rel','config_id', 'tax_id',
34
'Customer Taxes',domain=[('parent_id','=',False),('type_tax_use','in',['sale','all'])]),
35
'supplier_taxes_id': fields.many2many('account.tax',
36
'mod340_config_supplier_taxes_rel', 'config_id', 'tax_id',
37
'Supplier Taxes', domain=[('parent_id', '=', False),('type_tax_use','in',['purchase','all'])])
39
l10n_es_aeat_mod340_config()
41
class l10n_es_aeat_mod340(osv.osv):
43
def _total_taxable(self, cursor, user, ids, name, args, context=None):
47
for mod340 in self.browse(cursor, user, ids, context=context):
51
res[mod340.id] = reduce(lambda x, y: x + y.taxable, mod340.issued, 0.0)
54
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.taxable, mod340.received, 0.0)
57
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.taxable, mod340.investment, 0.0)
58
#registros intracomunitarias
59
if mod340.intracomunitarias:
60
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.taxable, mod340.intracomunitarias, 0.0)
64
def _total_share_tax(self, cursor, user, ids, name, args, context=None):
68
for mod340 in self.browse(cursor, user, ids, context=context):
72
res[mod340.id] = reduce(lambda x, y: x + y.share_tax, mod340.issued, 0.0)
75
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.share_tax, mod340.received, 0.0)
78
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.share_tax, mod340.investment, 0.0)
79
#registros intracomunitarias
80
if mod340.intracomunitarias:
81
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.share_tax, mod340.intracomunitarias, 0.0)
85
def _total(self, cursor, user, ids, name, args, context=None):
89
for mod340 in self.browse(cursor, user, ids, context=context):
93
res[mod340.id] = reduce(lambda x, y: x + y.total, mod340.issued, 0.0)
96
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.total, mod340.received, 0.0)
99
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.total, mod340.investment, 0.0)
100
#registros intracomunitarias
101
if mod340.intracomunitarias:
102
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + y.total, mod340.intracomunitarias, 0.0)
106
def _numer_records(self, cursor, user, ids, name, args, context=None):
110
for mod340 in self.browse(cursor, user, ids, context=context):
114
res[mod340.id] = reduce(lambda x, y: x + 1, mod340.issued, 0)
117
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + 1, mod340.received, 0)
118
#registros investment
119
if mod340.investment:
120
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + 1, mod340.investment, 0)
121
#registros intracomunitarias
122
if mod340.intracomunitarias:
123
res[mod340.id] = res[mod340.id] + reduce(lambda x, y: x + 1, mod340.intracomunitarias, 0)
126
_name = 'l10n.es.aeat.mod340'
127
_description = 'Model 340'
129
'fiscalyear': fields.integer('Fiscal Year',size=4),
130
'type': fields.selection([(' ','Normal'),('C','Complementary'),('S','Replacement')], 'Type Statement'),
131
'type_support': fields.selection([('C','DVD'),('T','Telematics')],'Type Support'),
132
'config_id': fields.many2one('l10n.es.aeat.mod340.config','Config',required=True),
133
'company_id': fields.many2one('res.company', 'Company', required=True),
134
'vat_representative' : fields.char('Vat Legal Representative',size=9),
135
#'vat_company': fields.char('VAT', size=32, requiered=True),
136
'name_surname': fields.char('Name and Surname',size=40),
137
'phone': fields.char('Phone',size=9),
138
'phone_contact' : fields.char('Phone Contact',size=9),
139
'name_contact' : fields.char('Name And Surname Contact',size=40),
140
'period': fields.selection([
141
('1T','First quarter'),('2T','Second quarter'),('3T','Third quarter'),
142
('4T','Fourth quarter'),('01','January'),('02','February'),('03','March'),('04','April'),
143
('05','May'),('06','June'),('07','July'),('08','August'),('09','September'),('10','October'),
144
('11','November'),('12','December')
146
'issued': fields.one2many('l10n.es.aeat.mod340.issued','mod340_id','Invoices Issued'),
147
'received': fields.one2many('l10n.es.aeat.mod340.received','mod340_id','Invoices Received'),
148
'investment': fields.one2many('l10n.es.aeat.mod340.investment','mod340_id','Property Investment'),
149
'intracomunitarias': fields.one2many('l10n.es.aeat.mod340.intracomunitarias','mod340_id','Operations Intracomunitarias'),
150
'state': fields.selection([
151
('draft', 'Draft'),('open','Confirmed'),('cancel','Cancelled'),
153
], 'State', select=True),
154
'date_done': fields.date('Execution date', readonly=True),
155
'number_records' : fields.function(_numer_records, string="Total Records", method=True,
157
'total_taxable': fields.function(_total_taxable, string="Total Taxable", method=True,
159
'total_sharetax': fields.function(_total_share_tax, string="Total Share Tax", method=True,
161
'total': fields.function(_total, string="Total", method=True,
165
'fiscalyear': lambda *a: int(time.strftime('%Y')),
166
'type': lambda *args: ' ',
167
'type_support': lambda *args: 'T',
170
def set_done(self, cr, uid, id, *args):
171
self.write(cr,uid,id,{'date_done': time.strftime('%Y-%m-%d'),'state': 'done',})
172
wf_service = netsvc.LocalService("workflow")
173
wf_service.trg_validate(uid, 'l10n.es.aeat.mod340', id, 'done', cr)
176
#def onchange_company_id(self, cr, uid, ids, company_id):
179
# p = self.pool.get('res.company').browse(cr, uid, company_id)
180
# vat = p.partner_id.vat
181
# result = {'value':{'vat_company': vat}}
184
l10n_es_aeat_mod340()
186
class l10n_es_aeat_mod340_issued(osv.osv):
187
_name = 'l10n.es.aeat.mod340.issued'
188
_description = 'Invoices Issued'
190
'mod340_id': fields.many2one('l10n.es.aeat.mod340','Model 340',ondelete="cascade"),
191
'vat_declared' : fields.char('Vat Declared',size=9),
192
'vat_representative' : fields.char('Legal Representative',size=9),
193
'partner_name': fields.char('Name',size=40),
194
'cod_country' : fields.char('Code Country',size=2),
195
'key_country' : fields.selection([
196
('1','Nif'),('2','Nif/Iva'),('3','Passport'),('4','Dni'),('5','Fiscal Residence Certificate '),
198
],'Key Ident Country'),
199
'vat_country' : fields.char('Vat on Country of residence',size =17),
200
'key_book' : fields.selection([
201
('E','Invoice Issued'),('I','Property Investment'),('R','Invoices Recibed'),
202
('U','Intra-Community Transactions'),('F','Invoice Issued IGIC'),
203
('J','Property Investment IGIC'),('S','Invoices Recibed IGIC')
205
'key_operation' : fields.selection([
206
('A','Account move Invoices'),('B','Account move Receipt'),
207
('C','Invoces varius tax rates'),('D','Amendment Invoices'),
208
('F','Travel Agency'),('G','IGIC'),('H','Gold Investment'),
209
('I','ISP'),('J','Receipt'),('K','Error correction'),
210
('L','None of the above')
212
'invoice_date' : fields.date('Invoice Date'),
213
'operation_date' : fields.date('Operation Date'),
214
'rate' : fields.float('Rate',digits=(5,2)),
215
'taxable' : fields.float('Taxable',digits=(13,2)),
216
'share_tax' : fields.float('Share Tax',digits=(13,2)),
217
'total' : fields.float('Total Invoice',digits=(13,2)),
218
'taxable_cost' : fields.float('Taxable Cost',digits=(13,2)),
219
'number' : fields.char('Invoice Number',size=40),
220
'number_amendment' : fields.char('Number Invoice Amendment',size=40),
221
#HASTA AQUI COMUNES EL RESTO ESPECIFICOS
222
'number_invoices' : fields.integer('Invoices Accumulated',size = 4),
223
'number_records' : fields.integer('Number records accumulated',size = 4),
224
'iterval_ini' : fields.char('Initiation Interval',size=40),
225
'iterval_end' : fields.char('Order Interval',size=40),
226
'invoice_corrected' : fields.char('Invoice Corrected',size=40),
227
'charge' : fields.float('Charge Equivalence',digits=(5,2)),
228
'share_charge' : fields.float('Rate',digits=(5,2)),
230
l10n_es_aeat_mod340_issued()
232
class l10n_es_aeat_mod340_received(osv.osv):
233
_name = 'l10n.es.aeat.mod340.received'
234
_description = 'Invoices Received'
235
_inherit = 'l10n.es.aeat.mod340.issued'
236
l10n_es_aeat_mod340_received()
238
class l10n_es_aeat_mod340_investment(osv.osv):
239
_name = 'l10n.es.aeat.mod340.investment'
240
_description = 'Property Investment'
241
_inherit = 'l10n.es.aeat.mod340.issued'
242
l10n_es_aeat_mod340_investment()
244
class l10n_es_aeat_mod340_intracomunitarias(osv.osv):
245
_name = 'l10n.es.aeat.mod340.intracomunitarias'
246
_description = 'Operations Intracomunitarias'
247
_inherit = 'l10n.es.aeat.mod340.issued'
248
l10n_es_aeat_mod340_intracomunitarias()