Merge lp:~vauxoo/addons-vauxoo/account_voucher_tax_dev_rodo into lp:addons-vauxoo

Proposed by Rodolfo Lopez
Status: Merged
Merged at revision: 338
Proposed branch: lp:~vauxoo/addons-vauxoo/account_voucher_tax_dev_rodo
Merge into: lp:addons-vauxoo
Diff against target: 473 lines (+428/-0)
8 files modified
account_voucher_tax/__init__.py (+2/-0)
account_voucher_tax/__openerp__.py (+47/-0)
account_voucher_tax/account_tax.py (+38/-0)
account_voucher_tax/account_tax_view.xml (+33/-0)
account_voucher_tax/account_voucher.py (+102/-0)
account_voucher_tax/patch/yaml_import.patch (+21/-0)
account_voucher_tax/test/account_voucher_taxes.yml (+85/-0)
account_voucher_tax/test/account_voucher_taxes_partial.yml (+100/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/account_voucher_tax_dev_rodo
Reviewer Review Type Date Requested Status
Vauxoo Pending
Review via email: mp+113816@code.launchpad.net

Description of the change

add module account_voucher_tax
genera poliza de impuesto efectivamente pagado/cobrado en el pago

To post a comment you must log in.
334. By Moisés López - http://www.vauxoo.com

[ADD] [product_custom_code] Add module for add product code of customer.

335. By Moisés López - http://www.vauxoo.com

[MERGE] Add product_customer_code

336. By Moisés López - http://www.vauxoo.com

[REF] [product_customer_code] Change company_id to required=False

337. By Moisés López - http://www.vauxoo.com

[MERGE] [account_invoice_tax] Add module account_invoice_tax

338. By Moisés López - http://www.vauxoo.com

[MERGE] [account_voucher_tax] Add module account_voucher_tax

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_voucher_tax'
2=== added file 'account_voucher_tax/__init__.py'
3--- account_voucher_tax/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_voucher_tax/__init__.py 2012-07-07 23:18:20 +0000
5@@ -0,0 +1,2 @@
6+import account_tax
7+import account_voucher
8\ No newline at end of file
9
10=== added file 'account_voucher_tax/__openerp__.py'
11--- account_voucher_tax/__openerp__.py 1970-01-01 00:00:00 +0000
12+++ account_voucher_tax/__openerp__.py 2012-07-07 23:18:20 +0000
13@@ -0,0 +1,47 @@
14+# -*- encoding: utf-8 -*-
15+###########################################################################
16+# Module Writen to OpenERP, Open Source Management Solution
17+#
18+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/
19+# All Rights Reserved.
20+# info Vauxoo (info@vauxoo.com)
21+############################################################################
22+# Coded by: el_rodo_1 (rodo@vauxoo.com)
23+############################################################################
24+#
25+# This program is free software: you can redistribute it and/or modify
26+# it under the terms of the GNU Affero General Public License as
27+# published by the Free Software Foundation, either version 3 of the
28+# License, or (at your option) any later version.
29+#
30+# This program is distributed in the hope that it will be useful,
31+# but WITHOUT ANY WARRANTY; without even the implied warranty of
32+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+# GNU Affero General Public License for more details.
34+#
35+# You should have received a copy of the GNU Affero General Public License
36+# along with this program. If not, see <http://www.gnu.org/licenses/>.
37+#
38+##############################################################################
39+
40+{
41+ "name" : "account_voucher_tax",
42+ "version" : "1.0",
43+ "author" : "Vauxoo",
44+ "category" : "Localization/Mexico",
45+ "description" : """This module shows the tax actually paid/cashed in the move of payment
46+ -You will nedd to aplly the patch patch/yaml_import.patch,
47+ that is located in this module ( use:patch -b file.py file.patch )""",
48+ "website" : "http://www.vauxoo.com/",
49+ "license" : "AGPL-3",
50+ "depends" : ["account","account_voucher","account_invoice_tax"],
51+ "init_xml" : [],
52+ "demo_xml" : [],
53+ "update_xml" : ["account_tax_view.xml"],
54+ "test": [
55+ 'test/account_voucher_taxes.yml',
56+ 'test/account_voucher_taxes_partial.yml',
57+ ],
58+ "installable" : True,
59+ "active" : False,
60+}
61
62=== added file 'account_voucher_tax/account_tax.py'
63--- account_voucher_tax/account_tax.py 1970-01-01 00:00:00 +0000
64+++ account_voucher_tax/account_tax.py 2012-07-07 23:18:20 +0000
65@@ -0,0 +1,38 @@
66+# -*- coding: utf-8 -*-
67+###########################################################################
68+# Module Writen to OpenERP, Open Source Management Solution
69+#
70+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
71+# All Rights Reserved.
72+# info@vauxoo.com
73+############################################################################
74+# Coded by: Rodo (rodo@vauxoo.com)
75+############################################################################
76+#
77+# This program is free software: you can redistribute it and/or modify
78+# it under the terms of the GNU Affero General Public License as
79+# published by the Free Software Foundation, either version 3 of the
80+# License, or (at your option) any later version.
81+#
82+# This program is distributed in the hope that it will be useful,
83+# but WITHOUT ANY WARRANTY; without even the implied warranty of
84+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85+# GNU Affero General Public License for more details.
86+#
87+# You should have received a copy of the GNU Affero General Public License
88+# along with this program. If not, see <http://www.gnu.org/licenses/>.
89+#
90+##############################################################################
91+from osv import osv, fields
92+
93+
94+class account_tax(osv.osv):
95+ _inherit = "account.tax"
96+
97+ _columns = {
98+ 'tax_voucher_ok': fields.boolean('Tax Vocuher Ok',help='help'),
99+ 'account_collected_voucher_id': fields.many2one('account.account','Account Collected Voucher'),
100+ 'account_paid_voucher_id': fields.many2one('account.account','Account Paid Voucher'),
101+ }
102+
103+account_tax()
104\ No newline at end of file
105
106=== added file 'account_voucher_tax/account_tax_view.xml'
107--- account_voucher_tax/account_tax_view.xml 1970-01-01 00:00:00 +0000
108+++ account_voucher_tax/account_tax_view.xml 2012-07-07 23:18:20 +0000
109@@ -0,0 +1,33 @@
110+<?xml version="1.0" encoding="utf-8"?>
111+<openerp>
112+ <data>
113+
114+ <record id="view_account_tax_voucher" model="ir.ui.view">
115+ <field name="name">view.account.tax.voucher</field>
116+ <field name="model">account.tax</field>
117+ <field name="type">form</field>
118+ <field name="inherit_id" ref="account.view_tax_form"/>
119+ <field name="arch" type="xml">
120+ <field name="active" position="after">
121+ <field name="tax_voucher_ok" />
122+ </field>
123+ </field>
124+ </record>
125+
126+
127+ <record id="view_account_tax_voucher_account" model="ir.ui.view">
128+ <field name="name">view.account.tax.voucher.account</field>
129+ <field name="model">account.tax</field>
130+ <field name="type">form</field>
131+ <field name="inherit_id" ref="account.view_tax_form"/>
132+ <field name="arch" type="xml">
133+ <separator string="Tax Declaration: Invoices" position="before">
134+ <field name="account_collected_voucher_id" attrs="{'required':[('tax_voucher_ok','=',True)]}"/>
135+ <newline/>
136+ <field name="account_paid_voucher_id" attrs="{'required':[('tax_voucher_ok','=',True)]}"/>
137+ </separator>
138+ </field>
139+ </record>
140+
141+ </data>
142+</openerp>
143
144=== added file 'account_voucher_tax/account_voucher.py'
145--- account_voucher_tax/account_voucher.py 1970-01-01 00:00:00 +0000
146+++ account_voucher_tax/account_voucher.py 2012-07-07 23:18:20 +0000
147@@ -0,0 +1,102 @@
148+# -*- coding: utf-8 -*-
149+###########################################################################
150+# Module Writen to OpenERP, Open Source Management Solution
151+#
152+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
153+# All Rights Reserved.
154+# info@vauxoo.com
155+############################################################################
156+# Coded by: Rodo (rodo@vauxoo.com)
157+############################################################################
158+#
159+# This program is free software: you can redistribute it and/or modify
160+# it under the terms of the GNU Affero General Public License as
161+# published by the Free Software Foundation, either version 3 of the
162+# License, or (at your option) any later version.
163+#
164+# This program is distributed in the hope that it will be useful,
165+# but WITHOUT ANY WARRANTY; without even the implied warranty of
166+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
167+# GNU Affero General Public License for more details.
168+#
169+# You should have received a copy of the GNU Affero General Public License
170+# along with this program. If not, see <http://www.gnu.org/licenses/>.
171+#
172+##############################################################################
173+
174+from osv import osv, fields
175+
176+class account_voucher(osv.osv):
177+ _inherit = 'account.voucher'
178+
179+ def voucher_move_line_create(self, cr, uid, voucher_id, line_total, move_id, company_currency, current_currency, context=None):
180+ move_obj = self.pool.get('account.move')
181+ move_line_obj = self.pool.get('account.move.line')
182+ invoice_obj = self.pool.get('account.invoice')
183+ currency_obj = self.pool.get('res.currency')
184+ res=super(account_voucher, self).voucher_move_line_create(cr, uid, voucher_id, line_total, move_id, company_currency, current_currency, context=None)
185+ for voucher in self.browse(cr,uid,[voucher_id],context=context):
186+ lines=[]
187+ for line in voucher.line_ids:
188+ if line.amount>0:
189+ invoice_ids=invoice_obj.search(cr,uid,[('move_id','=',line.move_line_id.move_id.id)],context=context)
190+ for invoice in invoice_obj.browse(cr,uid,invoice_ids,context=context):
191+ for tax in invoice.tax_line:
192+ if tax.tax_id.tax_voucher_ok:
193+ move_ids=[]
194+ account=tax.tax_id.account_collected_voucher_id.id
195+ credit_amount=currency_obj.compute(cr, uid, line.move_line_id.currency_id.id,company_currency, ((tax.tax_id.amount*tax.base)*(line.amount/line.amount_original)), context=context)
196+ debit_amount=0.0
197+ if tax.tax_id.amount<0:
198+ credit_amount=0.0
199+ debit_amount=(-1.0*currency_obj.compute(cr, uid, line.move_line_id.currency_id.id,company_currency, ((tax.tax_id.amount*tax.base)*(line.amount/line.amount_original)), context=context))
200+ if invoice.type=='out_invoice':## considerar que hacer con refund
201+ account=tax.tax_id.account_paid_voucher_id.id
202+ credit_amount, debit_amount=debit_amount, credit_amount
203+ move_line={
204+ 'journal_id': voucher.journal_id.id,
205+ 'period_id': voucher.period_id.id,
206+ 'name': tax.name or '/',
207+ 'account_id': tax.account_id.id,
208+ 'move_id': int(move_id),
209+ 'partner_id': voucher.partner_id.id,
210+ 'company_id':company_currency,
211+ 'currency_id': line.move_line_id and (company_currency <> current_currency and current_currency) or False,
212+ 'quantity': 1,
213+ 'credit': credit_amount,
214+ 'debit': debit_amount,
215+ 'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False,
216+ 'date': voucher.date,
217+
218+ }
219+ if company_currency!=current_currency:
220+ move_line['amount_currency']=currency_obj.compute(cr, uid, company_currency, current_currency,credit_amount, context=context)
221+ move_ids.append(move_line_obj.create(cr,uid,move_line,context=context))
222+ move_line={
223+ 'journal_id': voucher.journal_id.id,
224+ 'period_id': voucher.period_id.id,
225+ 'name': tax.name or '/',
226+ 'account_id': account,
227+ 'move_id': int(move_id),
228+ 'partner_id': voucher.partner_id.id,
229+ 'company_id':company_currency,
230+ #'currency_id': line.move_line_id and (company_currency <> line.move_line_id.currency_id.id and line.move_line_id.currency_id.id) or False,
231+ 'currency_id': line.move_line_id and (company_currency <> current_currency and current_currency) or False,
232+ 'quantity': 1,
233+ 'credit': debit_amount,
234+ 'debit': credit_amount,
235+ 'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False,
236+ 'date': voucher.date,
237+ }
238+ if company_currency!=current_currency:
239+ move_line['amount_currency']=currency_obj.compute(cr, uid, company_currency, current_currency,credit_amount, context=context)
240+ move_line_obj.create(cr,uid,move_line,context=context)
241+ for mov_line in invoice.move_id.line_id:
242+ if mov_line.account_id.id==tax.account_id.id:
243+ move_ids.append(mov_line.id)
244+ if line.amount==line.amount_original:
245+ self.pool.get('account.move.line').reconcile(cr, uid, move_ids, 'manual', writeoff_acc_id=tax.account_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id)
246+ else:
247+ self.pool.get('account.move.line').reconcile_partial(cr, uid, move_ids, 'manual', context)
248+ return res
249+account_voucher()
250\ No newline at end of file
251
252=== added directory 'account_voucher_tax/patch'
253=== added file 'account_voucher_tax/patch/yaml_import.patch'
254--- account_voucher_tax/patch/yaml_import.patch 1970-01-01 00:00:00 +0000
255+++ account_voucher_tax/patch/yaml_import.patch 2012-07-07 23:18:20 +0000
256@@ -0,0 +1,21 @@
257+=== modified file 'openerp/tools/yaml_import.py'
258+--- openerp/tools/yaml_import.py 2012-06-25 14:40:13 +0000
259++++ openerp/tools/yaml_import.py 2012-07-05 22:36:58 +0000
260+@@ -310,12 +310,13 @@
261+ def process_record(self, node):
262+ import openerp.osv as osv
263+ record, fields = node.items()[0]
264++ module_str = self.module
265+ model = self.get_model(record.model)
266+-
267+ view_id = record.view
268+ if view_id and (view_id is not True):
269+- view_id = self.pool.get('ir.model.data').get_object_reference(self.cr, 1, self.module, record.view)[1]
270+-
271++ if '.' in view_id:
272++ module_str,view_id = view_id.split('.')
273++ view_id = self.pool.get('ir.model.data').get_object_reference(self.cr, 1, module_str, view_id)[1]
274+ if model.is_transient():
275+ record_dict=self.create_osv_memory_record(record, fields)
276+ else:
277+
278
279=== added directory 'account_voucher_tax/test'
280=== added file 'account_voucher_tax/test/account_voucher_taxes.yml'
281--- account_voucher_tax/test/account_voucher_taxes.yml 1970-01-01 00:00:00 +0000
282+++ account_voucher_tax/test/account_voucher_taxes.yml 2012-07-07 23:18:20 +0000
283@@ -0,0 +1,85 @@
284+-
285+ In order to check account voucher tax module in OpenERP I create a tax
286+-
287+ !record {model: account.tax, id: account_tax_iva}:
288+ description: iva 16
289+ type_tax_use: purchase
290+ tax_voucher_ok: True
291+ name: Iva 16%
292+ type: percent
293+ amount: 0.1600
294+ account_collected_id: account.iva
295+ account_paid_id: account.iva
296+ account_collected_voucher_id: account.ova
297+ account_paid_voucher_id: account.ova
298+
299+-
300+ I create a supplier invoice
301+-
302+ !record {model: account.invoice, id: account_invoice_supplier_tax0}:
303+ account_id: account.a_pay
304+ address_contact_id: base.res_partner_address_3000
305+ address_invoice_id: base.res_partner_address_3000
306+ check_total: 6182.80
307+ company_id: base.main_company
308+ currency_id: base.EUR
309+ invoice_line:
310+ - account_id: account.a_expense
311+ name: '[PC1] Basic PC'
312+ price_unit: 5330.0
313+ product_id: product.product_product_pc1
314+ quantity: 1.0
315+ uos_id: product.product_uom_unit
316+ invoice_line_tax_id:
317+ - account_tax_iva
318+ journal_id: account.expenses_journal
319+ partner_id: base.res_partner_c2c
320+ reference_type: none
321+ type: in_invoice
322+
323+-
324+ I change the state of invoice to open by clicking Validate button
325+-
326+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier_tax0}
327+-
328+ I check that the invoice state is now "Open"
329+-
330+ !assert {model: account.invoice, id: account_invoice_supplier_tax0}:
331+ - state == 'open'
332+
333+-
334+ I create the first voucher of payment with values 6182.80
335+-
336+ !record {model: account.voucher, id: account_voucher_tax1, view: False}:
337+ account_id: account.cash
338+ company_id: base.main_company
339+ amount: 6182.80
340+ journal_id: account.bank_journal
341+ name: 'First payment: with tax'
342+ partner_id: base.res_partner_c2c
343+ period_id: account.period_7
344+ date: !eval time.strftime("%Y-%m-%d")
345+ type: 'payment'
346+
347+-
348+ Line of voucher
349+-
350+ !python {model: account.voucher}: |
351+ voucher_id = self.search(cr, uid, [('id', '=', ref('account_voucher_tax1'))])
352+ voucher = self.browse(cr, uid, voucher_id[0])
353+ res=self.onchange_journal(cr, uid, [voucher.id], journal_id=ref('account.bank_journal'), line_ids=[], tax_id=False, partner_id=voucher.partner_id.id, date=voucher.date, amount=6182.80, ttype='payment', company_id=voucher.company_id.id, context=None)
354+ onchange_journal_value=res.get('value', {}) or {}
355+ lines=onchange_journal_value.pop('line_dr_ids')[0]
356+ lines_format=[0,0]
357+ lines_format.append(lines)
358+ onchange_journal_value['line_dr_ids']=[tuple(lines_format)]
359+ self.write(cr,uid, [voucher.id], onchange_journal_value)
360+ assert (voucher.amount==6182.80) , "check amount"
361+-
362+ !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_tax1}
363+-
364+
365+
366+
367+
368+
369
370=== added file 'account_voucher_tax/test/account_voucher_taxes_partial.yml'
371--- account_voucher_tax/test/account_voucher_taxes_partial.yml 1970-01-01 00:00:00 +0000
372+++ account_voucher_tax/test/account_voucher_taxes_partial.yml 2012-07-07 23:18:20 +0000
373@@ -0,0 +1,100 @@
374+
375+-
376+ I create a supplier invoice
377+-
378+ !record {model: account.invoice, id: account_invoice_supplier_tax1}:
379+ account_id: account.a_pay
380+ address_contact_id: base.res_partner_address_3000
381+ address_invoice_id: base.res_partner_address_3000
382+ check_total: 6182.80
383+ company_id: base.main_company
384+ currency_id: base.EUR
385+ invoice_line:
386+ - account_id: account.a_expense
387+ name: '[PC1] Basic PC'
388+ price_unit: 5330.0
389+ product_id: product.product_product_pc1
390+ quantity: 1.0
391+ uos_id: product.product_uom_unit
392+ invoice_line_tax_id:
393+ - account_tax_iva
394+ journal_id: account.expenses_journal
395+ partner_id: base.res_partner_c2c
396+ reference_type: none
397+ type: in_invoice
398+
399+-
400+ I change the state of invoice to open by clicking Validate button
401+-
402+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier_tax1}
403+-
404+ I check that the invoice state is now "Open"
405+-
406+ !assert {model: account.invoice, id: account_invoice_supplier_tax1}:
407+ - state == 'open'
408+
409+-
410+ I create the first voucher of payment with values 3091.4
411+-
412+ !record {model: account.voucher, id: account_voucher_tax2, view: False}:
413+ company_id: base.main_company
414+ account_id: account.cash
415+ amount: 3091.4
416+ currency_id: base.EUR
417+ journal_id: account.bank_journal
418+ name: 'First Partial payment: with tax'
419+ partner_id: base.res_partner_c2c
420+ period_id: account.period_7
421+ date: !eval time.strftime("%Y-%m-%d")
422+ type: 'payment'
423+
424+-
425+ Line of voucher
426+-
427+ !python {model: account.voucher}: |
428+ voucher_id = self.search(cr, uid, [('id', '=', ref('account_voucher_tax2'))])
429+ voucher = self.browse(cr, uid, voucher_id[0])
430+ res=self.onchange_journal(cr, uid, [voucher.id], journal_id=ref('account.bank_journal'), line_ids=[], tax_id=False, partner_id=voucher.partner_id.id, date=voucher.date, amount=3091.4, ttype='payment', company_id=voucher.company_id.id, context=None)
431+ onchange_journal_value=res.get('value', {}) or {}
432+ lines=onchange_journal_value.pop('line_dr_ids')[0]
433+ lines_format=[0,0]
434+ lines_format.append(lines)
435+ onchange_journal_value['line_dr_ids']=[tuple(lines_format)]
436+ self.write(cr,uid, [voucher.id], onchange_journal_value)
437+ assert (voucher.amount==3091.4) , "check amount"
438+-
439+ !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_tax2}
440+-
441+
442+-
443+ I create the second voucher of payment with values 3091.4
444+-
445+ !record {model: account.voucher, id: account_voucher_tax3, view: False}:
446+ company_id: base.main_company
447+ account_id: account.cash
448+ currency_id: base.EUR
449+ amount: 3091.4
450+ journal_id: account.bank_journal
451+ name: 'Second Partial payment: with tax'
452+ partner_id: base.res_partner_c2c
453+ period_id: account.period_7
454+ date: !eval time.strftime("%Y-%m-%d")
455+ type: 'payment'
456+
457+-
458+ Line of voucher
459+-
460+ !python {model: account.voucher}: |
461+ voucher_id = self.search(cr, uid, [('id', '=', ref('account_voucher_tax3'))])
462+ voucher = self.browse(cr, uid, voucher_id[0])
463+ res=self.onchange_journal(cr, uid, [voucher.id], journal_id=ref('account.bank_journal'), line_ids=[], tax_id=False, partner_id=voucher.partner_id.id, date=voucher.date, amount=3091.4, ttype='payment', company_id=voucher.company_id.id, context=None)
464+ onchange_journal_value=res.get('value', {}) or {}
465+ lines=onchange_journal_value.pop('line_dr_ids')[0]
466+ lines_format=[0,0]
467+ lines_format.append(lines)
468+ onchange_journal_value['line_dr_ids']=[tuple(lines_format)]
469+ self.write(cr,uid, [voucher.id], onchange_journal_value)
470+ assert (voucher.amount==3091.4) , "check amount"
471+-
472+ !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_tax3}
473+-