41
41
_description = 'Generate XML'
43
43
def _get_amount_total(self,cr,uid,ids,name,args,context=None):
45
Returns withhold total amount
44
""" Returns withhold total amount
48
47
for xml in self.browse(cr,uid,ids,context):
54
53
def _get_amount_total_base(self,cr,uid,ids,name,args,context=None):
56
Returns base total amount
54
""" Returns base total amount
59
57
for xml in self.browse(cr,uid,ids,context):
91
89
def period_return(self,cr,uid,context=None):
93
Returns current period
90
""" Returns current period
95
92
period_obj = self.pool.get('account.period')
96
93
fecha = time.strftime('%m/%Y')
97
94
period_id = period_obj.search(cr,uid,[('code','=',fecha)])
103
100
def search_period(self,cr,uid,ids,period_id,context=None):
105
Returns islr lines associated with the period_id
101
""" Returns islr lines associated with the period_id
106
102
@param period_id: period associated with returned islr lines
108
104
if context is None:
110
106
res ={'value':{}}
118
114
def name_get(self, cr, uid, ids, context={}):
120
Returns id and name of all records
115
""" Returns id and name of all records
128
123
def action_anular1(self, cr, uid, ids, context={}):
130
Returns the document to draft status
124
""" Returns the document to draft status
132
126
return self.write(cr, uid, ids, {'state':'draft'})
134
128
def action_confirm1(self, cr, uid, ids, context={}):
136
Passes the document to state confirmed
129
""" Passes the document to state confirmed
138
131
return self.write(cr, uid, ids, {'state':'confirmed'})
140
133
def action_done1(self, cr, uid, ids, context={}):
142
Passes the document to state done
134
""" Passes the document to state done
144
136
root = self._xml(cr,uid,ids)
145
137
self._write_attachment(cr,uid,ids,root,context)
146
138
self.write(cr, uid, ids, {'state':'done'})
149
141
def _write_attachment(self, cr,uid,ids,root,context):
151
Codify the xml, to save it in the database and be able to
142
""" Codify the xml, to save it in the database and be able to
152
143
see it in the client as an attachment
153
144
@param root: data of the document in xml
155
146
fecha = time.strftime('%Y_%m_%d_%H%M%S')
156
147
name = 'ISLR_' + fecha +'.'+ 'xml'
157
148
self.pool.get('ir.attachment').create(cr, uid, {
166
157
self.log(cr, uid, ids[0], _("File XML %s generated.") % name)
168
159
def indent(self,elem, level=0):
160
""" Return indented text
171
161
@param level: number of spaces for indentation
172
162
@param elem: text to indentig
174
164
i = "\n" + level*" "
176
166
if not elem.text or not elem.text.strip():
189
179
def _xml(self, cr,uid,ids):
191
Transforms this document to XML format
180
""" Transforms this document to XML format
195
184
wh_brw = self.browse(cr,uid,id)
256
245
def onchange_partner_vat(self, cr, uid, ids, partner_id, context={}):
258
Changing the partner, the partner_vat field is updated.
246
""" Changing the partner, the partner_vat field is updated.
260
248
partner_brw = self.pool.get('res.partner').browse(cr,uid,partner_id)
261
249
return {'value' : {'partner_vat':partner_brw.vat[2:]}}
264
252
def onchange_code_perc(self, cr, uid, ids, rate_id, context={}):
266
Changing the rate of the islr, the porcent_rete and concept_code fields
253
""" Changing the rate of the islr, the porcent_rete and concept_code fields
269
256
rate_brw = self.pool.get('islr.rates').browse(cr,uid,rate_id)
270
257
return {'value' : {'porcent_rete':rate_brw.wh_perc,'concept_code':rate_brw.code}}