Merge lp:~vauxoo/openerp-venezuela-localization/l10n_ve_withholding_muni into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
- l10n_ve_withholding_muni
- Merge into 6.0-trunk
Proposed by
Javier Duran
Status: | Merged |
---|---|
Merged at revision: | 377 |
Proposed branch: | lp:~vauxoo/openerp-venezuela-localization/l10n_ve_withholding_muni |
Merge into: | lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk |
Diff against target: |
3328 lines (+2828/-171) 30 files modified
l10n_ve_withholding/__init__.py (+1/-0) l10n_ve_withholding/invoice.py (+173/-0) l10n_ve_withholding_iva/invoice.py (+3/-140) l10n_ve_withholding_iva/partner_view.xml (+2/-2) l10n_ve_withholding_iva/wh_iva.py (+9/-9) l10n_ve_withholding_iva/wh_iva_view.xml (+20/-20) l10n_ve_withholding_muni/__init__.py (+37/-0) l10n_ve_withholding_muni/__openerp__.py (+51/-0) l10n_ve_withholding_muni/__terp__.py (+59/-0) l10n_ve_withholding_muni/account_invoice_view.xml (+65/-0) l10n_ve_withholding_muni/invoice.py (+93/-0) l10n_ve_withholding_muni/partner.py (+59/-0) l10n_ve_withholding_muni/partner_view.xml (+33/-0) l10n_ve_withholding_muni/report/__init__.py (+32/-0) l10n_ve_withholding_muni/report/tiny_sxw2rml/__init__.py (+29/-0) l10n_ve_withholding_muni/report/tiny_sxw2rml/normalized_oo2rml.xsl (+681/-0) l10n_ve_withholding_muni/report/tiny_sxw2rml/tiny_sxw2rml.py (+365/-0) l10n_ve_withholding_muni/report/wh_muni_report.py (+71/-0) l10n_ve_withholding_muni/report/wh_muni_report.rml (+261/-0) l10n_ve_withholding_muni/retencion_munici_wizard.xml (+16/-0) l10n_ve_withholding_muni/security/ir.model.access.csv (+5/-0) l10n_ve_withholding_muni/security/wh_muni_security.xml (+13/-0) l10n_ve_withholding_muni/wh_muni.py (+323/-0) l10n_ve_withholding_muni/wh_muni_report.xml (+15/-0) l10n_ve_withholding_muni/wh_muni_sequence.xml (+26/-0) l10n_ve_withholding_muni/wh_muni_view.xml (+207/-0) l10n_ve_withholding_muni/wizard/__init__.py (+37/-0) l10n_ve_withholding_muni/wizard/out.txt (+1/-0) l10n_ve_withholding_muni/wizard/prueba1.py (+9/-0) l10n_ve_withholding_muni/wizard/wizard_ret_munici_xml.py (+132/-0) |
To merge this branch: | bzr merge lp:~vauxoo/openerp-venezuela-localization/l10n_ve_withholding_muni |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Javier Duran (community) | Approve | ||
Review via email: mp+76624@code.launchpad.net |
Commit message
[MERGE] Agregando modulo de retención de impuesto municipales
Description of the change
Se agrega el proceso de retención de impuesto municipales
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'l10n_ve_withholding/__init__.py' |
2 | --- l10n_ve_withholding/__init__.py 2011-05-11 16:44:18 +0000 |
3 | +++ l10n_ve_withholding/__init__.py 2011-09-22 17:22:23 +0000 |
4 | @@ -22,5 +22,6 @@ |
5 | import account |
6 | import l10n_ve_withholding |
7 | import account_move_line |
8 | +import invoice |
9 | |
10 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
11 | |
12 | === added file 'l10n_ve_withholding/invoice.py' |
13 | --- l10n_ve_withholding/invoice.py 1970-01-01 00:00:00 +0000 |
14 | +++ l10n_ve_withholding/invoice.py 2011-09-22 17:22:23 +0000 |
15 | @@ -0,0 +1,173 @@ |
16 | +# -*- coding: utf-8 -*- |
17 | +############################################################################## |
18 | +# |
19 | +# |
20 | +# |
21 | +# |
22 | +# This program is free software: you can redistribute it and/or modify |
23 | +# it under the terms of the GNU Affero General Public License as |
24 | +# published by the Free Software Foundation, either version 3 of the |
25 | +# License, or (at your option) any later version. |
26 | +# |
27 | +# This program is distributed in the hope that it will be useful, |
28 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
29 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
30 | +# GNU Affero General Public License for more details. |
31 | +# |
32 | +# You should have received a copy of the GNU Affero General Public License |
33 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
34 | +# |
35 | +############################################################################## |
36 | + |
37 | +import time |
38 | +from osv import fields, osv |
39 | +import decimal_precision as dp |
40 | + |
41 | + |
42 | + |
43 | +class account_invoice(osv.osv): |
44 | + _inherit = 'account.invoice' |
45 | + |
46 | + def ret_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, date, name, context=None): |
47 | + if context is None: |
48 | + context = {} |
49 | + #TODO check if we can use different period for payment and the writeoff line |
50 | + assert len(ids)==1, "Can only pay one invoice at a time" |
51 | + invoice = self.browse(cr, uid, ids[0]) |
52 | + src_account_id = invoice.account_id.id |
53 | + # Take the seq as name for move |
54 | + types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} |
55 | + direction = types[invoice.type] |
56 | + l1 = { |
57 | + 'debit': direction * pay_amount>0 and direction * pay_amount, |
58 | + 'credit': direction * pay_amount<0 and - direction * pay_amount, |
59 | + 'account_id': src_account_id, |
60 | + 'partner_id': invoice.partner_id.id, |
61 | + 'ref':invoice.number, |
62 | + 'date': date, |
63 | + 'currency_id': False, |
64 | + } |
65 | + l2 = { |
66 | + 'debit': direction * pay_amount<0 and - direction * pay_amount, |
67 | + 'credit': direction * pay_amount>0 and direction * pay_amount, |
68 | + 'account_id': pay_account_id, |
69 | + 'partner_id': invoice.partner_id.id, |
70 | + 'ref':invoice.number, |
71 | + 'date': date, |
72 | + 'currency_id': False, |
73 | + } |
74 | + |
75 | + l1['name'] = name |
76 | + l2['name'] = name |
77 | + |
78 | + lines = [(0, 0, l1), (0, 0, l2)] |
79 | + move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} |
80 | + move_id = self.pool.get('account.move').create(cr, uid, move, context=context) |
81 | + |
82 | + self.pool.get('account.move').post(cr, uid, [move_id]) |
83 | + |
84 | + line_ids = [] |
85 | + total = 0.0 |
86 | + line = self.pool.get('account.move.line') |
87 | + cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')') |
88 | + lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) |
89 | + for l in lines+invoice.payment_ids: |
90 | + if l.account_id.id==src_account_id: |
91 | + line_ids.append(l.id) |
92 | + total += (l.debit or 0.0) - (l.credit or 0.0) |
93 | + if (not round(total,self.pool.get('decimal.precision').precision_get(cr, uid, 'Withhold'))) or writeoff_acc_id: |
94 | + self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context) |
95 | + else: |
96 | + self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context) |
97 | + |
98 | + # Update the stored value (fields.function), so we write to trigger recompute |
99 | + self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context) |
100 | + return {'move_id': move_id} |
101 | + |
102 | + |
103 | + def check_tax_lines(self, cr, uid, inv, compute_taxes, ait_obj): |
104 | + if not inv.tax_line: |
105 | + for tax in compute_taxes.values(): |
106 | + ait_obj.create(cr, uid, tax) |
107 | + else: |
108 | + tax_key = [] |
109 | + for tax in inv.tax_line: |
110 | + if tax.manual: |
111 | + continue |
112 | +# key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id) |
113 | + #### group by tax id #### |
114 | + key = (tax.tax_id.id) |
115 | + tax_key.append(key) |
116 | + if not key in compute_taxes: |
117 | + raise osv.except_osv(_('Warning !'), _('Global taxes defined, but are not in invoice lines !')) |
118 | + base = compute_taxes[key]['base'] |
119 | + if abs(base - tax.base) > inv.company_id.currency_id.rounding: |
120 | + raise osv.except_osv(_('Warning !'), _('Tax base different !\nClick on compute to update tax base')) |
121 | + for key in compute_taxes: |
122 | + if not key in tax_key: |
123 | + raise osv.except_osv(_('Warning !'), _('Taxes missing !')) |
124 | + |
125 | +account_invoice() |
126 | + |
127 | + |
128 | + |
129 | + |
130 | +class account_invoice_tax(osv.osv): |
131 | + _inherit = 'account.invoice.tax' |
132 | + _columns = { |
133 | + 'tax_id': fields.many2one('account.tax', 'Tax', required=True, ondelete='set null', help="Tax"), |
134 | + } |
135 | + |
136 | + def compute(self, cr, uid, invoice_id, context=None): |
137 | + tax_grouped = {} |
138 | + tax_obj = self.pool.get('account.tax') |
139 | + cur_obj = self.pool.get('res.currency') |
140 | + inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) |
141 | + cur = inv.currency_id |
142 | + company_currency = inv.company_id.currency_id.id |
143 | + |
144 | + for line in inv.invoice_line: |
145 | + for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id)['taxes']: |
146 | + val={} |
147 | + val['invoice_id'] = inv.id |
148 | + val['name'] = tax['name'] |
149 | + val['amount'] = tax['amount'] |
150 | + val['manual'] = False |
151 | + val['sequence'] = tax['sequence'] |
152 | + val['base'] = tax['price_unit'] * line['quantity'] |
153 | + #### add tax id #### |
154 | + val['tax_id'] = tax['id'] |
155 | + |
156 | + if inv.type in ('out_invoice','in_invoice'): |
157 | + val['base_code_id'] = tax['base_code_id'] |
158 | + val['tax_code_id'] = tax['tax_code_id'] |
159 | + val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
160 | + val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
161 | + val['account_id'] = tax['account_collected_id'] or line.account_id.id |
162 | + else: |
163 | + val['base_code_id'] = tax['ref_base_code_id'] |
164 | + val['tax_code_id'] = tax['ref_tax_code_id'] |
165 | + val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
166 | + val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
167 | + val['account_id'] = tax['account_paid_id'] or line.account_id.id |
168 | + |
169 | +# key = (val['tax_code_id'], val['base_code_id'], val['account_id']) |
170 | + #### group by tax id #### |
171 | + key = (val['tax_id']) |
172 | + if not key in tax_grouped: |
173 | + tax_grouped[key] = val |
174 | + else: |
175 | + tax_grouped[key]['amount'] += val['amount'] |
176 | + tax_grouped[key]['base'] += val['base'] |
177 | + tax_grouped[key]['base_amount'] += val['base_amount'] |
178 | + tax_grouped[key]['tax_amount'] += val['tax_amount'] |
179 | + |
180 | + for t in tax_grouped.values(): |
181 | + t['base'] = cur_obj.round(cr, uid, cur, t['base']) |
182 | + t['amount'] = cur_obj.round(cr, uid, cur, t['amount']) |
183 | + t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount']) |
184 | + t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount']) |
185 | + return tax_grouped |
186 | + |
187 | + |
188 | +account_invoice_tax() |
189 | |
190 | === modified file 'l10n_ve_withholding_iva/invoice.py' |
191 | --- l10n_ve_withholding_iva/invoice.py 2011-06-14 17:06:20 +0000 |
192 | +++ l10n_ve_withholding_iva/invoice.py 2011-09-22 17:22:23 +0000 |
193 | @@ -131,16 +131,14 @@ |
194 | |
195 | return lines |
196 | |
197 | - |
198 | def wh_iva_line_create(self, cr, uid, inv): |
199 | return (0, False, { |
200 | 'name': inv.name or inv.number, |
201 | 'invoice_id': inv.id, |
202 | }) |
203 | - |
204 | |
205 | def action_wh_iva_create(self, cr, uid, ids, *args): |
206 | - wh_iva_obj = self.pool.get('account.wh.iva') |
207 | + wh_iva_obj = self.pool.get('account.wh.iva') |
208 | for inv in self.browse(cr, uid, ids): |
209 | if inv.wh_iva_id: |
210 | raise osv.except_osv('Invalid Action !', 'Withhold Invoice !') |
211 | @@ -163,8 +161,7 @@ |
212 | ret_id = wh_iva_obj.create(cr, uid, ret_iva) |
213 | self.write(cr, uid, [inv.id], {'wh_iva_id':ret_id}) |
214 | return True |
215 | - |
216 | - |
217 | + |
218 | def button_reset_taxes_ret(self, cr, uid, ids, context=None): |
219 | if not context: |
220 | context = {} |
221 | @@ -178,156 +175,22 @@ |
222 | |
223 | return True |
224 | |
225 | - |
226 | - |
227 | - def ret_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, date, name, context=None): |
228 | - if context is None: |
229 | - context = {} |
230 | - #TODO check if we can use different period for payment and the writeoff line |
231 | - assert len(ids)==1, "Can only pay one invoice at a time" |
232 | - invoice = self.browse(cr, uid, ids[0]) |
233 | - src_account_id = invoice.account_id.id |
234 | - # Take the seq as name for move |
235 | - types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} |
236 | - direction = types[invoice.type] |
237 | - l1 = { |
238 | - 'debit': direction * pay_amount>0 and direction * pay_amount, |
239 | - 'credit': direction * pay_amount<0 and - direction * pay_amount, |
240 | - 'account_id': src_account_id, |
241 | - 'partner_id': invoice.partner_id.id, |
242 | - 'ref':invoice.number, |
243 | - 'date': date, |
244 | - 'currency_id': False, |
245 | - } |
246 | - l2 = { |
247 | - 'debit': direction * pay_amount<0 and - direction * pay_amount, |
248 | - 'credit': direction * pay_amount>0 and direction * pay_amount, |
249 | - 'account_id': pay_account_id, |
250 | - 'partner_id': invoice.partner_id.id, |
251 | - 'ref':invoice.number, |
252 | - 'date': date, |
253 | - 'currency_id': False, |
254 | - } |
255 | - |
256 | - l1['name'] = name |
257 | - l2['name'] = name |
258 | - |
259 | - lines = [(0, 0, l1), (0, 0, l2)] |
260 | - move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} |
261 | - move_id = self.pool.get('account.move').create(cr, uid, move, context=context) |
262 | - |
263 | - self.pool.get('account.move').post(cr, uid, [move_id]) |
264 | - |
265 | - line_ids = [] |
266 | - total = 0.0 |
267 | - line = self.pool.get('account.move.line') |
268 | - cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')') |
269 | - lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) |
270 | - for l in lines+invoice.payment_ids: |
271 | - if l.account_id.id==src_account_id: |
272 | - line_ids.append(l.id) |
273 | - total += (l.debit or 0.0) - (l.credit or 0.0) |
274 | - if (not round(total,self.pool.get('decimal.precision').precision_get(cr, uid, 'Withhold'))) or writeoff_acc_id: |
275 | - self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context) |
276 | - else: |
277 | - self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context) |
278 | - |
279 | - # Update the stored value (fields.function), so we write to trigger recompute |
280 | - self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context) |
281 | - return {'move_id': move_id} |
282 | - |
283 | - |
284 | def button_reset_taxes(self, cr, uid, ids, context=None): |
285 | super(account_invoice, self).button_reset_taxes(cr, uid, ids, context) |
286 | self.button_reset_taxes_ret(cr, uid, ids, context) |
287 | |
288 | return True |
289 | |
290 | - |
291 | - def check_tax_lines(self, cr, uid, inv, compute_taxes, ait_obj): |
292 | - if not inv.tax_line: |
293 | - for tax in compute_taxes.values(): |
294 | - ait_obj.create(cr, uid, tax) |
295 | - else: |
296 | - tax_key = [] |
297 | - for tax in inv.tax_line: |
298 | - if tax.manual: |
299 | - continue |
300 | -# key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id) |
301 | - #### group by tax id #### |
302 | - key = (tax.tax_id.id) |
303 | - tax_key.append(key) |
304 | - if not key in compute_taxes: |
305 | - raise osv.except_osv(_('Warning !'), _('Global taxes defined, but are not in invoice lines !')) |
306 | - base = compute_taxes[key]['base'] |
307 | - if abs(base - tax.base) > inv.company_id.currency_id.rounding: |
308 | - raise osv.except_osv(_('Warning !'), _('Tax base different !\nClick on compute to update tax base')) |
309 | - for key in compute_taxes: |
310 | - if not key in tax_key: |
311 | - raise osv.except_osv(_('Warning !'), _('Taxes missing !')) |
312 | account_invoice() |
313 | |
314 | |
315 | |
316 | - |
317 | class account_invoice_tax(osv.osv): |
318 | _inherit = 'account.invoice.tax' |
319 | _columns = { |
320 | 'amount_ret': fields.float('Withholding amount', digits_compute= dp.get_precision('Withhold'), help="Withholding vat amount"), |
321 | - 'base_ret': fields.float('Amount', digits_compute= dp.get_precision('Withhold'), help="Amount without tax"), |
322 | - 'tax_id': fields.many2one('account.tax', 'Tax', required=True, ondelete='set null', help="Tax"), |
323 | + 'base_ret': fields.float('Amount', digits_compute= dp.get_precision('Withhold'), help="Amount without tax"), |
324 | } |
325 | - |
326 | - def compute(self, cr, uid, invoice_id, context=None): |
327 | - tax_grouped = {} |
328 | - tax_obj = self.pool.get('account.tax') |
329 | - cur_obj = self.pool.get('res.currency') |
330 | - inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) |
331 | - cur = inv.currency_id |
332 | - company_currency = inv.company_id.currency_id.id |
333 | - |
334 | - for line in inv.invoice_line: |
335 | - for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id)['taxes']: |
336 | - val={} |
337 | - val['invoice_id'] = inv.id |
338 | - val['name'] = tax['name'] |
339 | - val['amount'] = tax['amount'] |
340 | - val['manual'] = False |
341 | - val['sequence'] = tax['sequence'] |
342 | - val['base'] = tax['price_unit'] * line['quantity'] |
343 | - #### add tax id #### |
344 | - val['tax_id'] = tax['id'] |
345 | - |
346 | - if inv.type in ('out_invoice','in_invoice'): |
347 | - val['base_code_id'] = tax['base_code_id'] |
348 | - val['tax_code_id'] = tax['tax_code_id'] |
349 | - val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
350 | - val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
351 | - val['account_id'] = tax['account_collected_id'] or line.account_id.id |
352 | - else: |
353 | - val['base_code_id'] = tax['ref_base_code_id'] |
354 | - val['tax_code_id'] = tax['ref_tax_code_id'] |
355 | - val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
356 | - val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) |
357 | - val['account_id'] = tax['account_paid_id'] or line.account_id.id |
358 | - |
359 | -# key = (val['tax_code_id'], val['base_code_id'], val['account_id']) |
360 | - #### group by tax id #### |
361 | - key = (val['tax_id']) |
362 | - if not key in tax_grouped: |
363 | - tax_grouped[key] = val |
364 | - else: |
365 | - tax_grouped[key]['amount'] += val['amount'] |
366 | - tax_grouped[key]['base'] += val['base'] |
367 | - tax_grouped[key]['base_amount'] += val['base_amount'] |
368 | - tax_grouped[key]['tax_amount'] += val['tax_amount'] |
369 | - |
370 | - for t in tax_grouped.values(): |
371 | - t['base'] = cur_obj.round(cr, uid, cur, t['base']) |
372 | - t['amount'] = cur_obj.round(cr, uid, cur, t['amount']) |
373 | - t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount']) |
374 | - t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount']) |
375 | - return tax_grouped |
376 | |
377 | |
378 | def compute_amount_ret(self, cr, uid, invoice_id, context={}): |
379 | |
380 | === modified file 'l10n_ve_withholding_iva/partner_view.xml' |
381 | --- l10n_ve_withholding_iva/partner_view.xml 2011-05-11 16:46:27 +0000 |
382 | +++ l10n_ve_withholding_iva/partner_view.xml 2011-09-22 17:22:23 +0000 |
383 | @@ -18,7 +18,7 @@ |
384 | <field name="arch" type="xml"> |
385 | <page string="Withholdings" position="inside"> |
386 | <notebook> |
387 | - <page string="Withholdings Vat"> |
388 | + <page string="Withholdings Vat"> |
389 | <group col="4" colspan="2"> |
390 | <field name="wh_iva_agent"/> |
391 | <field name="wh_iva_rate"/> |
392 | @@ -26,7 +26,7 @@ |
393 | <field name="property_wh_iva_receivable"/> |
394 | </group> |
395 | </page> |
396 | - </notebook> |
397 | + </notebook> |
398 | </page> |
399 | </field> |
400 | </record> |
401 | |
402 | === modified file 'l10n_ve_withholding_iva/wh_iva.py' |
403 | --- l10n_ve_withholding_iva/wh_iva.py 2011-05-19 20:32:34 +0000 |
404 | +++ l10n_ve_withholding_iva/wh_iva.py 2011-09-22 17:22:23 +0000 |
405 | @@ -67,18 +67,18 @@ |
406 | _name = "account.wh.iva" |
407 | _description = "Withholding Vat" |
408 | _columns = { |
409 | - 'name': fields.char('Description', size=64, select=True,readonly=True, states={'draft':[('readonly',False)]}, required=True, help="Description of withholding"), |
410 | + 'name': fields.char('Description', size=64, readonly=True, states={'draft':[('readonly',False)]}, required=True, help="Description of withholding"), |
411 | 'code': fields.char('Code', size=32, readonly=True, states={'draft':[('readonly',False)]}, help="Withholding reference"), |
412 | 'number': fields.char('Number', size=32, readonly=True, states={'draft':[('readonly',False)]}, help="Withholding number"), |
413 | 'type': fields.selection([ |
414 | ('out_invoice','Customer Invoice'), |
415 | ('in_invoice','Supplier Invoice'), |
416 | - ],'Type', readonly=True, select=True, help="Withholding type"), |
417 | + ],'Type', readonly=True, help="Withholding type"), |
418 | 'state': fields.selection([ |
419 | ('draft','Draft'), |
420 | ('done','Done'), |
421 | ('cancel','Cancelled') |
422 | - ],'State', select=True, readonly=True, help="Withholding State"), |
423 | + ],'State', readonly=True, help="Withholding State"), |
424 | 'date_ret': fields.date('Withholding date', readonly=True, states={'draft':[('readonly',False)]}, help="Keep empty to use the current date"), |
425 | 'date': fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}, help="Date"), |
426 | 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], readonly=True, states={'draft':[('readonly',False)]}, help="Keep empty to use the period of the validation(Withholding date) date."), |
427 | @@ -88,7 +88,7 @@ |
428 | 'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}, help="Journal entry"), |
429 | 'company_id': fields.many2one('res.company', 'Company', required=True, help="Company"), |
430 | 'retention_line': fields.one2many('account.wh.iva.line', 'retention_id', 'Withholding vat lines', readonly=True, states={'draft':[('readonly',False)]}, help="Withholding vat lines"), |
431 | - 'tot_amount_base_wh': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount without tax"), |
432 | + 'tot_amount_base_wh': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount without tax"), |
433 | 'tot_amount_tax_wh': fields.float('Amount wh. tax vat', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount withholding tax vat"), |
434 | 'amount_base_ret': fields.function(_amount_ret_all, method=True, digits_compute= dp.get_precision('Withhold'), string='Compute amount', multi='all', help="Compute amount without tax"), |
435 | 'total_tax_ret': fields.function(_amount_ret_all, method=True, digits_compute= dp.get_precision('Withhold'), string='Compute amount wh. tax vat', multi='all', help="compute amount withholding tax vat"), |
436 | @@ -175,7 +175,7 @@ |
437 | period_id = period_ids[0] |
438 | |
439 | if ret.retention_line: |
440 | - for line in ret.retention_line: |
441 | + for line in ret.retention_line: |
442 | writeoff_account_id = False |
443 | writeoff_journal_id = False |
444 | amount = line.amount_tax_wh |
445 | @@ -224,7 +224,7 @@ |
446 | inv_str+= '%s'% '\n'+line.invoice_id.name |
447 | |
448 | if inv_str: |
449 | - raise osv.except_osv('Factura(s) No Perteneciente(s) !',"La(s) siguientes factura(s) no pertenecen al partner del comprobante: %s " % (inv_str,)) |
450 | + raise osv.except_osv('Incorrect Invoices !',"The following invoices are not the selected partner: %s " % (inv_str,)) |
451 | |
452 | return True |
453 | |
454 | @@ -245,7 +245,7 @@ |
455 | inv_str+= '%s'% '\n'+inv.name |
456 | |
457 | if inv_str: |
458 | - raise osv.except_osv('Factura(s) No Perteneciente(s) !',"La(s) siguientes factura(s) no pertenecen al partner del comprobante: %s " % (inv_str,)) |
459 | + raise osv.except_osv('Incorrect Invoices !',"The following invoices are not the selected partner: %s " % (inv_str,)) |
460 | |
461 | return True |
462 | |
463 | @@ -331,8 +331,8 @@ |
464 | _description = "Withholding vat line" |
465 | _columns = { |
466 | 'name': fields.char('Description', size=64, required=True, help="Withholding line Description"), |
467 | - 'retention_id': fields.many2one('account.wh.iva', 'Withholding vat', ondelete='cascade', select=True, help="Withholding vat"), |
468 | - 'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True, ondelete='set null', select=True, help="Withholding invoice"), |
469 | + 'retention_id': fields.many2one('account.wh.iva', 'Withholding vat', ondelete='cascade', help="Withholding vat"), |
470 | + 'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True, ondelete='set null', help="Withholding invoice"), |
471 | 'tax_line': fields.function(_compute_tax_lines, method=True, relation='account.invoice.tax', type="one2many", string='Taxes', help="Invoice taxes"), |
472 | 'amount_tax_ret': fields.function(_amount_all, method=True, digits=(16,4), string='Wh. tax amount', multi='all', help="Withholding tax amount"), |
473 | 'base_ret': fields.function(_amount_all, method=True, digits=(16,4), string='Wh. amount', multi='all', help="Withholding without tax amount"), |
474 | |
475 | === modified file 'l10n_ve_withholding_iva/wh_iva_view.xml' |
476 | --- l10n_ve_withholding_iva/wh_iva_view.xml 2011-08-21 22:33:37 +0000 |
477 | +++ l10n_ve_withholding_iva/wh_iva_view.xml 2011-09-22 17:22:23 +0000 |
478 | @@ -18,9 +18,9 @@ |
479 | <field name="invoice_id" on_change="invoice_id_change(invoice_id)" domain="[('state', '=', 'open'), ('wh_iva', '=', False), ('partner_id','=',parent.partner_id)]"/> |
480 | <!-- <field name="retention_rate" />--> |
481 | <field name="base_ret"/> |
482 | - <field name="amount_tax_ret"/> |
483 | + <field name="amount_tax_ret"/> |
484 | <field name="amount_base_wh"/> |
485 | - <field name="amount_tax_wh"/> |
486 | + <field name="amount_tax_wh"/> |
487 | <field name="move_id"/> |
488 | </tree> |
489 | </field> |
490 | @@ -55,7 +55,7 @@ |
491 | <field name="amount_tax_ret"/> |
492 | <field name="base_ret"/> |
493 | <field name="amount_base_wh"/> |
494 | - <field name="amount_tax_wh"/> |
495 | + <field name="amount_tax_wh"/> |
496 | </group> |
497 | </page> |
498 | </notebook> |
499 | @@ -64,11 +64,11 @@ |
500 | </record> |
501 | |
502 | |
503 | - <!-- |
504 | + <!-- |
505 | ===================================================== |
506 | Withholding vat |
507 | ===================================================== |
508 | - --> |
509 | + --> |
510 | |
511 | |
512 | <record id="view_wh_iva_filter" model="ir.ui.view"> |
513 | @@ -99,8 +99,8 @@ |
514 | </search> |
515 | </field> |
516 | </record> |
517 | - |
518 | - |
519 | + |
520 | + |
521 | <record id="view_wh_iva_tree" model="ir.ui.view"> |
522 | <field name="name">account.wh.iva.tree</field> |
523 | <field name="model">account.wh.iva</field> |
524 | @@ -132,27 +132,27 @@ |
525 | <form string="Withholding Vat"> |
526 | <group colspan="4" col="6"> |
527 | <field name="journal_id" select="2" domain="[('type','=','iva_purchase')]"/> |
528 | - <field name="type" select="2"/> |
529 | - <field name="code" select="1"/> |
530 | - <field name="partner_id" on_change="onchange_partner_id(type,partner_id)" select="1" domain="[('supplier','=',True)]"/> |
531 | - <field name="currency_id" /> |
532 | - <field name="date_ret" /> |
533 | + <field name="type"/> |
534 | + <field name="code"/> |
535 | + <field name="partner_id" on_change="onchange_partner_id(type,partner_id)" domain="[('supplier','=',True)]"/> |
536 | + <field name="currency_id"/> |
537 | + <field name="date_ret"/> |
538 | <field domain="[('type','<>','view'), ('company_id', '=', company_id)]" name="account_id"/> |
539 | - <field name="name" select="2"/> |
540 | + <field name="name"/> |
541 | <field name="period_id"/> |
542 | - <field name="number" select="1" attrs="{'readonly':[('type','=','in_invoice')],'required':[('type','in',['out_invoice','out_refund'])]}"/> |
543 | + <field name="number" attrs="{'readonly':[('type','=','in_invoice')],'required':[('type','in',['out_invoice','out_refund'])]}"/> |
544 | <field name="date" /> |
545 | </group> |
546 | <notebook colspan="4"> |
547 | <page string="Withholding"> |
548 | <field colspan="4" name="retention_line" nolabel="1" widget="one2many_list"/> |
549 | <group col="4" colspan="2"> |
550 | - <field name="state" select="2"/> |
551 | - <button name="wh_iva_done" states="draft" string="Realizar" icon="gtk-execute"/> |
552 | + <field name="state"/> |
553 | + <button name="wh_iva_done" states="draft" string="Done" icon="gtk-execute"/> |
554 | </group> |
555 | <group col="2" colspan="2"> |
556 | - <button colspan="2" name="compute_amount_wh" states="draft" string="Compute Withholding Vat" type="object" icon="terp-stock_format-scientific"/> |
557 | - <field name="amount_base_ret"/> |
558 | + <button colspan="2" name="compute_amount_wh" states="draft" string="Compute Withholding Vat" type="object" icon="terp-stock_format-scientific"/> |
559 | + <field name="amount_base_ret"/> |
560 | <field name="total_tax_ret"/> |
561 | <field name="tot_amount_base_wh"/> |
562 | <field name="tot_amount_tax_wh"/> |
563 | @@ -219,7 +219,7 @@ |
564 | <field name="domain">[('type','=','out_invoice')]</field> |
565 | <field name="context">{'type':'out_invoice'}</field> |
566 | <field name="search_view_id" ref="view_wh_iva_filter"/> |
567 | - <field name="help">With Customer Withholding Vat you can create and manage document withholding issued to your customers. OpenERP can also generate document withholding automatically from invoices. For retention must add the invoices, process them and then validate the document.</field> |
568 | + <field name="help">With Customer Withholding Vat you can create and manage document withholding issued to your customers. OpenERP can also generate document withholding automatically from invoices. For retention must add the invoices, process them and then validate the document.</field> |
569 | </record> |
570 | <record model="ir.actions.act_window.view" id="act_wv_account_wh_iva_customer_tree"> |
571 | <field name="sequence" eval="10"/> |
572 | @@ -236,7 +236,7 @@ |
573 | |
574 | <menuitem |
575 | id="menu_action_account_wh_iva_customer" |
576 | - name="Withholding vat customer" |
577 | + name="Withholding vat customer" |
578 | parent="l10n_ve_withholding.menu_wh_customer" |
579 | action="action_account_wh_iva_customer"/> |
580 | |
581 | |
582 | === added directory 'l10n_ve_withholding_muni' |
583 | === added file 'l10n_ve_withholding_muni/__init__.py' |
584 | --- l10n_ve_withholding_muni/__init__.py 1970-01-01 00:00:00 +0000 |
585 | +++ l10n_ve_withholding_muni/__init__.py 2011-09-22 17:22:23 +0000 |
586 | @@ -0,0 +1,37 @@ |
587 | +# -*- encoding: utf-8 -*- |
588 | +############################################################################## |
589 | +# |
590 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
591 | +# Javier Duran <javieredm@gmail.com> |
592 | +# |
593 | +# |
594 | +# WARNING: This program as such is intended to be used by professional |
595 | +# programmers who take the whole responsability of assessing all potential |
596 | +# consequences resulting from its eventual inadequacies and bugs |
597 | +# End users who are looking for a ready-to-use solution with commercial |
598 | +# garantees and support are strongly adviced to contract a Free Software |
599 | +# Service Company |
600 | +# |
601 | +# This program is Free Software; you can redistribute it and/or |
602 | +# modify it under the terms of the GNU General Public License |
603 | +# as published by the Free Software Foundation; either version 2 |
604 | +# of the License, or (at your option) any later version. |
605 | +# |
606 | +# This program is distributed in the hope that it will be useful, |
607 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
608 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
609 | +# GNU General Public License for more details. |
610 | +# |
611 | +# You should have received a copy of the GNU General Public License |
612 | +# along with this program; if not, write to the Free Software |
613 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
614 | +# |
615 | +############################################################################## |
616 | + |
617 | + |
618 | +import wh_muni |
619 | +import invoice |
620 | +import partner |
621 | +import report |
622 | +#import wizard |
623 | + |
624 | |
625 | === added file 'l10n_ve_withholding_muni/__openerp__.py' |
626 | --- l10n_ve_withholding_muni/__openerp__.py 1970-01-01 00:00:00 +0000 |
627 | +++ l10n_ve_withholding_muni/__openerp__.py 2011-09-22 17:22:23 +0000 |
628 | @@ -0,0 +1,51 @@ |
629 | +# -*- coding: utf-8 -*- |
630 | +############################################################################## |
631 | +# |
632 | +# OpenERP, Open Source Management Solution |
633 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
634 | +# This module was developen by Vauxoo Team: |
635 | +# Coded by: javier@vauxoo.com |
636 | +# |
637 | +# |
638 | +# This program is free software: you can redistribute it and/or modify |
639 | +# it under the terms of the GNU Affero General Public License as |
640 | +# published by the Free Software Foundation, either version 3 of the |
641 | +# License, or (at your option) any later version. |
642 | +# |
643 | +# This program is distributed in the hope that it will be useful, |
644 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
645 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
646 | +# GNU Affero General Public License for more details. |
647 | +# |
648 | +# You should have received a copy of the GNU Affero General Public License |
649 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
650 | +# |
651 | +############################################################################## |
652 | +{ |
653 | + "name" : "Local Withholding Venezuelan laws", |
654 | + "version" : "0.5", |
655 | + "author" : "Vauxoo", |
656 | + "website" : "http://vauxoo.com", |
657 | + "category": 'Generic Modules/Accounting', |
658 | + "description": """Management local withholding for Venezuelan tax laws |
659 | + """, |
660 | + 'init_xml': [], |
661 | + "depends" : ["l10n_ve_withholding"], |
662 | + 'update_xml': [ |
663 | + 'security/wh_muni_security.xml', |
664 | + 'security/ir.model.access.csv', |
665 | + 'account_invoice_view.xml', |
666 | + 'partner_view.xml', |
667 | + 'wh_muni_view.xml', |
668 | + "wh_muni_sequence.xml", |
669 | + "wh_muni_report.xml", |
670 | +# "account_workflow.xml", |
671 | + ], |
672 | + 'demo_xml': [], |
673 | + 'test': [], |
674 | + 'installable': True, |
675 | + 'active': False, |
676 | +} |
677 | + |
678 | + |
679 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
680 | |
681 | === added file 'l10n_ve_withholding_muni/__terp__.py' |
682 | --- l10n_ve_withholding_muni/__terp__.py 1970-01-01 00:00:00 +0000 |
683 | +++ l10n_ve_withholding_muni/__terp__.py 2011-09-22 17:22:23 +0000 |
684 | @@ -0,0 +1,59 @@ |
685 | +# -*- encoding: utf-8 -*- |
686 | +############################################################################## |
687 | +# |
688 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
689 | +# Javier Duran <javier.duran@netquatro.com> |
690 | +# |
691 | +# |
692 | +# WARNING: This program as such is intended to be used by professional |
693 | +# programmers who take the whole responsability of assessing all potential |
694 | +# consequences resulting from its eventual inadequacies and bugs |
695 | +# End users who are looking for a ready-to-use solution with commercial |
696 | +# garantees and support are strongly adviced to contract a Free Software |
697 | +# Service Company |
698 | +# |
699 | +# This program is Free Software; you can redistribute it and/or |
700 | +# modify it under the terms of the GNU General Public License |
701 | +# as published by the Free Software Foundation; either version 2 |
702 | +# of the License, or (at your option) any later version. |
703 | +# |
704 | +# This program is distributed in the hope that it will be useful, |
705 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
706 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
707 | +# GNU General Public License for more details. |
708 | +# |
709 | +# You should have received a copy of the GNU General Public License |
710 | +# along with this program; if not, write to the Free Software |
711 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
712 | +# |
713 | +############################################################################## |
714 | + |
715 | +{ |
716 | + "name" : "Retenciones Municipales", |
717 | + "version" : "0.1", |
718 | + "author" : "Netquatro", |
719 | + "category" : "Generic Modules", |
720 | + "website": "http://wiki.openerp.org.ve/", |
721 | + "description": ''' |
722 | +Administración de las retenciones aplicadas a tributos municipales. |
723 | +''', |
724 | + "depends" : ["base","account","retencion_iva"], |
725 | + "init_xml" : [], |
726 | + "demo_xml" : [ |
727 | + |
728 | + ], |
729 | + "update_xml" : [ |
730 | + "security/ir.model.access.csv", |
731 | +# "retention_workflow.xml", |
732 | + "retencion_munici_view.xml", |
733 | + "retencion_munici_sequence.xml", |
734 | + "account_invoice_view.xml", |
735 | +# "account_view.xml", |
736 | + "partner_view.xml", |
737 | +# "stock_view.xml", |
738 | + "retencion_munici_report.xml", |
739 | + "retencion_munici_wizard.xml", |
740 | + ], |
741 | + "active": False, |
742 | + "installable": True |
743 | +} |
744 | |
745 | === added file 'l10n_ve_withholding_muni/account_invoice_view.xml' |
746 | --- l10n_ve_withholding_muni/account_invoice_view.xml 1970-01-01 00:00:00 +0000 |
747 | +++ l10n_ve_withholding_muni/account_invoice_view.xml 2011-09-22 17:22:23 +0000 |
748 | @@ -0,0 +1,65 @@ |
749 | +<?xml version="1.0" encoding="utf-8"?> |
750 | +<openerp> |
751 | + <data> |
752 | + |
753 | + |
754 | + |
755 | + <!-- |
756 | + ===================================================== |
757 | + Invoices Extension |
758 | + ===================================================== |
759 | + --> |
760 | + |
761 | + <record id="account_invoice_wh_muni_customer" model="ir.ui.view"> |
762 | + <field name="name">account.invoice.wh.local.customer</field> |
763 | + <field name="model">account.invoice</field> |
764 | + <field name="type">form</field> |
765 | + <field name="inherit_id" ref="l10n_ve_withholding.wh_inv_customer"/> |
766 | + <field name="arch" type="xml"> |
767 | + <page string="Withholdings" position="inside"> |
768 | + <notebook> |
769 | + <page string="Withholdings Local"> |
770 | + <group col="6" colspan="4"> |
771 | + <field name="wh_local"/> |
772 | + </group> |
773 | + </page> |
774 | + </notebook> |
775 | + </page> |
776 | + </field> |
777 | + </record> |
778 | + |
779 | + |
780 | + <record id="account_invoice_wh_muni_supplier" model="ir.ui.view"> |
781 | + <field name="name">account.invoice.wh.local.supplier</field> |
782 | + <field name="model">account.invoice</field> |
783 | + <field name="type">form</field> |
784 | + <field name="inherit_id" ref="l10n_ve_withholding.wh_inv_supplier"/> |
785 | + <field name="arch" type="xml"> |
786 | + <page string="Withholdings" position="inside"> |
787 | + <notebook> |
788 | + <page string="Withholdings Vat"> |
789 | + <group col="6" colspan="4"> |
790 | + <field name="wh_local"/> |
791 | + </group> |
792 | + </page> |
793 | + </notebook> |
794 | + </page> |
795 | + </field> |
796 | + </record> |
797 | + |
798 | + |
799 | + <record id="account_invoice_wh_muni_tree" model="ir.ui.view"> |
800 | + <field name="name">account.invoice.wh.local.tree</field> |
801 | + <field name="model">account.invoice</field> |
802 | + <field name="type">tree</field> |
803 | + <field name="inherit_id" ref="account.invoice_tree"/> |
804 | + <field name="arch" type="xml"> |
805 | + <xpath expr="/tree/field[@name='origin']" position="after"> |
806 | + <field name="wh_local"/> |
807 | + </xpath> |
808 | + </field> |
809 | + </record> |
810 | + |
811 | + |
812 | + </data> |
813 | +</openerp> |
814 | |
815 | === added file 'l10n_ve_withholding_muni/invoice.py' |
816 | --- l10n_ve_withholding_muni/invoice.py 1970-01-01 00:00:00 +0000 |
817 | +++ l10n_ve_withholding_muni/invoice.py 2011-09-22 17:22:23 +0000 |
818 | @@ -0,0 +1,93 @@ |
819 | +# -*- encoding: utf-8 -*- |
820 | +############################################################################## |
821 | +# |
822 | +# Copyright (c) 2009 Latinux Inc (http://www.latinux.com/) All Rights Reserved. |
823 | +# Javier Duran <jduran@corvus.com.ve> |
824 | +# |
825 | +# |
826 | +# WARNING: This program as such is intended to be used by professional |
827 | +# programmers who take the whole responsability of assessing all potential |
828 | +# consequences resulting from its eventual inadequacies and bugs |
829 | +# End users who are looking for a ready-to-use solution with commercial |
830 | +# garantees and support are strongly adviced to contract a Free Software |
831 | +# Service Company |
832 | +# |
833 | +# This program is Free Software; you can redistribute it and/or |
834 | +# modify it under the terms of the GNU General Public License |
835 | +# as published by the Free Software Foundation; either version 2 |
836 | +# of the License, or (at your option) any later version. |
837 | +# |
838 | +# This program is distributed in the hope that it will be useful, |
839 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
840 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
841 | +# GNU General Public License for more details. |
842 | +# |
843 | +# You should have received a copy of the GNU General Public License |
844 | +# along with this program; if not, write to the Free Software |
845 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
846 | +# |
847 | +############################################################################## |
848 | + |
849 | +import time |
850 | +from osv import fields, osv |
851 | + |
852 | + |
853 | + |
854 | +class account_invoice(osv.osv): |
855 | + _inherit = 'account.invoice' |
856 | + |
857 | + |
858 | + def _retenida_munici(self, cr, uid, ids, name, args, context): |
859 | + res = {} |
860 | + for id in ids: |
861 | + res[id] = self.test_retenida(cr, uid, [id], 'retmun') |
862 | + return res |
863 | + |
864 | + |
865 | + def _get_inv_munici_from_line(self, cr, uid, ids, context={}): |
866 | + move = {} |
867 | + for line in self.pool.get('account.move.line').browse(cr, uid, ids): |
868 | + if line.reconcile_partial_id: |
869 | + for line2 in line.reconcile_partial_id.line_partial_ids: |
870 | + move[line2.move_id.id] = True |
871 | + if line.reconcile_id: |
872 | + for line2 in line.reconcile_id.line_id: |
873 | + move[line2.move_id.id] = True |
874 | + invoice_ids = [] |
875 | + if move: |
876 | + invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) |
877 | + return invoice_ids |
878 | + |
879 | + def _get_inv_munici_from_reconcile(self, cr, uid, ids, context={}): |
880 | + move = {} |
881 | + for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): |
882 | + for line in r.line_partial_ids: |
883 | + move[line.move_id.id] = True |
884 | + for line in r.line_id: |
885 | + move[line.move_id.id] = True |
886 | + |
887 | + invoice_ids = [] |
888 | + if move: |
889 | + invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) |
890 | + return invoice_ids |
891 | + |
892 | + |
893 | + _columns = { |
894 | + 'wh_local': fields.function(_retenida_munici, method=True, string='Local Withholding', type='boolean', |
895 | + store={ |
896 | + 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, None, 50), |
897 | + 'account.move.line': (_get_inv_munici_from_line, None, 50), |
898 | + 'account.move.reconcile': (_get_inv_munici_from_reconcile, None, 50), |
899 | + }, help="The account moves of the invoice have been withheld with account moves of the payment(s)."), |
900 | + |
901 | + } |
902 | + |
903 | + |
904 | + |
905 | + |
906 | + |
907 | +account_invoice() |
908 | + |
909 | + |
910 | + |
911 | + |
912 | |
913 | === added file 'l10n_ve_withholding_muni/partner.py' |
914 | --- l10n_ve_withholding_muni/partner.py 1970-01-01 00:00:00 +0000 |
915 | +++ l10n_ve_withholding_muni/partner.py 2011-09-22 17:22:23 +0000 |
916 | @@ -0,0 +1,59 @@ |
917 | +# -*- encoding: utf-8 -*- |
918 | +############################################################################## |
919 | +# |
920 | +# Copyright (c) 2009 Latinux Inc (http://www.latinux.com/) All Rights Reserved. |
921 | +# Javier Duran <jduran@corvus.com.ve> |
922 | +# |
923 | +# |
924 | +# WARNING: This program as such is intended to be used by professional |
925 | +# programmers who take the whole responsability of assessing all potential |
926 | +# consequences resulting from its eventual inadequacies and bugs |
927 | +# End users who are looking for a ready-to-use solution with commercial |
928 | +# garantees and support are strongly adviced to contract a Free Software |
929 | +# Service Company |
930 | +# |
931 | +# This program is Free Software; you can redistribute it and/or |
932 | +# modify it under the terms of the GNU General Public License |
933 | +# as published by the Free Software Foundation; either version 2 |
934 | +# of the License, or (at your option) any later version. |
935 | +# |
936 | +# This program is distributed in the hope that it will be useful, |
937 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
938 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
939 | +# GNU General Public License for more details. |
940 | +# |
941 | +# You should have received a copy of the GNU General Public License |
942 | +# along with this program; if not, write to the Free Software |
943 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
944 | +# |
945 | +############################################################################## |
946 | + |
947 | +from osv import fields, osv |
948 | + |
949 | + |
950 | +class res_partner(osv.osv): |
951 | + _inherit = 'res.partner' |
952 | + _columns = { |
953 | + 'property_wh_munici_payable': fields.property( |
954 | + 'account.account', |
955 | + type='many2one', |
956 | + relation='account.account', |
957 | + string="Purchase local withholding account", |
958 | + method=True, |
959 | + view_load=True, |
960 | + domain="[('type', '=', 'other')]", |
961 | + help="This account will be used debit local withholding amount"), |
962 | + 'property_wh_munici_receivable': fields.property( |
963 | + 'account.account', |
964 | + type='many2one', |
965 | + relation='account.account', |
966 | + string="Sale local withholding account", |
967 | + method=True, |
968 | + view_load=True, |
969 | + domain="[('type', '=', 'other')]", |
970 | + help="This account will be used credit local withholding amount"), |
971 | + |
972 | + } |
973 | + |
974 | + |
975 | +res_partner() |
976 | |
977 | === added file 'l10n_ve_withholding_muni/partner_view.xml' |
978 | --- l10n_ve_withholding_muni/partner_view.xml 1970-01-01 00:00:00 +0000 |
979 | +++ l10n_ve_withholding_muni/partner_view.xml 2011-09-22 17:22:23 +0000 |
980 | @@ -0,0 +1,33 @@ |
981 | +<?xml version="1.0" encoding="utf-8"?> |
982 | +<openerp> |
983 | + <data> |
984 | + |
985 | + |
986 | + |
987 | + <!-- |
988 | + ===================================================== |
989 | + Partners Extension |
990 | + ===================================================== |
991 | + --> |
992 | + |
993 | + <record id="partner_ext_munici_view_form_loc_ve" model="ir.ui.view"> |
994 | + <field name="name">partner_extended_munici.partner.form.view.loc_ve</field> |
995 | + <field name="model">res.partner</field> |
996 | + <field name="type">form</field> |
997 | + <field name="inherit_id" ref="l10n_ve_withholding.wh_partner"/> |
998 | + <field name="arch" type="xml"> |
999 | + <page string="Withholdings" position="inside"> |
1000 | + <notebook> |
1001 | + <page string="Local Withholdings"> |
1002 | + <group col="4" colspan="2"> |
1003 | + <field name="property_wh_munici_payable"/> |
1004 | + <field name="property_wh_munici_receivable"/> |
1005 | + </group> |
1006 | + </page> |
1007 | + </notebook> |
1008 | + </page> |
1009 | + </field> |
1010 | + </record> |
1011 | + |
1012 | + </data> |
1013 | +</openerp> |
1014 | |
1015 | === added directory 'l10n_ve_withholding_muni/report' |
1016 | === added file 'l10n_ve_withholding_muni/report/__init__.py' |
1017 | --- l10n_ve_withholding_muni/report/__init__.py 1970-01-01 00:00:00 +0000 |
1018 | +++ l10n_ve_withholding_muni/report/__init__.py 2011-09-22 17:22:23 +0000 |
1019 | @@ -0,0 +1,32 @@ |
1020 | +# -*- encoding: utf-8 -*- |
1021 | +############################################################################## |
1022 | +# |
1023 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
1024 | +# Javier Duran <javier.duran@netquatro.com> |
1025 | +# |
1026 | +# |
1027 | +# WARNING: This program as such is intended to be used by professional |
1028 | +# programmers who take the whole responsability of assessing all potential |
1029 | +# consequences resulting from its eventual inadequacies and bugs |
1030 | +# End users who are looking for a ready-to-use solution with commercial |
1031 | +# garantees and support are strongly adviced to contract a Free Software |
1032 | +# Service Company |
1033 | +# |
1034 | +# This program is Free Software; you can redistribute it and/or |
1035 | +# modify it under the terms of the GNU General Public License |
1036 | +# as published by the Free Software Foundation; either version 2 |
1037 | +# of the License, or (at your option) any later version. |
1038 | +# |
1039 | +# This program is distributed in the hope that it will be useful, |
1040 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1041 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1042 | +# GNU General Public License for more details. |
1043 | +# |
1044 | +# You should have received a copy of the GNU General Public License |
1045 | +# along with this program; if not, write to the Free Software |
1046 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1047 | +# |
1048 | +############################################################################## |
1049 | + |
1050 | +import wh_muni_report |
1051 | + |
1052 | |
1053 | === added directory 'l10n_ve_withholding_muni/report/tiny_sxw2rml' |
1054 | === added file 'l10n_ve_withholding_muni/report/tiny_sxw2rml/__init__.py' |
1055 | --- l10n_ve_withholding_muni/report/tiny_sxw2rml/__init__.py 1970-01-01 00:00:00 +0000 |
1056 | +++ l10n_ve_withholding_muni/report/tiny_sxw2rml/__init__.py 2011-09-22 17:22:23 +0000 |
1057 | @@ -0,0 +1,29 @@ |
1058 | +############################################################################## |
1059 | +# |
1060 | +# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. |
1061 | +# Fabien Pinckaers <fp@tiny.Be> |
1062 | +# |
1063 | +# WARNING: This program as such is intended to be used by professional |
1064 | +# programmers who take the whole responsability of assessing all potential |
1065 | +# consequences resulting from its eventual inadequacies and bugs |
1066 | +# End users who are looking for a ready-to-use solution with commercial |
1067 | +# garantees and support are strongly adviced to contract a Free Software |
1068 | +# Service Company |
1069 | +# |
1070 | +# This program is Free Software; you can redistribute it and/or |
1071 | +# modify it under the terms of the GNU General Public License |
1072 | +# as published by the Free Software Foundation; either version 2 |
1073 | +# of the License, or (at your option) any later version. |
1074 | +# |
1075 | +# This program is distributed in the hope that it will be useful, |
1076 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1077 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1078 | +# GNU General Public License for more details. |
1079 | +# |
1080 | +# You should have received a copy of the GNU General Public License |
1081 | +# along with this program; if not, write to the Free Software |
1082 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1083 | +# |
1084 | +############################################################################## |
1085 | + |
1086 | +from tiny_sxw2rml import sxw2rml |
1087 | |
1088 | === added file 'l10n_ve_withholding_muni/report/tiny_sxw2rml/normalized_oo2rml.xsl' |
1089 | --- l10n_ve_withholding_muni/report/tiny_sxw2rml/normalized_oo2rml.xsl 1970-01-01 00:00:00 +0000 |
1090 | +++ l10n_ve_withholding_muni/report/tiny_sxw2rml/normalized_oo2rml.xsl 2011-09-22 17:22:23 +0000 |
1091 | @@ -0,0 +1,681 @@ |
1092 | +<?xml version="1.0" encoding="utf-8"?> |
1093 | +<xsl:stylesheet |
1094 | + version="1.0" |
1095 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
1096 | + xmlns:fo="http://www.w3.org/1999/XSL/Format" |
1097 | + xmlns:office="http://openoffice.org/2000/office" |
1098 | + xmlns:style="http://openoffice.org/2000/style" |
1099 | + xmlns:text="http://openoffice.org/2000/text" |
1100 | + xmlns:table="http://openoffice.org/2000/table" |
1101 | + xmlns:draw="http://openoffice.org/2000/drawing" |
1102 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
1103 | + xmlns:number="http://openoffice.org/2000/datastyle" |
1104 | + xmlns:svg="http://www.w3.org/2000/svg" |
1105 | + xmlns:chart="http://openoffice.org/2000/chart" |
1106 | + xmlns:dr3d="http://openoffice.org/2000/dr3d" |
1107 | + xmlns:math="http://www.w3.org/1998/Math/MathML" |
1108 | + xmlns:form="http://openoffice.org/2000/form" |
1109 | + xmlns:script="http://openoffice.org/2000/script" |
1110 | + office:class="text" office:version="1.0" |
1111 | + exclude-result-prefixes = "xsl fo office style text table draw xlink number svg chart dr3d math form script"> |
1112 | + |
1113 | + <!--TODO's: indent, picture cache (trml2pdf) --> |
1114 | + |
1115 | +<xsl:output method="xml" indent="yes" /> |
1116 | +<xsl:strip-space elements="*"/> |
1117 | + |
1118 | +<xsl:key name="text_style" match="style:style[@style:family='text']" use="@style:name" /> |
1119 | +<xsl:key name="page_break_before" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-before='page']" use="@style:name" /> |
1120 | +<xsl:key name="page_break_after" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-after='page']" use="@style:name" /> |
1121 | +<xsl:key name="table_column_style" match="style:style[@style:family='table-column']" use="@style:name" /> |
1122 | +<xsl:key name="table_cell_style" match="style:style[@style:family='table-cell']" use="@style:name" /> |
1123 | +<xsl:key name="paragraph_style" match="style:style[@style:family='paragraph']" use="@style:name" /> |
1124 | + |
1125 | +<xsl:template match="office:document-content"> |
1126 | + <document filename="test.pdf"> |
1127 | + <xsl:apply-templates select="office:automatic-styles" /> |
1128 | + <xsl:apply-templates select="office:body" /> |
1129 | + </document> |
1130 | +</xsl:template> |
1131 | + |
1132 | +<xsl:template name="page_size"> |
1133 | + <xsl:attribute name="pageSize"> |
1134 | + <xsl:text>(</xsl:text> |
1135 | + <xsl:value-of select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" /> |
1136 | + <xsl:text>,</xsl:text> |
1137 | + <xsl:value-of select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height" /> |
1138 | + <xsl:text>)</xsl:text> |
1139 | + </xsl:attribute> |
1140 | +</xsl:template> |
1141 | + |
1142 | +<xsl:template name="fixed_frame"> |
1143 | + <xsl:for-each select="//draw:text-box"> |
1144 | + <frame> |
1145 | + <xsl:attribute name="id"><xsl:value-of select="./@draw:name" /></xsl:attribute> |
1146 | + <xsl:attribute name="x1"><xsl:value-of select="./@svg:x" /></xsl:attribute> |
1147 | + <xsl:attribute name="y1"> |
1148 | + <xsl:value-of |
1149 | + select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height - ./@svg:y - ./@fo:min-height" /> |
1150 | + </xsl:attribute> |
1151 | + <xsl:attribute name="width"> |
1152 | + <xsl:value-of select="./@svg:width" /> |
1153 | + </xsl:attribute> |
1154 | + <xsl:attribute name="height"> |
1155 | + <xsl:value-of select="./@fo:min-height" /> |
1156 | + </xsl:attribute> |
1157 | + </frame> |
1158 | + </xsl:for-each> |
1159 | +</xsl:template> |
1160 | + |
1161 | +<xsl:template name="margin_sizes"> |
1162 | + <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-left" /> |
1163 | + <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-right" /> |
1164 | + <xsl:variable name="margin_top" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-top" /> |
1165 | + <xsl:variable name="margin_bottom" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-bottom" /> |
1166 | + <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" /> |
1167 | + <xsl:variable name="page_height" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height" /> |
1168 | + <xsl:attribute name="x1"><xsl:value-of select="$margin_left" /></xsl:attribute> |
1169 | + <xsl:attribute name="y1"><xsl:value-of select="$margin_bottom" /></xsl:attribute> |
1170 | + <xsl:attribute name="width"><xsl:value-of select="$page_width - $margin_left - $margin_right"/></xsl:attribute> |
1171 | + <xsl:attribute name="height"><xsl:value-of select="$page_height - $margin_bottom - $margin_top"/></xsl:attribute> |
1172 | +</xsl:template> |
1173 | + |
1174 | +<xsl:template name="text_width"> |
1175 | + <!-- You need this for the workaround to make primitive outlines--> |
1176 | + <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-left" /> |
1177 | + <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-right" /> |
1178 | + <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" /> |
1179 | + <xsl:value-of select="$page_width - $margin_left - $margin_right - 18"/> |
1180 | +</xsl:template> |
1181 | + |
1182 | + |
1183 | + |
1184 | +<xsl:template match="office:automatic-styles"> |
1185 | + <!--<template pageSize="(21cm, 29.7cm)" leftMargin="1.0cm" rightMargin="2.0cm" topMargin="1.0cm" bottomMargin="1.0cm" title="Test" author="Martin Simon" allowSplitting="20">--> |
1186 | + <template pageSize="(21cm, 29.7cm)" title="Test" author="Martin Simon" allowSplitting="20"> |
1187 | + <xsl:call-template name="page_size" /> |
1188 | + <pageTemplate id="first"> |
1189 | + <xsl:call-template name="fixed_frame" /> |
1190 | + <frame id="first" x1="2cm" y1="2cm" width="17cm" height="26cm"> |
1191 | + <xsl:call-template name="margin_sizes" /> |
1192 | + </frame> |
1193 | + </pageTemplate> |
1194 | + </template> |
1195 | + <stylesheet> |
1196 | + <!--A table style to simulate primitive outlines -till the <addOutline> tag is implemented in trml2pdf --> |
1197 | + <blockTableStyle id="Standard_Outline"> |
1198 | + <blockAlignment value="LEFT"/> |
1199 | + <blockValign value="TOP"/> |
1200 | + </blockTableStyle> |
1201 | + <!--use two standard table grid styles like PyOpenOffice "Old Way": with and without a grid--> |
1202 | + <!--TODO insert table cell colors here, not within the <td> tag - otherwise |
1203 | + it will not work with flowables as cell content--> |
1204 | + <xsl:call-template name="make_blocktablestyle" /> |
1205 | + <initialize> |
1206 | + <paraStyle name="all" alignment="justify" /> |
1207 | + </initialize> |
1208 | + <xsl:apply-templates select="style:style" /> |
1209 | + </stylesheet> |
1210 | +</xsl:template> |
1211 | + |
1212 | +<xsl:template name="make_blocktablestyle"> |
1213 | + <xsl:for-each select="//table:table"> |
1214 | + <xsl:variable name="test"> |
1215 | + <xsl:value-of select="./@table:name" /> |
1216 | + </xsl:variable> |
1217 | + <xsl:if test="not(boolean(count(preceding-sibling::table:table[@table:name=$test])))"> |
1218 | + <!--Test if this is the first table with this style, nested tables not counted--> |
1219 | + <blockTableStyle id="{@table:name}"> |
1220 | + <xsl:if test=".//draw:image"> |
1221 | + <blockTopPadding value="0"/> |
1222 | + <blockBottomPadding value="0"/> |
1223 | + </xsl:if> |
1224 | + <blockAlignment value="LEFT" /> |
1225 | + <blockValign value="TOP" /> |
1226 | + <xsl:call-template name="make_linestyle" /> |
1227 | + <xsl:call-template name="make_tablebackground" /> |
1228 | + </blockTableStyle> |
1229 | + </xsl:if> |
1230 | + </xsl:for-each> |
1231 | +</xsl:template> |
1232 | + |
1233 | +<xsl:template name="make_linestyle"> |
1234 | + <xsl:for-each select=".//table:table-row"> |
1235 | + <xsl:variable name="row" select="position() - 1"/> |
1236 | + <xsl:for-each select=".//table:table-cell"> |
1237 | + <xsl:variable name="col" select="position() - 1"/> |
1238 | + <xsl:variable name="linebefore"> |
1239 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-left"/> |
1240 | + </xsl:variable> |
1241 | + <xsl:if test="not($linebefore='') and not($linebefore='none')"> |
1242 | + <xsl:variable name="colorname"> |
1243 | + <xsl:value-of select="substring-after($linebefore,'#')"/> |
1244 | + </xsl:variable> |
1245 | + <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
1246 | + </xsl:if> |
1247 | + <xsl:variable name="lineafter"> |
1248 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-right"/> |
1249 | + </xsl:variable> |
1250 | + <xsl:if test="not($lineafter='') and not($lineafter='none')"> |
1251 | + <xsl:variable name="colorname"> |
1252 | + <xsl:value-of select="substring-after($lineafter,'#')"/> |
1253 | + </xsl:variable> |
1254 | + <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
1255 | + </xsl:if> |
1256 | + <xsl:variable name="lineabove"> |
1257 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-top"/> |
1258 | + </xsl:variable> |
1259 | + <xsl:if test="not($lineabove='') and not($lineabove='none')"> |
1260 | + <xsl:variable name="colorname"> |
1261 | + <xsl:value-of select="substring-after($lineabove,'#')"/> |
1262 | + </xsl:variable> |
1263 | + <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/> |
1264 | + </xsl:if> |
1265 | + <xsl:variable name="linebelow"> |
1266 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-bottom"/> |
1267 | + </xsl:variable> |
1268 | + <xsl:if test="not($linebelow='') and not($linebelow='none')"> |
1269 | + <xsl:variable name="colorname"> |
1270 | + <xsl:value-of select="substring-after($linebelow,'#')"/> |
1271 | + </xsl:variable> |
1272 | + <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/> |
1273 | + </xsl:if> |
1274 | + <xsl:variable name="grid"> |
1275 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border"/> |
1276 | + </xsl:variable> |
1277 | + <xsl:if test="not($grid='') and not($grid='none')"> |
1278 | + <xsl:variable name="colorname"> |
1279 | + <xsl:value-of select="substring-after($grid,'#')"/> |
1280 | + </xsl:variable> |
1281 | + <!-- Don't use grid because we don't need a line between each rows --> |
1282 | + <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
1283 | + <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
1284 | + <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/> |
1285 | + <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/> |
1286 | + </xsl:if> |
1287 | + </xsl:for-each> |
1288 | + </xsl:for-each> |
1289 | +</xsl:template> |
1290 | + |
1291 | +<!-- Was needed to simulate bulleted lists: |
1292 | +<xsl:template match="text:ordered-list|text:unordered-list"> |
1293 | + <xsl:variable name = "text_width"> |
1294 | + <xsl:call-template name="text_width" /> |
1295 | + </xsl:variable> |
1296 | + <blockTable style="Standard_Outline" colWidths="18,{$text_width}"> |
1297 | + <xsl:apply-templates match="text:list-item" /> |
1298 | +</blockTable> |
1299 | +</xsl:template> |
1300 | + |
1301 | +<xsl:template match="text:list-item"> |
1302 | + <tr> |
1303 | + <td><para><font face="Helvetica-Bold" size="10">*</font></para></td> |
1304 | + <td> |
1305 | + <xsl:apply-templates /> |
1306 | + </td> |
1307 | + </tr> |
1308 | +</xsl:template> |
1309 | + |
1310 | +--> |
1311 | + |
1312 | + |
1313 | +<xsl:template match="office:body"> |
1314 | + <story> |
1315 | + <xsl:apply-templates /> |
1316 | + <xsl:for-each select="//draw:text-box"> |
1317 | + <currentFrame> |
1318 | + <xsl:attribute name="name"> |
1319 | + <xsl:value-of select="./@draw:name" /> |
1320 | + </xsl:attribute> |
1321 | + </currentFrame> |
1322 | + <xsl:apply-templates> |
1323 | + <xsl:with-param name="skip_draw" select="0" /> |
1324 | + </xsl:apply-templates> |
1325 | + <frameEnd /> |
1326 | + </xsl:for-each> |
1327 | + </story> |
1328 | +</xsl:template> |
1329 | + |
1330 | +<xsl:template match="table:table"> |
1331 | + <blockTable> |
1332 | + <xsl:attribute name="colWidths"> |
1333 | + <xsl:call-template name="make_columns" /> |
1334 | + </xsl:attribute> |
1335 | + <xsl:call-template name="make_tableheaders" /> |
1336 | + <xsl:attribute name="style"> |
1337 | + <xsl:value-of select="@table:name" /> |
1338 | + </xsl:attribute> |
1339 | + <xsl:apply-templates /> |
1340 | + </blockTable> |
1341 | +</xsl:template> |
1342 | + |
1343 | +<xsl:template name="make_tableheaders"> |
1344 | + <xsl:if test="boolean(count(table:table-header-rows))"> |
1345 | + <xsl:attribute name="repeatRows">1</xsl:attribute> |
1346 | + </xsl:if> |
1347 | +</xsl:template> |
1348 | + |
1349 | +<xsl:template name="make_tablebackground"> |
1350 | + <xsl:for-each select=".//table:table-row"> |
1351 | + <!--Be careful when there are table:table-header-rows as |
1352 | + parent node of table:table-row --> |
1353 | + <xsl:variable name="row" select="position() - 1" /> |
1354 | + <xsl:for-each select="./table:table-cell"> |
1355 | + <xsl:variable name="col" select="position() - 1" /> |
1356 | + <xsl:variable name="background"> |
1357 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:background-color" /> |
1358 | + </xsl:variable> |
1359 | + <xsl:if test="not($background='') and boolean(key('table_cell_style',@table:style-name)/style:properties/@fo:background-color) and starts-with($background,'#')"> |
1360 | + <!--only RGB hexcolors are accepted --> |
1361 | + <blockBackground colorName="{$background}" start="{$col},{$row}" stop="{$col},-1" /> |
1362 | + </xsl:if> |
1363 | + </xsl:for-each> |
1364 | + </xsl:for-each> |
1365 | +</xsl:template> |
1366 | + |
1367 | +<xsl:template name="make_columns"> |
1368 | + <xsl:variable name="columns" > |
1369 | + <xsl:for-each select="table:table-column"> |
1370 | + <xsl:value-of select="key('table_column_style',@table:style-name)/style:properties/@style:column-width" /> |
1371 | + <xsl:text>,</xsl:text> |
1372 | + </xsl:for-each> |
1373 | + </xsl:variable> |
1374 | + <xsl:value-of select="substring($columns,1,string-length($columns) - 1)" /> |
1375 | + <!--strip the last comma--> |
1376 | +</xsl:template> |
1377 | + |
1378 | +<xsl:template match="table:table-row"> |
1379 | + <tr> |
1380 | + <xsl:apply-templates /> |
1381 | + </tr> |
1382 | +</xsl:template> |
1383 | + |
1384 | +<xsl:template match="table:table-cell"> |
1385 | + <td> |
1386 | + <xsl:apply-templates /> |
1387 | + </td> |
1388 | +</xsl:template> |
1389 | + |
1390 | +<xsl:template match="text:section"> |
1391 | + <section> |
1392 | + <xsl:apply-templates /> |
1393 | + </section> |
1394 | +</xsl:template> |
1395 | + |
1396 | + |
1397 | +<xsl:template match="text:span"> |
1398 | + <font> |
1399 | + <xsl:call-template name="make_fontnames_span" /> |
1400 | + <xsl:call-template name="make_fontsize_span" /> |
1401 | + <xsl:apply-templates /> |
1402 | + </font> |
1403 | +</xsl:template> |
1404 | + |
1405 | +<xsl:template name="make_fontsize_span"> |
1406 | + <xsl:variable name ="fontsize"> |
1407 | + <xsl:value-of select="key('text_style',@text:style-name)/style:properties/@fo:font-size" /> |
1408 | + </xsl:variable> |
1409 | + <xsl:if test="not($fontsize='') and boolean(key('text_style',@text:style-name)/style:properties/@fo:font-size)" > |
1410 | + <xsl:attribute name="size"> |
1411 | + <xsl:value-of select="$fontsize" /> |
1412 | + </xsl:attribute> |
1413 | + </xsl:if> |
1414 | +</xsl:template> |
1415 | + |
1416 | +<xsl:template name="make_fontnames_span"> |
1417 | + <xsl:attribute name="face"> |
1418 | + <xsl:call-template name="make_fontnames"> |
1419 | + <xsl:with-param name="fontName" select="key('text_style',@text:style-name)/style:properties/@style:font-name" /> |
1420 | + <xsl:with-param name="fontWeight" select="key('text_style',@text:style-name)/style:properties/@fo:font-weight" /> |
1421 | + <xsl:with-param name="fontStyle" select="key('text_style',@text:style-name)/style:properties/@fo:font-style" /> |
1422 | + </xsl:call-template> |
1423 | + </xsl:attribute> |
1424 | +</xsl:template> |
1425 | + |
1426 | +<xsl:template name="make_image"> |
1427 | + <illustration height="{.//draw:image/@svg:height}" width="{.//draw:image/@svg:width}"> |
1428 | + <image x="0" y="0" file="{substring-after(.//draw:image/@xlink:href,'#Pictures/')}" height="{.//draw:image/@svg:height}" width="{.//draw:image/@svg:width}" /> |
1429 | + </illustration> |
1430 | +</xsl:template> |
1431 | + |
1432 | +<xsl:template name="empty_paragraph"> |
1433 | + <xsl:if test="not(boolean(count(descendant::node())))"> |
1434 | + <xsl:call-template name="distance_point"> |
1435 | + <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" /> |
1436 | + </xsl:call-template> |
1437 | + </xsl:if> |
1438 | +</xsl:template> |
1439 | + |
1440 | +<xsl:template name="distance_point"> |
1441 | + <xsl:param name="background" /> |
1442 | + <xsl:param name="tab_stop"></xsl:param> |
1443 | + <xsl:variable name="local_back"> |
1444 | + <xsl:choose> |
1445 | + <xsl:when test="not(boolean($background)) or not(contains($background,'#'))"> |
1446 | + <!-- Do not accept OO colors like "transparent", only hex-colors --> |
1447 | + <xsl:text>white</xsl:text> |
1448 | + </xsl:when> |
1449 | + <xsl:otherwise> |
1450 | + <xsl:value-of select="$background" /> |
1451 | + </xsl:otherwise> |
1452 | + </xsl:choose> |
1453 | + </xsl:variable> |
1454 | + <font color="{$local_back}"> |
1455 | + <xsl:text> </xsl:text> |
1456 | + <xsl:if test="boolean($tab_stop)"> |
1457 | + <!-- simulate a tabstop with white/background-color points --> |
1458 | + <xsl:text>.........</xsl:text> |
1459 | + </xsl:if> |
1460 | + </font> |
1461 | +</xsl:template> |
1462 | + |
1463 | +<xsl:template match="text:ordered-list"> |
1464 | + <xsl:apply-templates /> |
1465 | + <para><seqreset id="ordered_list" /></para> |
1466 | + <!-- Reset the counter. seqreset is not a trml2pdf tag, but a Platypus Intra Paragraph Markup, |
1467 | + so it needs a dummy paragraph to enclose it --> |
1468 | +</xsl:template> |
1469 | + |
1470 | +<xsl:template name="make_listitem"> |
1471 | + <xsl:if test="(name(..)='text:list-item')"> |
1472 | + <xsl:attribute name="leftIndent">15</xsl:attribute> |
1473 | + <xsl:attribute name="bulletIndent">0</xsl:attribute> |
1474 | + <xsl:choose> |
1475 | + <xsl:when test="(name(../..)='text:unordered-list')"> |
1476 | + <xsl:variable name="fontsize"> |
1477 | + <xsl:value-of select="number(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)" /> |
1478 | + </xsl:variable> |
1479 | + <xsl:choose> |
1480 | + <xsl:when test="$fontsize='NaN'"> |
1481 | + <!-- you should exclude non-numerical values for bulletFontSize. <== Sometimes the preprocessing went wrong.--> |
1482 | + <!--use a default bullet font size--> |
1483 | + <xsl:attribute name="bulletFontSize">6</xsl:attribute> |
1484 | + </xsl:when> |
1485 | + <xsl:otherwise> |
1486 | + <xsl:attribute name="bulletFontSize"><xsl:value-of select="floor(($fontsize div 2) + 1)" /></xsl:attribute> |
1487 | + </xsl:otherwise> |
1488 | + </xsl:choose> |
1489 | + <xsl:attribute name="bulletFontName">ZapfDingbats</xsl:attribute> |
1490 | + <xsl:attribute name="bulletText">l</xsl:attribute> |
1491 | + </xsl:when> |
1492 | + <xsl:otherwise> |
1493 | + <!-- Generate the numbers for an ordered list --> |
1494 | + <xsl:variable name="size"> |
1495 | + <xsl:value-of select="key('paragraph_style',@text:style-name)/style:properties/@fo:font-size" /> |
1496 | + </xsl:variable> |
1497 | + <!-- For ordered lists we use the bullet tag from Platypus Intra Paragraph Markup --> |
1498 | + <bullet> |
1499 | + <xsl:if test="not($size='') and boolean(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)"> |
1500 | + <xsl:attribute name="size"> |
1501 | + <!-- adapt the fontsize to the fontsize of the current paragraph --> |
1502 | + <xsl:value-of select="$size" /> |
1503 | + </xsl:attribute> |
1504 | + </xsl:if> |
1505 | + <seq id="ordered_list" />.</bullet> |
1506 | + </xsl:otherwise> |
1507 | + </xsl:choose> |
1508 | + </xsl:if> |
1509 | +</xsl:template> |
1510 | + |
1511 | +<xsl:template match="text:drop-down"> |
1512 | + <xsl:value-of select="text:label[2]/@text:value" /> |
1513 | +</xsl:template> |
1514 | + |
1515 | + |
1516 | +<xsl:template match="text:p|text:h"> |
1517 | + <xsl:param name="skip_draw" select="1" /> |
1518 | + <xsl:if test="boolean(key('page_break_before',@text:style-name))" > |
1519 | + <pageBreak /> |
1520 | + </xsl:if> |
1521 | + <xsl:choose> |
1522 | + <xsl:when test="boolean(.//draw:image)"> |
1523 | + <xsl:call-template name="make_image" /> |
1524 | + </xsl:when> |
1525 | + <xsl:when test="boolean(name(..) = 'draw:text-box') and boolean($skip_draw)"> |
1526 | + </xsl:when> |
1527 | + <xsl:otherwise> |
1528 | + <para> |
1529 | + <xsl:attribute name="style"> |
1530 | + <xsl:value-of select="@text:style-name" /> |
1531 | + </xsl:attribute> |
1532 | + <xsl:call-template name="make_listitem" /> |
1533 | + <xsl:apply-templates /> |
1534 | + <xsl:call-template name="empty_paragraph" /> |
1535 | + </para> |
1536 | + </xsl:otherwise> |
1537 | + </xsl:choose> |
1538 | + <xsl:if test="boolean(key('page_break_after',@text:style-name))" > |
1539 | + <pageBreak /> |
1540 | + </xsl:if> |
1541 | +</xsl:template> |
1542 | + |
1543 | +<xsl:template match="text:p/text:tab-stop"> |
1544 | + <!-- simulate a tabstop --> |
1545 | + <xsl:call-template name="distance_point"> |
1546 | + <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" /> |
1547 | + <xsl:with-param name="tab_stop">yes</xsl:with-param> |
1548 | + </xsl:call-template> |
1549 | +</xsl:template> |
1550 | + |
1551 | +<!-- experimental - switched off |
1552 | +<xsl:template match="text:h"> |
1553 | + <para> |
1554 | + <xsl:attribute name="style"> |
1555 | + <xsl:value-of select="@text:style-name" /> |
1556 | + </xsl:attribute> |
1557 | + <xsl:call-template name="make_number" /> |
1558 | + <xsl:apply-templates /> |
1559 | + <xsl:call-template name="empty_paragraph" /> |
1560 | + </para> |
1561 | +</xsl:template> |
1562 | + |
1563 | +<xsl:template name="make_number"> |
1564 | + <xsl:choose> |
1565 | + <xsl:when test="@text:level='1'"> |
1566 | + <xsl:number format="1. " /> |
1567 | + </xsl:when> |
1568 | + <xsl:when test="@text:level='2'"> |
1569 | + <xsl:number count="text:h[@text:level='1']|text:h[text:level='2']" level="any" format="1.1." /> |
1570 | + </xsl:when> |
1571 | + </xsl:choose> |
1572 | +</xsl:template> |
1573 | + |
1574 | +--> |
1575 | + |
1576 | +<xsl:template match="style:style[@style:family='paragraph']"> |
1577 | + <paraStyle> |
1578 | + <xsl:attribute name="name"> |
1579 | + <xsl:value-of select="@style:name" /> |
1580 | + </xsl:attribute> |
1581 | + <xsl:call-template name="make_indent_paragraph" /> |
1582 | + <xsl:call-template name="make_fontnames_paragraph" /> |
1583 | + <xsl:call-template name="make_fontsize" /> |
1584 | + <!--<xsl:call-template name="make_parent" /> not necessary - |
1585 | + parent styles processed by PyOpenOffice --> |
1586 | + <xsl:call-template name="make_alignment" /> |
1587 | + <xsl:call-template name="make_background" /> |
1588 | + <xsl:call-template name="make_space_beforeafter" /> |
1589 | + </paraStyle> |
1590 | +</xsl:template> |
1591 | + |
1592 | +<xsl:template name="make_indent_paragraph"> |
1593 | + <xsl:variable name="right_indent"><xsl:value-of select="style:properties/@fo:margin-right" /></xsl:variable> |
1594 | + <xsl:variable name="left_indent"><xsl:value-of select="style:properties/@fo:margin-left" /></xsl:variable> |
1595 | + <xsl:if test="not($right_indent='') and boolean(style:properties/@fo:margin-right)"> |
1596 | + <xsl:attribute name="rightIndent"> |
1597 | + <xsl:value-of select="$right_indent" /> |
1598 | + </xsl:attribute> |
1599 | + </xsl:if> |
1600 | + <xsl:if test="not($left_indent='') and boolean(style:properties/@fo:margin-left)"> |
1601 | + <xsl:attribute name="leftIndent"> |
1602 | + <xsl:value-of select="$left_indent" /> |
1603 | + </xsl:attribute> |
1604 | + </xsl:if> |
1605 | +</xsl:template> |
1606 | + |
1607 | +<xsl:template name="make_background"> |
1608 | + <xsl:variable name="background"> |
1609 | + <xsl:value-of select="style:properties/@fo:background-color" /> |
1610 | + </xsl:variable> |
1611 | + <xsl:if test="not($background='') and boolean(style:properties/@fo:background-color) and starts-with($background,'#')" > |
1612 | + <xsl:attribute name="backColor"> |
1613 | + <xsl:value-of select="$background" /> |
1614 | + </xsl:attribute> |
1615 | + </xsl:if> |
1616 | +</xsl:template> |
1617 | + |
1618 | +<xsl:template name="make_space_beforeafter"> |
1619 | + <xsl:variable name="before"> |
1620 | + <xsl:value-of select="style:properties/@fo:margin-top" /> |
1621 | + </xsl:variable> |
1622 | + <xsl:variable name="after"> |
1623 | + <xsl:value-of select="style:properties/@fo:margin-bottom" /> |
1624 | + </xsl:variable> |
1625 | + <xsl:if test="not($before='') and boolean(style:properties/@fo:margin-top)" > |
1626 | + <xsl:attribute name="spaceBefore"> |
1627 | + <xsl:value-of select="$before" /> |
1628 | + </xsl:attribute> |
1629 | + </xsl:if> |
1630 | + <xsl:if test="not($after='') and boolean(style:properties/@fo:margin-bottom)" > |
1631 | + <xsl:attribute name="spaceAfter"> |
1632 | + <xsl:value-of select="$after" /> |
1633 | + </xsl:attribute> |
1634 | + </xsl:if> |
1635 | +</xsl:template> |
1636 | + |
1637 | +<xsl:template name="make_fontsize"> |
1638 | + <xsl:variable name="fontSize"> |
1639 | + <xsl:value-of select="style:properties/@fo:font-size" /> |
1640 | + </xsl:variable> |
1641 | + <xsl:if test="not($fontSize='') and boolean(style:properties/@fo:font-size)"> |
1642 | + <xsl:attribute name="fontSize"> |
1643 | + <xsl:value-of select="$fontSize" /> |
1644 | + </xsl:attribute> |
1645 | + <xsl:attribute name="leading"> |
1646 | + <xsl:value-of select="$fontSize + floor($fontSize div 5) + 1" /> |
1647 | + <!--use a standard leading related to the font size --> |
1648 | + </xsl:attribute> |
1649 | + </xsl:if> |
1650 | +</xsl:template> |
1651 | + |
1652 | +<!--this template is not needed anymore for "normalized" sxw files --> |
1653 | +<xsl:template name="make_parent"> |
1654 | + <xsl:variable name="parent"> |
1655 | + <xsl:value-of select="@style:parent-style-name" /> |
1656 | + </xsl:variable> |
1657 | + <xsl:if test="not($parent='') and boolean(@style:parent-style-name)"> |
1658 | + <xsl:attribute name="parent"> |
1659 | + <xsl:value-of select="$parent" /> |
1660 | + </xsl:attribute> |
1661 | + </xsl:if> |
1662 | +</xsl:template> |
1663 | + |
1664 | +<xsl:template name="make_alignment"> |
1665 | + <xsl:variable name="alignment"> |
1666 | + <xsl:value-of select="style:properties/@fo:text-align" /> |
1667 | + </xsl:variable> |
1668 | + <xsl:if test="not($alignment='') and boolean(style:properties/@fo:text-align)"> |
1669 | + <xsl:choose> |
1670 | + <xsl:when test="$alignment='start'"> |
1671 | + <xsl:attribute name="alignment">LEFT</xsl:attribute> |
1672 | + </xsl:when> |
1673 | + <xsl:when test="$alignment='center'"> |
1674 | + <xsl:attribute name="alignment">CENTER</xsl:attribute> |
1675 | + </xsl:when> |
1676 | + <xsl:when test="$alignment='end'"> |
1677 | + <xsl:attribute name="alignment">RIGHT</xsl:attribute> |
1678 | + </xsl:when> |
1679 | + <xsl:when test="$alignment='justify'"> |
1680 | + <xsl:attribute name="alignment">JUSTIFY</xsl:attribute> |
1681 | + </xsl:when> |
1682 | + </xsl:choose> |
1683 | + </xsl:if> |
1684 | +</xsl:template> |
1685 | + |
1686 | +<xsl:template name="make_fontnames_paragraph"> |
1687 | + <xsl:attribute name="fontName"> |
1688 | + <xsl:call-template name="make_fontnames"> |
1689 | + <xsl:with-param name="fontName" select="style:properties/@style:font-name" /> |
1690 | + <xsl:with-param name="fontWeight" select="style:properties/@fo:font-weight" /> |
1691 | + <xsl:with-param name="fontStyle" select="style:properties/@fo:font-style" /> |
1692 | + </xsl:call-template> |
1693 | + </xsl:attribute> |
1694 | +</xsl:template> |
1695 | + |
1696 | +<xsl:template name="make_fontnames"> |
1697 | + <!--much too verbose, needs improvement--> |
1698 | +<xsl:param name="fontName" /> |
1699 | +<xsl:param name="fontWeight" /> |
1700 | +<xsl:param name="fontStyle" /> |
1701 | +<xsl:choose> |
1702 | +<xsl:when test="not($fontName='') and boolean($fontName)"> |
1703 | + <xsl:choose> |
1704 | + <xsl:when test="contains($fontName,'Courier')"> |
1705 | + <xsl:choose> |
1706 | + <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')"> |
1707 | + <xsl:text>Courier-BoldOblique</xsl:text> |
1708 | + </xsl:when> |
1709 | + <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')"> |
1710 | + <xsl:text>Courier-Bold</xsl:text> |
1711 | + </xsl:when> |
1712 | + <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')"> |
1713 | + <xsl:text>Courier-Oblique</xsl:text> |
1714 | + </xsl:when> |
1715 | + <xsl:otherwise> |
1716 | + <xsl:text>Courier</xsl:text> |
1717 | + </xsl:otherwise> |
1718 | + </xsl:choose> |
1719 | + </xsl:when> |
1720 | + <xsl:when test="contains($fontName,'Helvetica') or contains($fontName,'Arial') or contains($fontName,'Sans')"> |
1721 | + <xsl:choose> |
1722 | + <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')"> |
1723 | + <xsl:text>Helvetica-BoldOblique</xsl:text> |
1724 | + </xsl:when> |
1725 | + <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')"> |
1726 | + <xsl:text>Helvetica-Bold</xsl:text> |
1727 | + </xsl:when> |
1728 | + <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')"> |
1729 | + <xsl:text>Helvetica-Oblique</xsl:text> |
1730 | + </xsl:when> |
1731 | + <xsl:otherwise> |
1732 | + <xsl:text>Helvetica</xsl:text> |
1733 | + </xsl:otherwise> |
1734 | + </xsl:choose> |
1735 | + </xsl:when> |
1736 | + <xsl:otherwise> |
1737 | + <xsl:choose> |
1738 | + <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')"> |
1739 | + <xsl:text>Times-BoldItalic</xsl:text> |
1740 | + </xsl:when> |
1741 | + <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')"> |
1742 | + <xsl:text>Times-Bold</xsl:text> |
1743 | + </xsl:when> |
1744 | + <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')"> |
1745 | + <xsl:text>Times-Italic</xsl:text> |
1746 | + </xsl:when> |
1747 | + <xsl:otherwise> |
1748 | + <xsl:text>Times-Roman</xsl:text> |
1749 | + </xsl:otherwise> |
1750 | + </xsl:choose> |
1751 | + </xsl:otherwise> |
1752 | + </xsl:choose> |
1753 | +</xsl:when> |
1754 | +<xsl:otherwise> |
1755 | + <!--Use this as default --> |
1756 | + <xsl:text>Times-Roman</xsl:text> |
1757 | +</xsl:otherwise> |
1758 | +</xsl:choose> |
1759 | +</xsl:template> |
1760 | + |
1761 | +<!-- |
1762 | +This stylesheet is part of: |
1763 | +PyOpenOffice Version 0.4 |
1764 | +Copyright (C) 2005: Martin Simon |
1765 | +Homepage: www.bezirksreiter.de |
1766 | + |
1767 | +GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 |
1768 | +--> |
1769 | + |
1770 | +</xsl:stylesheet> |
1771 | + |
1772 | + |
1773 | |
1774 | === added file 'l10n_ve_withholding_muni/report/tiny_sxw2rml/office.dtd' |
1775 | === added file 'l10n_ve_withholding_muni/report/tiny_sxw2rml/tiny_sxw2rml.py' |
1776 | --- l10n_ve_withholding_muni/report/tiny_sxw2rml/tiny_sxw2rml.py 1970-01-01 00:00:00 +0000 |
1777 | +++ l10n_ve_withholding_muni/report/tiny_sxw2rml/tiny_sxw2rml.py 2011-09-22 17:22:23 +0000 |
1778 | @@ -0,0 +1,365 @@ |
1779 | +#!/usr/bin/python |
1780 | +#coding: utf-8 |
1781 | + |
1782 | +############################################################################## |
1783 | +# |
1784 | +# Copyright (c): |
1785 | +# |
1786 | +# 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de) |
1787 | +# 2005 Fabien Pinckaers, TINY SPRL. (http://tiny.be) |
1788 | +# |
1789 | +# WARNING: This program as such is intended to be used by professional |
1790 | +# programmers who take the whole responsability of assessing all potential |
1791 | +# consequences resulting from its eventual inadequacies and bugs |
1792 | +# End users who are looking for a ready-to-use solution with commercial |
1793 | +# garantees and support are strongly adviced to contact a Free Software |
1794 | +# Service Company |
1795 | +# |
1796 | +# This program is Free Software; you can redistribute it and/or |
1797 | +# modify it under the terms of the GNU General Public License |
1798 | +# as published by the Free Software Foundation; either version 2 |
1799 | +# of the License, or (at your option) any later version. |
1800 | +# |
1801 | +# This program is distributed in the hope that it will be useful, |
1802 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1803 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1804 | +# GNU General Public License for more details. |
1805 | +# |
1806 | +# You should have received a copy of the GNU General Public License |
1807 | +# along with this program; if not, write to the Free Software |
1808 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1809 | +# |
1810 | +############################################################################## |
1811 | + |
1812 | +""" |
1813 | +Tiny SXW2RML - The Tiny ERP's report engine |
1814 | + |
1815 | +Tiny SXW2RMLis part of the Tiny report project. |
1816 | +Tiny Report is a module that allows you to render high quality PDF document |
1817 | +from an OpenOffice template (.sxw) and any relationnal database. |
1818 | + |
1819 | +The whole source code is distributed under the terms of the |
1820 | +GNU Public Licence. |
1821 | + |
1822 | +(c) 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de) |
1823 | +(c) 2005-TODAY, Fabien Pinckaers - Tiny sprl |
1824 | +""" |
1825 | +__version__ = '0.9' |
1826 | + |
1827 | + |
1828 | +import re |
1829 | +import string |
1830 | +import os |
1831 | +import zipfile |
1832 | +import xml.dom.minidom |
1833 | +from reportlab.lib.units import toLength |
1834 | +import base64 |
1835 | + |
1836 | +class DomApiGeneral: |
1837 | + """General DOM API utilities.""" |
1838 | + def __init__(self,content_string="",file=""): |
1839 | + self.content_string = content_string |
1840 | + self.re_digits = re.compile(r"(.*?\d)(pt|cm|mm|inch|in)") |
1841 | + |
1842 | + def _unitTuple(self,string): |
1843 | + """Split values and units to a tuple.""" |
1844 | + temp = self.re_digits.findall(string) |
1845 | + if not temp: |
1846 | + return (string,"") |
1847 | + else: |
1848 | + return (temp[0]) |
1849 | + |
1850 | + def stringPercentToFloat(self,string): |
1851 | + temp = string.replace("""%""","") |
1852 | + return float(temp)/100 |
1853 | + |
1854 | + def findChildrenByName(self,parent,name,attr_dict={}): |
1855 | + """Helper functions. Does not work recursively. |
1856 | + Optional: also test for certain attribute/value pairs.""" |
1857 | + children = [] |
1858 | + for c in parent.childNodes: |
1859 | + if c.nodeType == c.ELEMENT_NODE and c.nodeName == name: |
1860 | + children.append(c) |
1861 | + if attr_dict == {}: |
1862 | + return children |
1863 | + else: |
1864 | + return self._selectForAttributes(nodelist=children,attr_dict=attr_dict) |
1865 | + |
1866 | + def _selectForAttributes(self,nodelist,attr_dict): |
1867 | + "Helper function.""" |
1868 | + selected_nodes = [] |
1869 | + for n in nodelist: |
1870 | + check = 1 |
1871 | + for a in attr_dict.keys(): |
1872 | + if n.getAttribute(a) != attr_dict[a]: |
1873 | + # at least one incorrect attribute value? |
1874 | + check = 0 |
1875 | + if check: |
1876 | + selected_nodes.append(n) |
1877 | + return selected_nodes |
1878 | + |
1879 | + def _stringToTuple(self,s): |
1880 | + """Helper function.""" |
1881 | + try: |
1882 | + temp = string.split(s,",") |
1883 | + return int(temp[0]),int(temp[1]) |
1884 | + except: |
1885 | + return None |
1886 | + |
1887 | + def _tupleToString(self,t): |
1888 | + try: |
1889 | + return self.openOfficeStringUtf8("%s,%s" % (t[0],t[1])) |
1890 | + except: |
1891 | + return None |
1892 | + |
1893 | + def _lengthToFloat(self,value): |
1894 | + v = value |
1895 | + if not self.re_digits.search(v): |
1896 | + return v |
1897 | + try: |
1898 | + if v[-4:] == "inch": |
1899 | + # OO files use "inch" instead of "in" in Reportlab units |
1900 | + v = v[:-2] |
1901 | + except: |
1902 | + pass |
1903 | + try: |
1904 | + c = round(toLength(v)) |
1905 | + return c |
1906 | + except: |
1907 | + return v |
1908 | + |
1909 | + def openOfficeStringUtf8(self,string): |
1910 | + if type(string) == unicode: |
1911 | + return string.encode("utf-8") |
1912 | + tempstring = unicode(string,"cp1252").encode("utf-8") |
1913 | + return tempstring |
1914 | + |
1915 | +class DomApi(DomApiGeneral): |
1916 | + """This class provides a DOM-API for XML-Files from an SXW-Archive.""" |
1917 | + def __init__(self,xml_content,xml_styles): |
1918 | + DomApiGeneral.__init__(self) |
1919 | + self.content_dom = xml.dom.minidom.parseString(xml_content) |
1920 | + self.styles_dom = xml.dom.minidom.parseString(xml_styles) |
1921 | + body = self.content_dom.getElementsByTagName("office:body") |
1922 | + self.body = body and body[0] |
1923 | + |
1924 | + # TODO: |
1925 | + self.style_dict = {} |
1926 | + self.style_properties_dict = {} |
1927 | + |
1928 | + # ******** always use the following order: |
1929 | + self.buildStyleDict() |
1930 | + self.buildStylePropertiesDict() |
1931 | + if self.styles_dom.getElementsByTagName("style:page-master").__len__()<>0: |
1932 | + self.page_master = self.styles_dom.getElementsByTagName("style:page-master")[0] |
1933 | + self.document = self.content_dom.getElementsByTagName("office:document-content")[0] |
1934 | + |
1935 | + def buildStylePropertiesDict(self): |
1936 | + for s in self.style_dict.keys(): |
1937 | + self.style_properties_dict[s] = self.getStylePropertiesDict(s) |
1938 | + |
1939 | + def updateWithPercents(self,dict,updatedict): |
1940 | + """Sometimes you find values like "115%" in the style hierarchy.""" |
1941 | + if not updatedict: |
1942 | + # no style hierarchies for this style? => |
1943 | + return |
1944 | + new_updatedict = copy.copy(updatedict) |
1945 | + for u in new_updatedict.keys(): |
1946 | + try: |
1947 | + if new_updatedict[u].find("""%""") != -1 and dict.has_key(u): |
1948 | + number = float(self.re_digits.search(dict[u]).group(1)) |
1949 | + unit = self.re_digits.search(dict[u]).group(2) |
1950 | + new_number = self.stringPercentToFloat(new_updatedict[u]) * number |
1951 | + if unit == "pt": |
1952 | + new_number = int(new_number) |
1953 | + # no floats allowed for "pt" |
1954 | + # OOo just takes the int, does not round (try it out!) |
1955 | + new_updatedict[u] = "%s%s" % (new_number,unit) |
1956 | + else: |
1957 | + dict[u] = new_updatedict[u] |
1958 | + except: |
1959 | + dict[u] = new_updatedict[u] |
1960 | + dict.update(new_updatedict) |
1961 | + |
1962 | + def normalizeStyleProperties(self): |
1963 | + """Transfer all style:style-properties attributes from the |
1964 | + self.style_properties_hierarchical dict to the automatic-styles |
1965 | + from content.xml. Use this function to preprocess content.xml for |
1966 | + XSLT transformations etc.Do not try to implement this function |
1967 | + with XSlT - believe me, it's a terrible task...""" |
1968 | + styles_styles = self.styles_dom.getElementsByTagName("style:style") |
1969 | + automatic_styles = self.content_dom.getElementsByTagName("office:automatic-styles")[0] |
1970 | + for s in styles_styles: |
1971 | + automatic_styles.appendChild(s.cloneNode(deep=1)) |
1972 | + content_styles = self.content_dom.getElementsByTagName("style:style") |
1973 | + # these are the content_styles with styles_styles added!!! |
1974 | + for s in content_styles: |
1975 | + c = self.findChildrenByName(s,"style:properties") |
1976 | + if c == []: |
1977 | + # some derived automatic styles do not have "style:properties": |
1978 | + temp = self.content_dom.createElement("style:properties") |
1979 | + s.appendChild(temp) |
1980 | + c = self.findChildrenByName(s,"style:properties") |
1981 | + c = c[0] |
1982 | + dict = self.style_properties_dict[(s.getAttribute("style:name")).encode("latin-1")] or {} |
1983 | + for attribute in dict.keys(): |
1984 | + c.setAttribute(self.openOfficeStringUtf8(attribute),self.openOfficeStringUtf8(dict[attribute])) |
1985 | + |
1986 | + def transferStylesXml(self): |
1987 | + """Transfer certain sub-trees from styles.xml to the normalized content.xml |
1988 | + (see above). It is not necessary to do this - for example - with paragraph styles. |
1989 | + the "normalized" style properties contain all information needed for |
1990 | + further processing.""" |
1991 | + # TODO: What about table styles etc.? |
1992 | + outline_styles = self.styles_dom.getElementsByTagName("text:outline-style") |
1993 | + t = self.content_dom.createElement("transferredfromstylesxml") |
1994 | + self.document.insertBefore(t,self.body) |
1995 | + t_new = self.body.previousSibling |
1996 | + try: |
1997 | + page_master = self.page_master |
1998 | + t_new.appendChild(page_master.cloneNode(deep=1)) |
1999 | + t_new.appendChild(outline_styles[0].cloneNode(deep=1)) |
2000 | + except: |
2001 | + pass |
2002 | + |
2003 | + def normalizeLength(self): |
2004 | + """Normalize all lengthes to floats (i.e: 1 inch = 72). |
2005 | + Always use this after "normalizeContent" and "transferStyles"!""" |
2006 | + # TODO: The complex attributes of table cell styles are not transferred yet. |
2007 | + #all_styles = self.content_dom.getElementsByTagName("style:properties") |
2008 | + #all_styles += self.content_dom.getElementsByTagName("draw:image") |
2009 | + all_styles = self.content_dom.getElementsByTagName("*") |
2010 | + for s in all_styles: |
2011 | + for x in s._attrs.keys(): |
2012 | + v = s.getAttribute(x) |
2013 | + s.setAttribute(x,"%s" % self._lengthToFloat(v)) |
2014 | + # convert float to string first! |
2015 | + |
2016 | + def normalizeTableColumns(self): |
2017 | + """Handle this strange table:number-columns-repeated attribute.""" |
2018 | + columns = self.content_dom.getElementsByTagName("table:table-column") |
2019 | + for c in columns: |
2020 | + if c.hasAttribute("table:number-columns-repeated"): |
2021 | + number = int(c.getAttribute("table:number-columns-repeated")) |
2022 | + c.removeAttribute("table:number-columns-repeated") |
2023 | + for i in range(number-1): |
2024 | + (c.parentNode).insertBefore(c.cloneNode(deep=1),c) |
2025 | + |
2026 | + def buildStyleDict(self): |
2027 | + """Store all style:style-nodes from content.xml and styles.xml in self.style_dict. |
2028 | + Caution: in this dict the nodes from two dom apis are merged!""" |
2029 | + for st in (self.styles_dom,self.content_dom): |
2030 | + for s in st.getElementsByTagName("style:style"): |
2031 | + name = s.getAttribute("style:name").encode("latin-1") |
2032 | + self.style_dict[name] = s |
2033 | + return True |
2034 | + |
2035 | + def toxml(self): |
2036 | + return self.content_dom.toxml(encoding="utf-8") |
2037 | + |
2038 | + def getStylePropertiesDict(self,style_name): |
2039 | + res = {} |
2040 | + |
2041 | + if self.style_dict[style_name].hasAttribute("style:parent-style-name"): |
2042 | + parent = self.style_dict[style_name].getAttribute("style:parent-style-name").encode("latin-1") |
2043 | + res = self.getStylePropertiesDict(parent) |
2044 | + |
2045 | + childs = self.style_dict[style_name].childNodes |
2046 | + for c in childs: |
2047 | + if c.nodeType == c.ELEMENT_NODE and c.nodeName == "style:properties": |
2048 | + for attr in c._attrs.keys(): |
2049 | + res[attr] = c.getAttribute(attr).encode("latin-1") |
2050 | + return res |
2051 | + |
2052 | +class PyOpenOffice(object): |
2053 | + """This is the main class which provides all functionality.""" |
2054 | + def __init__(self, path='.', save_pict=False): |
2055 | + self.path = path |
2056 | + self.save_pict = save_pict |
2057 | + self.images = {} |
2058 | + |
2059 | + def oo_read(self,fname): |
2060 | + z = zipfile.ZipFile(fname,"r") |
2061 | + content = z.read('content.xml') |
2062 | + style = z.read('styles.xml') |
2063 | + all = z.namelist() |
2064 | + for a in all: |
2065 | + if a[:9]=='Pictures/' and len(a)>10: |
2066 | + pic_content = z.read(a) |
2067 | + self.images[a[9:]] = pic_content |
2068 | + if self.save_pict: |
2069 | + f=open(os.path.join(self.path, os.path.basename(a)),"wb") |
2070 | + f.write(pic_content) |
2071 | + f.close() |
2072 | + z.close() |
2073 | + return content,style |
2074 | + |
2075 | + def oo_replace(self,content): |
2076 | + regex = [ |
2077 | + (r"<para[^>]*/>", ""), |
2078 | + #(r"<text:ordered-list.*?>(.*?)</text:ordered-list>", "$1"), |
2079 | + #(r"<text:unordered-list.*?>(.*?)</text:unordered-list>", "$1"), |
2080 | + (r"<para(.*)>(.*?)<text:line-break[^>]*/>", "<para$1>$2</para><para$1>"), |
2081 | + ] |
2082 | + for key,val in regex: |
2083 | + content = re.sub(key, val, content) |
2084 | + return content |
2085 | + |
2086 | + def unpackNormalize(self,sourcefile): |
2087 | + c,s = self.oo_read(sourcefile) |
2088 | + c = self.oo_replace(c) |
2089 | + dom = DomApi(c,s) |
2090 | + dom.normalizeStyleProperties() |
2091 | + dom.transferStylesXml() |
2092 | + dom.normalizeLength() |
2093 | + dom.normalizeTableColumns() |
2094 | + new_c = dom.toxml() |
2095 | + return new_c |
2096 | + |
2097 | +def sxw2rml(sxw_file, xsl, output='.', save_pict=False): |
2098 | + import libxslt |
2099 | + import libxml2 |
2100 | + tool = PyOpenOffice(output, save_pict = save_pict) |
2101 | + res = tool.unpackNormalize(sxw_file) |
2102 | + styledoc = libxml2.parseDoc(xsl) |
2103 | + style = libxslt.parseStylesheetDoc(styledoc) |
2104 | + doc = libxml2.parseMemory(res,len(res)) |
2105 | + result = style.applyStylesheet(doc, None) |
2106 | + |
2107 | + root = result.xpathEval("/document/stylesheet") |
2108 | + if root: |
2109 | + root=root[0] |
2110 | + images = libxml2.newNode("images") |
2111 | + for img in tool.images: |
2112 | + node = libxml2.newNode('image') |
2113 | + node.setProp('name', img) |
2114 | + node.setContent( base64.encodestring(tool.images[img])) |
2115 | + images.addChild(node) |
2116 | + root.addNextSibling(images) |
2117 | + try: |
2118 | + xml = style.saveResultToString(result) |
2119 | + return xml |
2120 | + except: |
2121 | + return result |
2122 | + |
2123 | +if __name__ == "__main__": |
2124 | + import optparse |
2125 | + parser = optparse.OptionParser( |
2126 | + version="Tiny Report v%s" % __version__, |
2127 | + usage = 'tiny_sxw2rml.py [options] file.sxw') |
2128 | + parser.add_option("-v", "--verbose", default=False, dest="verbose", help="enable basic debugging") |
2129 | + parser.add_option("-o", "--output", dest="output", default='.', help="directory of image output") |
2130 | + (opt, args) = parser.parse_args() |
2131 | + if len(args) != 1: |
2132 | + parser.error("incorrect number of arguments") |
2133 | + |
2134 | + import sys |
2135 | + import StringIO |
2136 | + |
2137 | + fname = sys.argv[1] |
2138 | + f = StringIO.StringIO(file(fname).read()) |
2139 | + |
2140 | + xsl = file(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'normalized_oo2rml.xsl')).read() |
2141 | + result = sxw2rml(f, xsl, output=opt.output, save_pict=False) |
2142 | + |
2143 | + print result |
2144 | |
2145 | === added file 'l10n_ve_withholding_muni/report/wh_muni_report.py' |
2146 | --- l10n_ve_withholding_muni/report/wh_muni_report.py 1970-01-01 00:00:00 +0000 |
2147 | +++ l10n_ve_withholding_muni/report/wh_muni_report.py 2011-09-22 17:22:23 +0000 |
2148 | @@ -0,0 +1,71 @@ |
2149 | +# -*- encoding: utf-8 -*- |
2150 | +############################################################################## |
2151 | +# |
2152 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
2153 | +# Javier Duran <javier.duran@netquatro.com> |
2154 | +# |
2155 | +# |
2156 | +# WARNING: This program as such is intended to be used by professional |
2157 | +# programmers who take the whole responsability of assessing all potential |
2158 | +# consequences resulting from its eventual inadequacies and bugs |
2159 | +# End users who are looking for a ready-to-use solution with commercial |
2160 | +# garantees and support are strongly adviced to contract a Free Software |
2161 | +# Service Company |
2162 | +# |
2163 | +# This program is Free Software; you can redistribute it and/or |
2164 | +# modify it under the terms of the GNU General Public License |
2165 | +# as published by the Free Software Foundation; either version 2 |
2166 | +# of the License, or (at your option) any later version. |
2167 | +# |
2168 | +# This program is distributed in the hope that it will be useful, |
2169 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2170 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2171 | +# GNU General Public License for more details. |
2172 | +# |
2173 | +# You should have received a copy of the GNU General Public License |
2174 | +# along with this program; if not, write to the Free Software |
2175 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
2176 | +# |
2177 | +############################################################################## |
2178 | + |
2179 | +import time |
2180 | +from report import report_sxw |
2181 | +from osv import osv |
2182 | +import pooler |
2183 | + |
2184 | +class rep_wh_muni(report_sxw.rml_parse): |
2185 | + def __init__(self, cr, uid, name, context): |
2186 | + super(rep_wh_muni, self).__init__(cr, uid, name, context) |
2187 | + self.localcontext.update({ |
2188 | + 'time': time, |
2189 | + 'get_partner_addr': self._get_partner_addr, |
2190 | + 'get_rif': self._get_rif |
2191 | + }) |
2192 | + |
2193 | + def _get_partner_addr(self, idp=None): |
2194 | + if not idp: |
2195 | + return [] |
2196 | + |
2197 | + addr_obj = self.pool.get('res.partner.address') |
2198 | + addr_inv = 'NO HAY DIRECCION FISCAL DEFINIDA' |
2199 | + addr_ids = addr_obj.search(self.cr,self.uid,[('partner_id','=',idp), ('type','=','invoice')]) |
2200 | + if addr_ids: |
2201 | + addr = addr_obj.browse(self.cr,self.uid, addr_ids[0]) |
2202 | + addr_inv = (addr.street or '')+' '+(addr.street2 or '')+' '+(addr.zip or '')+ ' '+(addr.city or '')+ ' '+ (addr.country_id and addr.country_id.name or '')+ ', TELF.:'+(addr.phone or '') |
2203 | + return addr_inv |
2204 | + |
2205 | + |
2206 | + def _get_rif(self, vat=''): |
2207 | + if not vat: |
2208 | + return [] |
2209 | + return vat[2:].replace(' ', '') |
2210 | + |
2211 | + |
2212 | + |
2213 | +report_sxw.report_sxw( |
2214 | + 'report.wh.muni_rep', |
2215 | + 'account.wh.munici', |
2216 | + 'addons/l10n_ve_withholding_muni/report/wh_muni_report.rml', |
2217 | + parser=rep_wh_muni, |
2218 | + header=False |
2219 | +) |
2220 | |
2221 | === added file 'l10n_ve_withholding_muni/report/wh_muni_report.rml' |
2222 | --- l10n_ve_withholding_muni/report/wh_muni_report.rml 1970-01-01 00:00:00 +0000 |
2223 | +++ l10n_ve_withholding_muni/report/wh_muni_report.rml 2011-09-22 17:22:23 +0000 |
2224 | @@ -0,0 +1,261 @@ |
2225 | +<?xml version="1.0"?> |
2226 | +<document filename="test.pdf"> |
2227 | + <template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20"> |
2228 | + <pageTemplate id="first"> |
2229 | + <frame id="first" x1="42.0" y1="42.0" width="528" height="708"/> |
2230 | + </pageTemplate> |
2231 | + </template> |
2232 | + <stylesheet> |
2233 | + <blockTableStyle id="Standard_Outline"> |
2234 | + <blockAlignment value="LEFT"/> |
2235 | + <blockValign value="TOP"/> |
2236 | + </blockTableStyle> |
2237 | + <blockTableStyle id="Tabla1"> |
2238 | + <blockAlignment value="LEFT"/> |
2239 | + <blockValign value="TOP"/> |
2240 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
2241 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/> |
2242 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
2243 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/> |
2244 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> |
2245 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
2246 | + </blockTableStyle> |
2247 | + <blockTableStyle id="Tabla5"> |
2248 | + <blockAlignment value="LEFT"/> |
2249 | + <blockValign value="TOP"/> |
2250 | + </blockTableStyle> |
2251 | + <blockTableStyle id="Tabla6"> |
2252 | + <blockAlignment value="LEFT"/> |
2253 | + <blockValign value="TOP"/> |
2254 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
2255 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/> |
2256 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/> |
2257 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> |
2258 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,1" stop="0,-1"/> |
2259 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,1" stop="1,-1"/> |
2260 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,2" stop="0,-1"/> |
2261 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
2262 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,2" stop="1,-1"/> |
2263 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
2264 | + </blockTableStyle> |
2265 | + <blockTableStyle id="Tabla3"> |
2266 | + <blockAlignment value="LEFT"/> |
2267 | + <blockValign value="TOP"/> |
2268 | + </blockTableStyle> |
2269 | + <blockTableStyle id="Tabla8"> |
2270 | + <blockAlignment value="LEFT"/> |
2271 | + <blockValign value="TOP"/> |
2272 | + </blockTableStyle> |
2273 | + <blockTableStyle id="Tabla2"> |
2274 | + <blockAlignment value="LEFT"/> |
2275 | + <blockValign value="TOP"/> |
2276 | + </blockTableStyle> |
2277 | + <initialize> |
2278 | + <paraStyle name="all" alignment="justify"/> |
2279 | + </initialize> |
2280 | + <paraStyle name="P1" fontName="Helvetica"/> |
2281 | + <paraStyle name="P2" fontName="Helvetica-Bold"/> |
2282 | + <paraStyle name="P3" fontName="Helvetica" fontSize="2.0" leading="3"/> |
2283 | + <paraStyle name="P4" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT"/> |
2284 | + <paraStyle name="P5" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT"/> |
2285 | + <paraStyle name="P6" fontName="Helvetica-Bold" fontSize="16.0" leading="20" alignment="CENTER"/> |
2286 | + <paraStyle name="P7" fontName="Helvetica"/> |
2287 | + <paraStyle name="P8" fontName="Helvetica-Bold" fontSize="11.0" leading="14"/> |
2288 | + <paraStyle name="P9" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2289 | + <paraStyle name="P10" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2290 | + <paraStyle name="P11" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2291 | + <paraStyle name="P12" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT"/> |
2292 | + <paraStyle name="P13" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT"/> |
2293 | + <paraStyle name="P14" fontName="Helvetica" fontSize="12.0" leading="15" alignment="RIGHT"/> |
2294 | + <paraStyle name="P15" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT"/> |
2295 | + <paraStyle name="P16" fontName="Helvetica" fontSize="2.0" leading="3" alignment="CENTER"/> |
2296 | + <paraStyle name="P17" fontName="Helvetica" fontSize="11.0" leading="14" alignment="RIGHT"/> |
2297 | + <paraStyle name="P18" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT"/> |
2298 | + <paraStyle name="P19" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT"/> |
2299 | + <paraStyle name="P20" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT"/> |
2300 | + <paraStyle name="P21" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/> |
2301 | + <paraStyle name="P22" fontName="Helvetica" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2302 | + <paraStyle name="P23" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2303 | + <paraStyle name="P24" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="11.0" leading="14" alignment="LEFT"/> |
2304 | + <paraStyle name="Standard" fontName="Times-Roman"/> |
2305 | + <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/> |
2306 | + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
2307 | + <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
2308 | + <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
2309 | + <paraStyle name="Index" fontName="Times-Roman"/> |
2310 | + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
2311 | + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2312 | + <paraStyle name="Table Contents" fontName="Times-Roman" fontSize="8.0" leading="10"/> |
2313 | + <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
2314 | + <paraStyle name="Table Heading" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="CENTER"/> |
2315 | + <paraStyle name="Table" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
2316 | + </stylesheet> |
2317 | + <images/> |
2318 | + <story> |
2319 | + <para style="P9">[[repeatIn(objects,'o')]]</para> |
2320 | + <para style="P6">COMPROBANTE RETENCION IMPUESTOS MUNICIPALES</para> |
2321 | + <blockTable colWidths="321.0,206.0" style="Tabla1"> |
2322 | + <tr> |
2323 | + <td> |
2324 | + <para style="P12"><font face="Times-Roman" size="14.0">[[ company.partner_id.name ]]</font>[[ get_rif(company.partner_id.vat) or '' ]]</para> |
2325 | + <para style="P4">[[ get_partner_addr( company.partner_id.id ) ]]</para> |
2326 | + </td> |
2327 | + <td> |
2328 | + <para style="P23">NRO. COMPROBANTE: [[ o.number]]</para> |
2329 | + <para style="P22">Fecha: <font face="Times-Roman">[[ time.strftime('%d/%m/%Y', time.strptime(o.date_ret, '%Y-%m-%d')) ]]</font></para> |
2330 | + <para style="P22">PERIODO FISCAL:<font face="Times-Roman"/></para> |
2331 | + <blockTable colWidths="100.0,100.0" style="Tabla5"> |
2332 | + <tr> |
2333 | + <td> |
2334 | + <para style="P23">AÑO</para> |
2335 | + </td> |
2336 | + <td> |
2337 | + <para style="P23">MES </para> |
2338 | + </td> |
2339 | + </tr> |
2340 | + <tr> |
2341 | + <td> |
2342 | + <para style="P23">[[ o.period_id.fiscalyear_id.name]] </para> |
2343 | + </td> |
2344 | + <td> |
2345 | + <para style="P23">[[ o.period_id.name]] </para> |
2346 | + </td> |
2347 | + </tr> |
2348 | + </blockTable> |
2349 | + <para style="P23"> |
2350 | + <font color="white"> </font> |
2351 | + </para> |
2352 | + </td> |
2353 | + </tr> |
2354 | + </blockTable> |
2355 | + <para style="P7">SUJETO RETENIDO:</para> |
2356 | + <blockTable colWidths="80.0,447.0" style="Tabla6"> |
2357 | + <tr> |
2358 | + <td> |
2359 | + <para style="P1"> |
2360 | + <font face="Times-Roman" size="11.0">Razón Social</font> |
2361 | + <font face="Times-Roman"/> |
2362 | + <font face="Times-Roman"/> |
2363 | + </para> |
2364 | + </td> |
2365 | + <td> |
2366 | + <para style="P2">[[ o.partner_id.name ]]</para> |
2367 | + </td> |
2368 | + </tr> |
2369 | + <tr> |
2370 | + <td> |
2371 | + <para style="P8">Dirección Fiscal</para> |
2372 | + </td> |
2373 | + <td> |
2374 | + <para style="P2">[[ get_partner_addr( o.partner_id.id ) ]]</para> |
2375 | + </td> |
2376 | + </tr> |
2377 | + <tr> |
2378 | + <td> |
2379 | + <para style="P1"> |
2380 | + <font face="Times-Roman" size="11.0">Nro. R.I.F.</font> |
2381 | + </para> |
2382 | + </td> |
2383 | + <td> |
2384 | + <para style="P2">[[ get_rif(o.partner_id.vat) or '' ]]</para> |
2385 | + </td> |
2386 | + </tr> |
2387 | + </blockTable> |
2388 | + <para style="P3"> |
2389 | + <font color="white"> </font> |
2390 | + </para> |
2391 | + <section> |
2392 | + <para style="P10">[[repeatIn(o.munici_line_ids,'l')]]</para> |
2393 | + <para style="P11">Retención por concepto de impuestos municipales:</para> |
2394 | + <blockTable colWidths="527.0" style="Tabla3"> |
2395 | + <tr> |
2396 | + <td> |
2397 | + <para style="P20">COMPROBANTE DE RETENCION DE IMPUESTOS MUNICIPALES DE FACTURA: <font face="Helvetica" size="9.0">[[ l.invoice_id.reference ]]</font></para> |
2398 | + </td> |
2399 | + </tr> |
2400 | + </blockTable> |
2401 | + <para style="P11"> |
2402 | + <font color="white"> </font> |
2403 | + </para> |
2404 | + <blockTable colWidths="100.0,93.0,334.0" style="Tabla8"> |
2405 | + <tr> |
2406 | + <td> |
2407 | + <para style="P20">Base imponible</para> |
2408 | + </td> |
2409 | + <td> |
2410 | + <para style="P15">[[ l.invoice_id.amount_untaxed ]]</para> |
2411 | + </td> |
2412 | + </tr> |
2413 | + <tr> |
2414 | + <td> |
2415 | + <para style="P20">Exento</para> |
2416 | + </td> |
2417 | + <td> |
2418 | + <para style="P18"> |
2419 | + <font color="white"> </font> |
2420 | + </para> |
2421 | + </td> |
2422 | + </tr> |
2423 | + <tr> |
2424 | + <td> |
2425 | + <para style="P20">Retención</para> |
2426 | + </td> |
2427 | + <td> |
2428 | + <para style="P15">[[ o.amount ]]</para> |
2429 | + </td> |
2430 | + <td> |
2431 | + <para style="P15"><font face="Helvetica" size="8.0">% Retención: </font>[[ l.retencion_munici ]]%</para> |
2432 | + </td> |
2433 | + </tr> |
2434 | + </blockTable> |
2435 | + <para style="P10"> |
2436 | + <font color="white"> </font> |
2437 | + </para> |
2438 | + </section> |
2439 | + <blockTable colWidths="327.0,200.0" style="Tabla2"> |
2440 | + <tr> |
2441 | + <td> |
2442 | + <para style="P12"> |
2443 | + <font color="white"> </font> |
2444 | + </para> |
2445 | + </td> |
2446 | + </tr> |
2447 | + <tr> |
2448 | + <td> |
2449 | + <para style="P16"> |
2450 | + <font color="white"> </font> |
2451 | + </para> |
2452 | + </td> |
2453 | + </tr> |
2454 | + <tr> |
2455 | + <td> |
2456 | + <para style="P24">----------------------------------------------------</para> |
2457 | + <para style="P13">Por la Empresa</para> |
2458 | + </td> |
2459 | + <td> |
2460 | + <para style="P24">----------------------------------------------------</para> |
2461 | + <para style="P13">POR<font color="white"> .........</font>[[ o.partner_id.name ]]<font color="white"> .........</font></para> |
2462 | + </td> |
2463 | + </tr> |
2464 | + <tr> |
2465 | + <td> |
2466 | + <para style="P21"> |
2467 | + <font color="white"> </font> |
2468 | + </para> |
2469 | + </td> |
2470 | + <td> |
2471 | + <para style="P14"> |
2472 | + <font color="white"> </font> |
2473 | + </para> |
2474 | + </td> |
2475 | + </tr> |
2476 | + </blockTable> |
2477 | + <para style="P17"> |
2478 | + <font color="white"> </font> |
2479 | + </para> |
2480 | + <para style="P19"> |
2481 | + <font color="white"> </font> |
2482 | + </para> |
2483 | + </story> |
2484 | +</document> |
2485 | + |
2486 | |
2487 | === added file 'l10n_ve_withholding_muni/report/wh_muni_report.sxw' |
2488 | Binary files l10n_ve_withholding_muni/report/wh_muni_report.sxw 1970-01-01 00:00:00 +0000 and l10n_ve_withholding_muni/report/wh_muni_report.sxw 2011-09-22 17:22:23 +0000 differ |
2489 | === added file 'l10n_ve_withholding_muni/retencion_munici_wizard.xml' |
2490 | --- l10n_ve_withholding_muni/retencion_munici_wizard.xml 1970-01-01 00:00:00 +0000 |
2491 | +++ l10n_ve_withholding_muni/retencion_munici_wizard.xml 2011-09-22 17:22:23 +0000 |
2492 | @@ -0,0 +1,16 @@ |
2493 | +<?xml version="1.0" encoding="utf-8"?> |
2494 | +<openerp> |
2495 | + <data> |
2496 | + |
2497 | + |
2498 | + <wizard |
2499 | + string="Reporte Seniat" |
2500 | + model="account.retencion.munici" |
2501 | + name="account.ret.munici.xml.seniat" |
2502 | + id="wizard_ret_munici_xml_seniat" /> |
2503 | + |
2504 | + |
2505 | + |
2506 | + |
2507 | + </data> |
2508 | +</openerp> |
2509 | |
2510 | === added directory 'l10n_ve_withholding_muni/security' |
2511 | === added file 'l10n_ve_withholding_muni/security/ir.model.access.csv' |
2512 | --- l10n_ve_withholding_muni/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
2513 | +++ l10n_ve_withholding_muni/security/ir.model.access.csv 2011-09-22 17:22:23 +0000 |
2514 | @@ -0,0 +1,5 @@ |
2515 | +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
2516 | +"access_account_wh_muni_user","account.wh.muni.user","model_account_wh_munici","l10n_ve_withholding_muni.group_account_wh_muni_user",1,0,0,0 |
2517 | +"access_account_wh_muni_line_user","account.wh.muni.line.user","model_account_wh_munici_line","l10n_ve_withholding_muni.group_account_wh_muni_user",1,0,0,0 |
2518 | +"access_account_wh_muni_manager","account.wh.muni.manager","model_account_wh_munici","l10n_ve_withholding_muni.group_account_wh_muni_manager",1,1,1,1 |
2519 | +"access_account_wh_muni_line_manager","account.wh.muni.line.manager","model_account_wh_munici_line","l10n_ve_withholding_muni.group_account_wh_muni_manager",1,1,1,1 |
2520 | |
2521 | === added file 'l10n_ve_withholding_muni/security/wh_muni_security.xml' |
2522 | --- l10n_ve_withholding_muni/security/wh_muni_security.xml 1970-01-01 00:00:00 +0000 |
2523 | +++ l10n_ve_withholding_muni/security/wh_muni_security.xml 2011-09-22 17:22:23 +0000 |
2524 | @@ -0,0 +1,13 @@ |
2525 | +<?xml version="1.0" encoding="utf-8"?> |
2526 | +<openerp> |
2527 | +<data noupdate="0"> |
2528 | + |
2529 | + <record id="group_account_wh_muni_user" model="res.groups"> |
2530 | + <field name="name">Withhold Local / User</field> |
2531 | + </record> |
2532 | + <record id="group_account_wh_muni_manager" model="res.groups"> |
2533 | + <field name="name">Withhold Local / Manager</field> |
2534 | + </record> |
2535 | + |
2536 | +</data> |
2537 | +</openerp> |
2538 | |
2539 | === added file 'l10n_ve_withholding_muni/wh_muni.py' |
2540 | --- l10n_ve_withholding_muni/wh_muni.py 1970-01-01 00:00:00 +0000 |
2541 | +++ l10n_ve_withholding_muni/wh_muni.py 2011-09-22 17:22:23 +0000 |
2542 | @@ -0,0 +1,323 @@ |
2543 | +# -*- encoding: utf-8 -*- |
2544 | +############################################################################## |
2545 | +# |
2546 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
2547 | +# Javier Duran <javier.duran@netquatro.com> |
2548 | +# |
2549 | +# |
2550 | +# WARNING: This program as such is intended to be used by professional |
2551 | +# programmers who take the whole responsability of assessing all potential |
2552 | +# consequences resulting from its eventual inadequacies and bugs |
2553 | +# End users who are looking for a ready-to-use solution with commercial |
2554 | +# garantees and support are strongly adviced to contract a Free Software |
2555 | +# Service Company |
2556 | +# |
2557 | +# This program is Free Software; you can redistribute it and/or |
2558 | +# modify it under the terms of the GNU General Public License |
2559 | +# as published by the Free Software Foundation; either version 2 |
2560 | +# of the License, or (at your option) any later version. |
2561 | +# |
2562 | +# This program is distributed in the hope that it will be useful, |
2563 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2564 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2565 | +# GNU General Public License for more details. |
2566 | +# |
2567 | +# You should have received a copy of the GNU General Public License |
2568 | +# along with this program; if not, write to the Free Software |
2569 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
2570 | +# |
2571 | +############################################################################## |
2572 | + |
2573 | +from osv import osv, fields |
2574 | +import time |
2575 | +from tools import config |
2576 | +from tools.translate import _ |
2577 | +import decimal_precision as dp |
2578 | + |
2579 | + |
2580 | +class account_wh_munici(osv.osv): |
2581 | + |
2582 | + def _get_type(self, cr, uid, context=None): |
2583 | + if context is None: |
2584 | + context = {} |
2585 | + type = context.get('type', 'in_invoice') |
2586 | + return type |
2587 | + |
2588 | + def _get_journal(self, cr, uid, context): |
2589 | + if context is None: |
2590 | + context = {} |
2591 | + type_inv = context.get('type', 'in_invoice') |
2592 | + type2journal = {'out_invoice': 'mun_sale', 'in_invoice': 'mun_purchase'} |
2593 | + journal_obj = self.pool.get('account.journal') |
2594 | + res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'mun_purchase'))], limit=1) |
2595 | + if res: |
2596 | + return res[0] |
2597 | + else: |
2598 | + return False |
2599 | + |
2600 | + def _get_currency(self, cr, uid, context): |
2601 | + user = self.pool.get('res.users').browse(cr, uid, [uid])[0] |
2602 | + if user.company_id: |
2603 | + return user.company_id.currency_id.id |
2604 | + else: |
2605 | + return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0] |
2606 | + |
2607 | + _name = "account.wh.munici" |
2608 | + _description = "Local Withholding" |
2609 | + _columns = { |
2610 | + 'name': fields.char('Description', size=64, readonly=True, states={'draft':[('readonly',False)]}, required=True, help="Description of withholding"), |
2611 | + 'code': fields.char('Code', size=32, readonly=True, states={'draft':[('readonly',False)]}, help="Withholding reference"), |
2612 | + 'number': fields.char('Number', size=32, readonly=True, states={'draft':[('readonly',False)]}, help="Withholding number"), |
2613 | + 'type': fields.selection([ |
2614 | + ('out_invoice','Customer Invoice'), |
2615 | + ('in_invoice','Supplier Invoice'), |
2616 | + ],'Type', readonly=True, help="Withholding type"), |
2617 | + 'state': fields.selection([ |
2618 | + ('draft','Draft'), |
2619 | + ('confirmed', 'Confirmed'), |
2620 | + ('done','Done'), |
2621 | + ('cancel','Cancelled') |
2622 | + ],'Estado', readonly=True, help="Estado del Comprobante"), |
2623 | + 'date_ret': fields.date('Withholding date', readonly=True, states={'draft':[('readonly',False)]}, help="Keep empty to use the current date"), |
2624 | + 'date': fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}, help="Date"), |
2625 | + 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], readonly=True, states={'draft':[('readonly',False)]}, help="Keep empty to use the period of the validation(Withholding date) date."), |
2626 | + 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="The pay account used for this withholding."), |
2627 | + 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True, required=True, states={'draft':[('readonly',False)]}, help="Withholding customer/supplier"), |
2628 | + 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Currency"), |
2629 | + 'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}, help="Journal entry"), |
2630 | + 'company_id': fields.many2one('res.company', 'Company', required=True, help="Company"), |
2631 | + 'munici_line_ids': fields.one2many('account.wh.munici.line', 'retention_id', 'Local withholding lines', readonly=True, states={'draft':[('readonly',False)]}, help="Facturas a la cual se realizarán las retenciones"), |
2632 | + 'amount': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount withheld"), |
2633 | + 'move_id':fields.many2one('account.move', 'Account Entry'), |
2634 | + |
2635 | + |
2636 | + } |
2637 | + _defaults = { |
2638 | + 'type': _get_type, |
2639 | + 'state': lambda *a: 'draft', |
2640 | + 'journal_id': _get_journal, |
2641 | + 'currency_id': _get_currency, |
2642 | + 'company_id': lambda self, cr, uid, context: \ |
2643 | + self.pool.get('res.users').browse(cr, uid, uid, |
2644 | + context=context).company_id.id, |
2645 | + |
2646 | + } |
2647 | + |
2648 | + _sql_constraints = [ |
2649 | + ('ret_num_uniq', 'unique (number)', 'number must be unique !') |
2650 | + ] |
2651 | + |
2652 | + |
2653 | + |
2654 | + def action_confirm(self, cr, uid, ids, context={}): |
2655 | + obj=self.pool.get('account.wh.munici').browse(cr,uid,ids) |
2656 | + total=0 |
2657 | + for i in obj[0].munici_line_ids: |
2658 | + if i.amount >= i.invoice_id.check_total*0.15: |
2659 | + raise osv.except_osv(_('Invalid action !'), _("The line containing the document '%s' looks as if the amount withheld was wrong please check.!") % (i.invoice_id.reference)) |
2660 | + total+=i.amount |
2661 | + self.write(cr,uid,ids,{'amount':total}) |
2662 | + self.write(cr, uid, ids, {'state':'confirmed'}) |
2663 | + return True |
2664 | + |
2665 | + |
2666 | + def action_number(self, cr, uid, ids, *args): |
2667 | + obj_ret = self.browse(cr, uid, ids)[0] |
2668 | + if obj_ret.type == 'in_invoice': |
2669 | + cr.execute('SELECT id, number ' \ |
2670 | + 'FROM account_wh_munici ' \ |
2671 | + 'WHERE id IN ('+','.join(map(str,ids))+')') |
2672 | + |
2673 | + for (id, number) in cr.fetchall(): |
2674 | + if not number: |
2675 | + number = self.pool.get('ir.sequence').get(cr, uid, 'account.wh.muni.%s' % obj_ret.type) |
2676 | + cr.execute('UPDATE account_wh_munici SET number=%s ' \ |
2677 | + 'WHERE id=%s', (number, id)) |
2678 | + |
2679 | + |
2680 | + return True |
2681 | + |
2682 | + |
2683 | + def action_done(self, cr, uid, ids, context={}): |
2684 | + self.action_number(cr, uid, ids) |
2685 | + self.action_move_create(cr, uid, ids) |
2686 | + self.write(cr, uid, ids, {'state':'done'}) |
2687 | + return True |
2688 | + |
2689 | + |
2690 | + def action_move_create(self, cr, uid, ids, *args): |
2691 | + inv_obj = self.pool.get('account.invoice') |
2692 | + context = {} |
2693 | + |
2694 | + for ret in self.browse(cr, uid, ids): |
2695 | + for line in ret.munici_line_ids: |
2696 | + if line.move_id or line.invoice_id.wh_local: |
2697 | + raise osv.except_osv(_('Invoice already withhold !'),_("You must omit the follow invoice '%s' !") % (line.invoice_id.name,)) |
2698 | + return False |
2699 | + |
2700 | + acc_id = ret.account_id.id |
2701 | + if not ret.date_ret: |
2702 | + self.write(cr, uid, [ret.id], {'date_ret':time.strftime('%Y-%m-%d')}) |
2703 | + |
2704 | + period_id = ret.period_id and ret.period_id.id or False |
2705 | + journal_id = ret.journal_id.id |
2706 | + if not period_id: |
2707 | + period_ids = self.pool.get('account.period').search(cr,uid,[('date_start','<=',ret.date_ret or time.strftime('%Y-%m-%d')),('date_stop','>=',ret.date_ret or time.strftime('%Y-%m-%d'))]) |
2708 | + if len(period_ids): |
2709 | + period_id = period_ids[0] |
2710 | + else: |
2711 | + raise osv.except_osv(_('Warning !'), _("No se encontro un periodo fiscal para esta fecha: '%s' por favor verificar.!") % (ret.date_ret or time.strftime('%Y-%m-%d'))) |
2712 | + |
2713 | + if ret.munici_line_ids: |
2714 | + for line in ret.munici_line_ids: |
2715 | + writeoff_account_id = False |
2716 | + writeoff_journal_id = False |
2717 | + amount = line.amount |
2718 | + name = 'COMP. RET. MUN ' + ret.number |
2719 | + ret_move = inv_obj.ret_and_reconcile(cr, uid, [line.invoice_id.id], |
2720 | + amount, acc_id, period_id, journal_id, writeoff_account_id, |
2721 | + period_id, writeoff_journal_id, ret.date_ret, name, context) |
2722 | + |
2723 | + # make the retencion line point to that move |
2724 | + rl = { |
2725 | + 'move_id': ret_move['move_id'], |
2726 | + } |
2727 | + lines = [(1, line.id, rl)] |
2728 | + self.write(cr, uid, [ret.id], {'munici_line_ids':lines, 'period_id':period_id}) |
2729 | + |
2730 | + return True |
2731 | + |
2732 | + |
2733 | + def onchange_partner_id(self, cr, uid, ids, type, partner_id): |
2734 | + acc_id = False |
2735 | + if partner_id: |
2736 | + p = self.pool.get('res.partner').browse(cr, uid, partner_id) |
2737 | + if type in ('out_invoice', 'out_refund'): |
2738 | + acc_id = p.property_wh_munici_receivable.id |
2739 | + else: |
2740 | + acc_id = p.property_wh_munici_payable.id |
2741 | + |
2742 | + self._update_check(cr, uid, ids, partner_id) |
2743 | + result = {'value': { |
2744 | + 'account_id': acc_id} |
2745 | + } |
2746 | + |
2747 | + return result |
2748 | + |
2749 | + |
2750 | + def _update_check(self, cr, uid, ids, partner_id, context={}): |
2751 | + if ids: |
2752 | + ret = self.browse(cr, uid, ids[0]) |
2753 | + inv_str = '' |
2754 | + for line in ret.munici_line_ids: |
2755 | + if line.invoice_id.partner_id.id != partner_id: |
2756 | + inv_str+= '%s'% '\n'+line.invoice_id.name |
2757 | + |
2758 | + if inv_str: |
2759 | + raise osv.except_osv('Incorrect Invoices !',"The following invoices are not the selected partner: %s " % (inv_str,)) |
2760 | + |
2761 | + return True |
2762 | + |
2763 | + def _new_check(self, cr, uid, values, context={}): |
2764 | + lst_inv = [] |
2765 | + |
2766 | + if 'munici_line_ids' in values and values['munici_line_ids']: |
2767 | + if 'partner_id' in values and values['partner_id']: |
2768 | + for l in values['munici_line_ids']: |
2769 | + if 'invoice_id' in l[2] and l[2]['invoice_id']: |
2770 | + lst_inv.append(l[2]['invoice_id']) |
2771 | + |
2772 | + if lst_inv: |
2773 | + invoices = self.pool.get('account.invoice').browse(cr, uid, lst_inv) |
2774 | + inv_str = '' |
2775 | + for inv in invoices: |
2776 | + if inv.partner_id.id != values['partner_id']: |
2777 | + inv_str+= '%s'% '\n'+inv.name |
2778 | + |
2779 | + if inv_str: |
2780 | + raise osv.except_osv('Incorrect Invoices !',"The following invoices are not the selected partner: %s " % (inv_str,)) |
2781 | + |
2782 | + return True |
2783 | + |
2784 | + |
2785 | + |
2786 | + def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): |
2787 | + if not context: |
2788 | + context={} |
2789 | + ret = self.browse(cr, uid, ids[0]) |
2790 | + if update_check: |
2791 | + if 'partner_id' in vals and vals['partner_id']: |
2792 | + self._update_check(cr, uid, ids, vals['partner_id'], context) |
2793 | + else: |
2794 | + self._update_check(cr, uid, ids, ret.partner_id.id, context) |
2795 | + |
2796 | + return super(account_wh_munici, self).write(cr, uid, ids, vals, context=context) |
2797 | + |
2798 | + |
2799 | + def create(self, cr, uid, vals, context=None, check=True): |
2800 | + if not context: |
2801 | + context={} |
2802 | + if check: |
2803 | + self._new_check(cr, uid, vals, context) |
2804 | + |
2805 | + return super(account_wh_munici, self).create(cr, uid, vals, context) |
2806 | + |
2807 | +account_wh_munici() |
2808 | + |
2809 | + |
2810 | + |
2811 | +class account_wh_munici_line(osv.osv): |
2812 | + |
2813 | + def default_get(self, cr, uid, fields, context={}): |
2814 | + data = super(account_wh_munici_line, self).default_get(cr, uid, fields, context) |
2815 | + self.munici_context = context |
2816 | + return data |
2817 | +#TODO |
2818 | +#necesito crear el campo y tener la forma de calcular el monto del impuesto |
2819 | +#munici retenido en la factura |
2820 | + |
2821 | + |
2822 | + _name = "account.wh.munici.line" |
2823 | + _description = "Local Withholding Line" |
2824 | + _columns = { |
2825 | + 'name': fields.char('Description', size=64, required=True, help="Local Withholding line Description"), |
2826 | + 'retention_id': fields.many2one('account.wh.munici', 'Local withholding', ondelete='cascade', help="Local withholding"), |
2827 | + 'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True, ondelete='set null', help="Withholding invoice"), |
2828 | + 'amount':fields.float('Amount', digits_compute= dp.get_precision('Withhold')), |
2829 | + 'move_id': fields.many2one('account.move', 'Account Entry', readonly=True, help="Account Entry"), |
2830 | + 'wh_loc_rate':fields.float('Rate', help="Local withholding rate"), |
2831 | + 'concepto_id': fields.integer('Concept', size=3, help="Local withholding concept"), |
2832 | + |
2833 | + |
2834 | + } |
2835 | + _defaults = { |
2836 | + 'concepto_id': lambda *a: 1, |
2837 | + |
2838 | + } |
2839 | + _sql_constraints = [ |
2840 | + ('munici_fact_uniq', 'unique (invoice_id)', 'The invoice has already assigned in local withholding, you cannot assigned it twice!') |
2841 | + ] |
2842 | + |
2843 | + |
2844 | + def onchange_invoice_id(self, cr, uid, ids, invoice_id, context={}): |
2845 | + lines = [] |
2846 | + |
2847 | + if hasattr(self, 'munici_context') and ('lines' in self.munici_context): |
2848 | + lines = [x[2] for x in self.munici_context['lines']] |
2849 | + if not invoice_id: |
2850 | + return {'value':{'amount':0.0}} |
2851 | + else: |
2852 | + ok = True |
2853 | + res = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context) |
2854 | + cr.execute('select retention_id from account_wh_munici_line where invoice_id=%s', (invoice_id,)) |
2855 | + ret_ids = cr.fetchone() |
2856 | + ok = ok and bool(ret_ids) |
2857 | + if ok: |
2858 | + ret = self.pool.get('account.wh.munici').browse(cr, uid, ret_ids[0], context) |
2859 | + raise osv.except_osv('Assigned Invoice !',"The invoice has already assigned in local withholding code: '%s' !" % (ret.code,)) |
2860 | + |
2861 | + total = res.amount_total |
2862 | + return {'value' : {'amount':total}} |
2863 | + |
2864 | + |
2865 | +account_wh_munici_line() |
2866 | |
2867 | === added file 'l10n_ve_withholding_muni/wh_muni_report.xml' |
2868 | --- l10n_ve_withholding_muni/wh_muni_report.xml 1970-01-01 00:00:00 +0000 |
2869 | +++ l10n_ve_withholding_muni/wh_muni_report.xml 2011-09-22 17:22:23 +0000 |
2870 | @@ -0,0 +1,15 @@ |
2871 | +<?xml version="1.0" encoding="utf-8"?> |
2872 | +<openerp> |
2873 | + <data> |
2874 | + <report |
2875 | + id="report_wh_muni" |
2876 | + model="account.wh.munici" |
2877 | + name="wh.muni_rep" |
2878 | + rml="l10n_ve_withholding_muni/report/wh_muni_report.rml" |
2879 | + string="Comprobante Retencion Municipal" |
2880 | + header="False" |
2881 | + auto="False" /> |
2882 | + |
2883 | + |
2884 | + </data> |
2885 | +</openerp> |
2886 | |
2887 | === added file 'l10n_ve_withholding_muni/wh_muni_sequence.xml' |
2888 | --- l10n_ve_withholding_muni/wh_muni_sequence.xml 1970-01-01 00:00:00 +0000 |
2889 | +++ l10n_ve_withholding_muni/wh_muni_sequence.xml 2011-09-22 17:22:23 +0000 |
2890 | @@ -0,0 +1,26 @@ |
2891 | +<?xml version="1.0" encoding="utf-8"?> |
2892 | +<openerp> |
2893 | + <data noupdate="1"> |
2894 | + |
2895 | + <!-- Sequences type for account.wh.munici --> |
2896 | + |
2897 | + |
2898 | + <record id="seq_type_account_wh_muni_purchase" model="ir.sequence.type"> |
2899 | + <field name="name">Withholding local.purchase</field> |
2900 | + <field name="code">account.wh.muni.in_invoice</field> |
2901 | + </record> |
2902 | + |
2903 | + <!-- Sequences for account.wh.munici --> |
2904 | + |
2905 | + |
2906 | + <record id="seq_account_retencion_munici_compras" model="ir.sequence"> |
2907 | + <field name="name">Withholding local purchase</field> |
2908 | + <field name="code">account.wh.muni.in_invoice</field> |
2909 | + <field name="prefix">RET-MUNI</field> |
2910 | + <field name="padding">8</field> |
2911 | + <field name="number_increment">1</field> |
2912 | + </record> |
2913 | + |
2914 | + |
2915 | + </data> |
2916 | +</openerp> |
2917 | |
2918 | === added file 'l10n_ve_withholding_muni/wh_muni_view.xml' |
2919 | --- l10n_ve_withholding_muni/wh_muni_view.xml 1970-01-01 00:00:00 +0000 |
2920 | +++ l10n_ve_withholding_muni/wh_muni_view.xml 2011-09-22 17:22:23 +0000 |
2921 | @@ -0,0 +1,207 @@ |
2922 | +<?xml version="1.0" encoding="utf-8"?> |
2923 | +<openerp> |
2924 | + <data> |
2925 | + |
2926 | + <!-- |
2927 | + ===================================================== |
2928 | + Withholding Line |
2929 | + ===================================================== |
2930 | + --> |
2931 | + |
2932 | + <record id="view_wh_muni_line_tree" model="ir.ui.view"> |
2933 | + <field name="name">account.wh.munici.line.tree</field> |
2934 | + <field name="model">account.wh.munici.line</field> |
2935 | + <field name="type">tree</field> |
2936 | + <field name="arch" type="xml"> |
2937 | + <tree string="Local Withholding line " editable="bottom"> |
2938 | + <field name="name"/> |
2939 | + <field name="invoice_id" on_change="onchange_invoice_id(invoice_id)" domain="[('state', '=', 'open'), ('partner_id','=',parent.partner_id), ('ret_munici', '=', False)]"/> |
2940 | + <field name="wh_loc_rate"/> |
2941 | + <field name="amount"/> |
2942 | + <field name="move_id"/> |
2943 | + </tree> |
2944 | + </field> |
2945 | + </record> |
2946 | + |
2947 | + <record id="view_wh_muni_line_form" model="ir.ui.view"> |
2948 | + <field name="name">account.wh.munici.line.form</field> |
2949 | + <field name="model">account.wh.munici.line</field> |
2950 | + <field name="type">form</field> |
2951 | + <field name="arch" type="xml"> |
2952 | + <form string="Local Withholding line "> |
2953 | + <notebook> |
2954 | + <page string="Linea"> |
2955 | + <field name="invoice_id" on_change="onchange_invoice_id(invoice_id)" domain="[('state', '=', 'open'), ('partner_id','=',parent.partner_id), ('ret_munici', '=', False)]"/> |
2956 | + <field colspan="4" name="name" select="1"/> |
2957 | + <field name="wh_loc_rate"/> |
2958 | + <field name="amount"/> |
2959 | + <field name="move_id"/> |
2960 | + </page> |
2961 | + </notebook> |
2962 | + </form> |
2963 | + </field> |
2964 | + </record> |
2965 | + |
2966 | + |
2967 | + <!-- |
2968 | + ===================================================== |
2969 | + Local Withholding |
2970 | + ===================================================== |
2971 | + --> |
2972 | + |
2973 | + |
2974 | + <record id="view_wh_muni_filter" model="ir.ui.view"> |
2975 | + <field name="name">account.wh.munici.search</field> |
2976 | + <field name="model">account.wh.munici</field> |
2977 | + <field name="type">search</field> |
2978 | + <field name="arch" type="xml"> |
2979 | + <search string="Search Withholding Local"> |
2980 | + <group col="10" colspan="4"> |
2981 | + <filter name="draft" icon="terp-gtk-media-pause" string="Draft" domain="[('state','=','draft')]" help="Draft Withholding Local"/> |
2982 | + <filter name="confirmed" icon="terp-gtk-media-pause" string="Confirmed" domain="[('state','=','confirmed')]" help="Draft Withholding Local"/> |
2983 | + <filter name="done" icon="terp-check" string="Done" domain="[('state','=','done')]" help="Done Withholding Local"/> |
2984 | + <filter name="cancel" icon="terp-dialog-close" string="Cancel" domain="[('state','=','cancel')]" help="Cancel Withholding Local"/> |
2985 | + <separator orientation="vertical"/> |
2986 | + <field name="code"/> |
2987 | + <field name="number"/> |
2988 | + <field name="partner_id"/> |
2989 | + <field name="journal_id" widget="selection" string="Journal"/> |
2990 | + <field name="date_ret"/> |
2991 | + </group> |
2992 | + <newline/> |
2993 | + <group expand="1" string="Group By..."> |
2994 | + <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> |
2995 | + <separator orientation="vertical"/> |
2996 | + <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> |
2997 | + <separator orientation="vertical"/> |
2998 | + <filter string="Accounting Date of Withhold" icon="terp-go-month" domain="[]" context="{'group_by':'date_ret'}"/> |
2999 | + </group> |
3000 | + </search> |
3001 | + </field> |
3002 | + </record> |
3003 | + |
3004 | + |
3005 | + <record id="view_wh_muni_tree" model="ir.ui.view"> |
3006 | + <field name="name">account.wh.munici.tree</field> |
3007 | + <field name="model">account.wh.munici</field> |
3008 | + <field name="type">tree</field> |
3009 | + <field name="arch" type="xml"> |
3010 | + <tree colors="blue:state=='draft'" string="Local Withholding"> |
3011 | + <field name="name"/> |
3012 | + <field name="type"/> |
3013 | + <field name="code"/> |
3014 | + <field name="number"/> |
3015 | + <field name="partner_id"/> |
3016 | + <field name="date_ret"/> |
3017 | + <field name="currency_id"/> |
3018 | + <field name="period_id"/> |
3019 | + <field name="state"/> |
3020 | + <field name="amount"/> |
3021 | + |
3022 | + </tree> |
3023 | + </field> |
3024 | + </record> |
3025 | + |
3026 | + |
3027 | + <record id="view_wh_muni_form" model="ir.ui.view"> |
3028 | + <field name="name">account.wh.munici.form</field> |
3029 | + <field name="model">account.wh.munici</field> |
3030 | + <field name="type">form</field> |
3031 | + <field name="arch" type="xml"> |
3032 | + <form string="Local Withholding"> |
3033 | + <group colspan="4" col="6"> |
3034 | + <field name="journal_id" select="2" domain="[('type','=','mun_purchase')]"/> |
3035 | + <field name="type"/> |
3036 | + <field name="code"/> |
3037 | + <field name="partner_id" on_change="onchange_partner_id(type,partner_id)"/> |
3038 | + <field name="currency_id"/> |
3039 | + <field name="date_ret"/> |
3040 | + <field domain="[('type','<>','view'), ('company_id', '=', company_id)]" name="account_id"/> |
3041 | + <field name="name"/> |
3042 | + <field name="period_id"/> |
3043 | + <field name="number" attrs="{'readonly':[('type','=','in_invoice')],'required':[('type','in',['out_invoice','out_refund'])]}"/> |
3044 | + <field name="date" /> |
3045 | + <field name="amount" /> |
3046 | + </group> |
3047 | + <notebook colspan="4"> |
3048 | + <page string="Withholding"> |
3049 | + <field name="munici_line_ids" default_get="{'lines': munici_line_ids }" colspan="4" nolabel="1" height="275"/> |
3050 | + <group col="4" colspan="2"> |
3051 | + <field name="state"/> |
3052 | + <button name="action_confirm" string="Confirmed" states="draft" type="object" icon="gtk-open"/> |
3053 | + <button name="action_done" string="Done" states="confirmed" type="object" icon="gtk-go-forward"/> |
3054 | + </group> |
3055 | + </page> |
3056 | + <page string="Other Information"> |
3057 | + <field name="company_id"/> |
3058 | + </page> |
3059 | + </notebook> |
3060 | + </form> |
3061 | + </field> |
3062 | + </record> |
3063 | + |
3064 | + |
3065 | + <record model="ir.actions.act_window" id="action_account_wh_muni_customer"> |
3066 | + <field name="name">Local Withholding Customer</field> |
3067 | + <field name="res_model">account.wh.munici</field> |
3068 | + <field name="type">ir.actions.act_window</field> |
3069 | + <field name="view_type">form</field> |
3070 | + <field name="view_mode">tree,form</field> |
3071 | + <field name="domain">[('type','=','out_invoice')]</field> |
3072 | + <field name="context">{'type':'out_invoice'}</field> |
3073 | + <field name="search_view_id" ref="view_wh_muni_filter"/> |
3074 | + <field name="help">With Local Withholding Customer you can create and manage document withholding issued to your customers. OpenERP can also generate document withholding automatically from invoices. For retention must add the invoices, process them and then validate the document.</field> |
3075 | + </record> |
3076 | + <record model="ir.actions.act_window.view" id="act_wv_account_wh_muni_customer_tree"> |
3077 | + <field name="sequence" eval="10"/> |
3078 | + <field name="view_mode">tree</field> |
3079 | + <field name="view_id" ref="view_wh_muni_tree"/> |
3080 | + <field name="act_window_id" ref="action_account_wh_muni_customer"/> |
3081 | + </record> |
3082 | + <record model="ir.actions.act_window.view" id="act_wv_account_wh_muni_customer_form"> |
3083 | + <field name="sequence" eval="20"/> |
3084 | + <field name="view_mode">form</field> |
3085 | + <field name="view_id" ref="view_wh_muni_form"/> |
3086 | + <field name="act_window_id" ref="action_account_wh_muni_customer"/> |
3087 | + </record> |
3088 | + |
3089 | + <menuitem |
3090 | + id="menu_action_account_wh_muni_customer" |
3091 | + name="Local Withholding Customer" |
3092 | + parent="l10n_ve_withholding.menu_wh_customer" |
3093 | + action="action_account_wh_muni_customer"/> |
3094 | + |
3095 | + |
3096 | + |
3097 | + <record model="ir.actions.act_window" id="action_account_wh_muni_supplier"> |
3098 | + <field name="name">Local Withholding Supplier</field> |
3099 | + <field name="res_model">account.wh.munici</field> |
3100 | + <field name="type">ir.actions.act_window</field> |
3101 | + <field name="view_type">form</field> |
3102 | + <field name="view_mode">tree,form</field> |
3103 | + <field name="domain">[('type','=','in_invoice')]</field> |
3104 | + <field name="context">{'type':'in_invoice'}</field> |
3105 | + <field name="search_view_id" ref="view_wh_muni_filter"/> |
3106 | + <field name="help">With Local Withholding Supplier you can create and manage document withholding issued to your customers. OpenERP can also generate document withholding automatically from invoices. For retention must add the invoices, process them and then validate the document.</field> |
3107 | + </record> |
3108 | + <record model="ir.actions.act_window.view" id="act_wv_account_wh_muni_supplier_tree"> |
3109 | + <field name="sequence" eval="10"/> |
3110 | + <field name="view_mode">tree</field> |
3111 | + <field name="view_id" ref="view_wh_muni_tree"/> |
3112 | + <field name="act_window_id" ref="action_account_wh_muni_supplier"/> |
3113 | + </record> |
3114 | + <record model="ir.actions.act_window.view" id="act_wv_account_wh_muni_supplier_form"> |
3115 | + <field name="sequence" eval="20"/> |
3116 | + <field name="view_mode">form</field> |
3117 | + <field name="view_id" ref="view_wh_muni_form"/> |
3118 | + <field name="act_window_id" ref="action_account_wh_muni_supplier"/> |
3119 | + </record> |
3120 | + |
3121 | + <menuitem |
3122 | + id="menu_action_account_wh_muni_supplier" |
3123 | + name="Local Withholding Supplier" |
3124 | + parent="l10n_ve_withholding.menu_wh_suppiler" |
3125 | + action="action_account_wh_muni_supplier"/> |
3126 | + |
3127 | + </data> |
3128 | +</openerp> |
3129 | |
3130 | === added directory 'l10n_ve_withholding_muni/wizard' |
3131 | === added file 'l10n_ve_withholding_muni/wizard/__init__.py' |
3132 | --- l10n_ve_withholding_muni/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
3133 | +++ l10n_ve_withholding_muni/wizard/__init__.py 2011-09-22 17:22:23 +0000 |
3134 | @@ -0,0 +1,37 @@ |
3135 | +# -*- encoding: utf-8 -*- |
3136 | +############################################################################## |
3137 | +# |
3138 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
3139 | +# Javier Duran <javier.duran@netquatro.com> |
3140 | +# |
3141 | +# |
3142 | +# WARNING: This program as such is intended to be used by professional |
3143 | +# programmers who take the whole responsability of assessing all potential |
3144 | +# consequences resulting from its eventual inadequacies and bugs |
3145 | +# End users who are looking for a ready-to-use solution with commercial |
3146 | +# garantees and support are strongly adviced to contract a Free Software |
3147 | +# Service Company |
3148 | +# |
3149 | +# This program is Free Software; you can redistribute it and/or |
3150 | +# modify it under the terms of the GNU General Public License |
3151 | +# as published by the Free Software Foundation; either version 2 |
3152 | +# of the License, or (at your option) any later version. |
3153 | +# |
3154 | +# This program is distributed in the hope that it will be useful, |
3155 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3156 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3157 | +# GNU General Public License for more details. |
3158 | +# |
3159 | +# You should have received a copy of the GNU General Public License |
3160 | +# along with this program; if not, write to the Free Software |
3161 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3162 | +# |
3163 | +############################################################################## |
3164 | + |
3165 | +import wizard_ret_munici_xml |
3166 | + |
3167 | + |
3168 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3169 | + |
3170 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3171 | + |
3172 | |
3173 | === added file 'l10n_ve_withholding_muni/wizard/out.txt' |
3174 | --- l10n_ve_withholding_muni/wizard/out.txt 1970-01-01 00:00:00 +0000 |
3175 | +++ l10n_ve_withholding_muni/wizard/out.txt 2011-09-22 17:22:23 +0000 |
3176 | @@ -0,0 +1,1 @@ |
3177 | +False,2009/003,01245898,1,500.0,20.0 |
3178 | |
3179 | === added file 'l10n_ve_withholding_muni/wizard/prueba1.py' |
3180 | --- l10n_ve_withholding_muni/wizard/prueba1.py 1970-01-01 00:00:00 +0000 |
3181 | +++ l10n_ve_withholding_muni/wizard/prueba1.py 2011-09-22 17:22:23 +0000 |
3182 | @@ -0,0 +1,9 @@ |
3183 | +import sys |
3184 | + |
3185 | + |
3186 | + |
3187 | +print 'Nombre Archivo:',sys.argv[0] |
3188 | +print 'Periodo:',sys.argv[1] |
3189 | + |
3190 | + |
3191 | + |
3192 | |
3193 | === added file 'l10n_ve_withholding_muni/wizard/wizard_ret_munici_xml.py' |
3194 | --- l10n_ve_withholding_muni/wizard/wizard_ret_munici_xml.py 1970-01-01 00:00:00 +0000 |
3195 | +++ l10n_ve_withholding_muni/wizard/wizard_ret_munici_xml.py 2011-09-22 17:22:23 +0000 |
3196 | @@ -0,0 +1,132 @@ |
3197 | +# -*- encoding: utf-8 -*- |
3198 | +############################################################################## |
3199 | +# |
3200 | +# Copyright (c) 2009 Netquatro C.A. (http://openerp.netquatro.com/) All Rights Reserved. |
3201 | +# Javier Duran <javier.duran@netquatro.com> |
3202 | +# |
3203 | +# |
3204 | +# WARNING: This program as such is intended to be used by professional |
3205 | +# programmers who take the whole responsability of assessing all potential |
3206 | +# consequences resulting from its eventual inadequacies and bugs |
3207 | +# End users who are looking for a ready-to-use solution with commercial |
3208 | +# garantees and support are strongly adviced to contract a Free Software |
3209 | +# Service Company |
3210 | +# |
3211 | +# This program is Free Software; you can redistribute it and/or |
3212 | +# modify it under the terms of the GNU General Public License |
3213 | +# as published by the Free Software Foundation; either version 2 |
3214 | +# of the License, or (at your option) any later version. |
3215 | +# |
3216 | +# This program is distributed in the hope that it will be useful, |
3217 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3218 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3219 | +# GNU General Public License for more details. |
3220 | +# |
3221 | +# You should have received a copy of the GNU General Public License |
3222 | +# along with this program; if not, write to the Free Software |
3223 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3224 | +# |
3225 | +############################################################################## |
3226 | + |
3227 | +import wizard |
3228 | +import osv |
3229 | +import pooler |
3230 | +from tools.translate import _ |
3231 | +import os |
3232 | + |
3233 | +_transaction_form = '''<?xml version="1.0"?> |
3234 | +<form string=" Seleccione el periodo de declaracion"> |
3235 | + <field name="period_id"/> |
3236 | + |
3237 | +</form>''' |
3238 | + |
3239 | +_transaction_fields = { |
3240 | + 'period_id': { |
3241 | + 'string': 'Periodo', |
3242 | + 'type': 'many2one', |
3243 | + 'relation': 'account.period', |
3244 | + 'required': True |
3245 | + }, |
3246 | + |
3247 | +} |
3248 | + |
3249 | + |
3250 | + |
3251 | +def _data_save(self, cr, uid, data, context): |
3252 | + pool = pooler.get_pool(cr.dbname) |
3253 | + period_obj = pool.get('account.period') |
3254 | + comp_obj = pool.get('account.retencion.munici') |
3255 | + form = data['form'] |
3256 | + |
3257 | + res = {} |
3258 | + lst = [] |
3259 | + period = period_obj.browse(cr, uid, form['period_id']) |
3260 | + comp_ids = comp_obj.search(cr, uid, [('date_ret','>=',period.date_start),('date_ret','<=',period.date_stop)]) |
3261 | + print 'comprobantes: ',comp_ids |
3262 | + for comprobante in comp_obj.browse(cr, uid, comp_ids): |
3263 | + res['rif_r'] = comprobante.partner_id.vat |
3264 | + for line in comprobante.munici_line_ids: |
3265 | + res['nro'] = line.invoice_id.number |
3266 | + res['ctrl'] = line.invoice_id.nro_ctrl |
3267 | + res['conce'] = line.concepto_id |
3268 | + res['monto'] = line.amount |
3269 | + res['ptaje'] = line.retencion_munici |
3270 | + |
3271 | + lst.append(res) |
3272 | + |
3273 | + print 'resultadoxxx: ',res |
3274 | + |
3275 | + |
3276 | + |
3277 | + |
3278 | +# os.system("python /home/javier/openerp/stable/5.0/base/loc_ve_29122009/retencion_munici/wizard/prueba1.py "+period.name) |
3279 | + |
3280 | + |
3281 | + return self._csv_write(cr, uid, lst, context) |
3282 | + |
3283 | +class wiz_ret_munici_xml(wizard.interface): |
3284 | + |
3285 | + def _csv_write(self, cr, uid, data, context): |
3286 | + orden = [ |
3287 | + 'rif_r', |
3288 | + 'nro', |
3289 | + 'ctrl', |
3290 | + 'conce', |
3291 | + 'monto', |
3292 | + 'ptaje' |
3293 | + |
3294 | + ] |
3295 | + print 'data: ',data |
3296 | + lt = [] |
3297 | + arch = [] |
3298 | + for d in data: |
3299 | + print 'd: ',d |
3300 | + for col in orden: |
3301 | + print 'col: ',col |
3302 | + lt.append(d[col]) |
3303 | + |
3304 | + print 'lt: ',lt |
3305 | + arch.append(tuple(lt)) |
3306 | + print 'archxxx: ',arch |
3307 | + |
3308 | + import csv |
3309 | + cw = csv.writer(open("/home/javier/openerp/stable/5.0/base/loc_ve_29122009/retencion_munici/wizard/out.csv", "wb")) |
3310 | + cw.writerows(arch) |
3311 | + return {} |
3312 | + |
3313 | + |
3314 | + states = { |
3315 | + 'init': { |
3316 | + 'actions': [], |
3317 | + 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('change','Realizar')]} |
3318 | + }, |
3319 | + 'change': { |
3320 | + 'actions': [_data_save], |
3321 | + 'result': {'type': 'state', 'state':'end'} |
3322 | + } |
3323 | + } |
3324 | +wiz_ret_munici_xml('account.ret.munici.xml.seniat') |
3325 | + |
3326 | + |
3327 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3328 | + |
ya se realizó la mezcla