Merge lp:~vauxoo/openerp-venezuela-localization/hbto_wh_base into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Merged
Approved by: hbto [Vauxoo] http://www.vauxoo.com
Approved revision: 491
Merged at revision: 504
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/hbto_wh_base
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Diff against target: 58 lines (+22/-17)
1 file modified
l10n_ve_withholding/invoice.py (+22/-17)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/hbto_wh_base
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Approve
Review via email: mp+86636@code.launchpad.net

Description of the change

[IMP] Improved socket method for creating moves in invoice
so that other modules could use it in a easier way.

To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_withholding/invoice.py'
2--- l10n_ve_withholding/invoice.py 2011-10-30 22:07:10 +0000
3+++ l10n_ve_withholding/invoice.py 2011-12-21 23:50:28 +0000
4@@ -31,11 +31,19 @@
5
6 class account_invoice(osv.osv):
7 _inherit = 'account.invoice'
8-
9+
10+
11+ def _get_move_lines(self, cr, uid, ids, to_wh, period_id,
12+ pay_journal_id, writeoff_acc_id,
13+ writeoff_period_id, writeoff_journal_id, date,
14+ name, context=None):
15+ if context is None: context = {}
16+ return []
17+
18 def ret_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id,
19 period_id, pay_journal_id, writeoff_acc_id,
20 writeoff_period_id, writeoff_journal_id, date,
21- name, context=None):
22+ name, to_wh, context=None):
23 if context is None:
24 context = {}
25 #TODO check if we can use different period for payment and the writeoff line
26@@ -53,21 +61,18 @@
27 'ref':invoice.number,
28 'date': date,
29 'currency_id': False,
30- }
31- l2 = {
32- 'debit': direction * pay_amount<0 and - direction * pay_amount,
33- 'credit': direction * pay_amount>0 and direction * pay_amount,
34- 'account_id': pay_account_id,
35- 'partner_id': invoice.partner_id.id,
36- 'ref':invoice.number,
37- 'date': date,
38- 'currency_id': False,
39- }
40-
41- l1['name'] = name
42- l2['name'] = name
43-
44- lines = [(0, 0, l1), (0, 0, l2)]
45+ 'name':name
46+ }
47+ lines = [(0, 0, l1)]
48+
49+ l2 = self._get_move_lines(cr, uid, ids, to_wh, period_id,
50+ pay_journal_id, writeoff_acc_id,
51+ writeoff_period_id, writeoff_journal_id, date,
52+ name, context=context)
53+ if not l2:
54+ raise osv.except_osv(_('Warning !'), _('No accounting moves were created.\n Please, Check if there are Taxes/Concepts to withhold in the Invoices!'))
55+ lines += l2
56+
57 move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
58 move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
59