Merge lp:~domsense/account-payment/adding_account_vat_on_payment_7 into lp:~account-payment-team/account-payment/7.0

Proposed by Lorenzo Battistini
Status: Needs review
Proposed branch: lp:~domsense/account-payment/adding_account_vat_on_payment_7
Merge into: lp:~account-payment-team/account-payment/7.0
Diff against target: 816 lines (+770/-0)
9 files modified
account_vat_on_payment/AUTHORS.txt (+1/-0)
account_vat_on_payment/__init__.py (+25/-0)
account_vat_on_payment/__openerp__.py (+60/-0)
account_vat_on_payment/account.py (+433/-0)
account_vat_on_payment/account_view.xml (+104/-0)
account_vat_on_payment/company.py (+42/-0)
account_vat_on_payment/company_view.xml (+21/-0)
account_vat_on_payment/partner.py (+36/-0)
account_vat_on_payment/partner_view.xml (+48/-0)
To merge this branch: bzr merge lp:~domsense/account-payment/adding_account_vat_on_payment_7
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Disapprove
Omar (Pexego) code review, no test Approve
Review via email: mp+196914@code.launchpad.net

Description of the change

See 'account_voucher_cash_basis' description.

To activate the VAT on payment behaviour, this module adds a checkbox on
invoice form: 'Vat on payment'

Moreover, three things have to be configured:
 - On account object, Related account used for real registrations on a VAT on
    payment basis
 - On journal object, Related journal used for shadow registrations on a VAT on
    payment basis
 - On tax code object, Related tax code used for real registrations on a VAT on
    payment basis

Requirements:
https://docs.google.com/spreadsheet/ccc?key=0Aodwq17jxF4edDJaZ2dOQkVEN0hodEtfRmpVdlg2Vnc#gid=0
Howto:
http://planet.agilebg.com/en/2012/10/vat-on-payment-treatment-with-openerp/

I propose this now so we can discuss about the usefulness of this module.

I set it 'work in progress' also because YAML tests are missing.

To post a comment you must log in.
Revision history for this message
Davide Corio (enlightx-deactivatedaccount) wrote :
Revision history for this message
Lorenzo Battistini (elbati) wrote :

2013/11/27 Davide Corio <email address hidden>

> there's a blocking typo here:
>
>
> http://bazaar.launchpad.net/~domsense/account-payment/adding_account_vat_on_payment_7/view/head:/account_vat_on_payment/account.py#L45
>
> s/vat_on_paymen/vat_on_payment
>
>
Oops.
Fixed.
Thanks!

Revision history for this message
Omar (Pexego) (omar7r) wrote :

Could you take the time to bring this to the 7.0 community addons coding conventions. This includes:

* not using the shortcut imports (things in the openerp namespace need to be imported from openerp)
* using the from . import xxx for relative imports (typically in __init__.py files)
* using orm.Model and orm.TransientModel as base class rather than osv.osv and osv.osv_memory
* etc.

Thanks

review: Needs Fixing (code review)
Revision history for this message
Nicola Malcontenti - Agile BG (hurrin1c0) wrote :

Hi Omar,
Thanks for the segnalation,
we have done all the modify requested.

Greetings.
-N.

Revision history for this message
Lorenzo Battistini (elbati) wrote :
Revision history for this message
Omar (Pexego) (omar7r) wrote :

Thanks, LGTM

review: Approve (code review, no test)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/account-payment. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Revision history for this message
Lorenzo Battistini (elbati) wrote :
review: Disapprove

Unmerged revisions

115. By Lorenzo Battistini

[FIX] when selecting partner without fiscal position, do not overwrite invoice field

114. By Lorenzo Battistini

[FIX] [7.0] account_vat_on_payment - impossible to compute VAT based on invoice total in case of write-off

113. By Lorenzo Battistini

[FIX] missing fields

112. By Hurrinico

[FIX] PEP8 fixing

111. By Lorenzo Battistini

[IMP] handling fiscal positions

110. By Lorenzo Battistini

[FIX] typo

109. By Lorenzo Battistini

[fix] URL

108. By Lorenzo Battistini

[imp] other PEP8

107. By Lorenzo Battistini

[imp] other PEP8

106. By Lorenzo Battistini

[IMP] some PEP8

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_vat_on_payment'
2=== added file 'account_vat_on_payment/AUTHORS.txt'
3--- account_vat_on_payment/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ account_vat_on_payment/AUTHORS.txt 2014-06-03 16:12:49 +0000
5@@ -0,0 +1,1 @@
6+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
7
8=== added file 'account_vat_on_payment/__init__.py'
9--- account_vat_on_payment/__init__.py 1970-01-01 00:00:00 +0000
10+++ account_vat_on_payment/__init__.py 2014-06-03 16:12:49 +0000
11@@ -0,0 +1,25 @@
12+# -*- coding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
17+# Copyright (C) 2012-2013 Agile Business Group sagl
18+# (<http://www.agilebg.com>)
19+#
20+# This program is free software: you can redistribute it and/or modify
21+# it under the terms of the GNU Affero General Public License as
22+# published by the Free Software Foundation, either version 3 of the
23+# License, or (at your option) any later version.
24+#
25+# This program is distributed in the hope that it will be useful,
26+# but WITHOUT ANY WARRANTY; without even the implied warranty of
27+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+# GNU Affero General Public License for more details.
29+#
30+# You should have received a copy of the GNU Affero General Public License
31+# along with this program. If not, see <http://www.gnu.org/licenses/>.
32+#
33+##############################################################################E
34+from . import account
35+from . import company
36+from . import partner
37
38=== added file 'account_vat_on_payment/__openerp__.py'
39--- account_vat_on_payment/__openerp__.py 1970-01-01 00:00:00 +0000
40+++ account_vat_on_payment/__openerp__.py 2014-06-03 16:12:49 +0000
41@@ -0,0 +1,60 @@
42+# -*- coding: utf-8 -*-
43+##############################################################################
44+#
45+# OpenERP, Open Source Management Solution
46+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
47+# Copyright (C) 2012-2013 Agile Business Group sagl
48+# (<http://www.agilebg.com>)
49+#
50+# This program is free software: you can redistribute it and/or modify
51+# it under the terms of the GNU Affero General Public License as
52+# published by the Free Software Foundation, either version 3 of the
53+# License, or (at your option) any later version.
54+#
55+# This program is distributed in the hope that it will be useful,
56+# but WITHOUT ANY WARRANTY; without even the implied warranty of
57+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58+# GNU Affero General Public License for more details.
59+#
60+# You should have received a copy of the GNU Affero General Public License
61+# along with this program. If not, see <http://www.gnu.org/licenses/>.
62+#
63+##############################################################################
64+
65+
66+{
67+ "name": "VAT on payment",
68+ "version": "2.0",
69+ 'category': 'Generic Modules/Accounting',
70+ "depends": ["account_voucher_cash_basis"],
71+ "author": "Agile Business Group",
72+ "description": """
73+See 'account_voucher_cash_basis' description.
74+
75+To activate the VAT on payment behaviour, this module adds a checkbox on
76+invoice form: 'Vat on payment'
77+
78+Moreover, three things have to be configured:
79+ - On account object, Related account used for real registrations on a VAT on
80+ payment basis
81+ - On journal object, Related journal used for shadow registrations on a VAT on
82+ payment basis
83+ - On tax code object, Related tax code used for real registrations on a VAT on
84+ payment basis
85+
86+Requirements:
87+https://docs.google.com/spreadsheet/ccc?key=0Aodwq17jxF4edDJaZ2dOQkVEN0hodEtfRmpVdlg2Vnc#gid=0
88+Howto:
89+http://planet.agilebg.com/en/2012/10/vat-on-payment-treatment-with-openerp/
90+ """,
91+ 'website': 'http://www.agilebg.com',
92+ 'init_xml': [],
93+ 'update_xml': [
94+ 'account_view.xml',
95+ 'company_view.xml',
96+ 'partner_view.xml',
97+ ],
98+ 'demo_xml': [], # TODO YAML tests
99+ 'installable': True,
100+ 'active': False,
101+}
102
103=== added file 'account_vat_on_payment/account.py'
104--- account_vat_on_payment/account.py 1970-01-01 00:00:00 +0000
105+++ account_vat_on_payment/account.py 2014-06-03 16:12:49 +0000
106@@ -0,0 +1,433 @@
107+# -*- coding: utf-8 -*-
108+##############################################################################
109+#
110+# OpenERP, Open Source Management Solution
111+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
112+# Copyright (C) 2012-2013 Agile Business Group sagl
113+# (<http://www.agilebg.com>)
114+#
115+# This program is free software: you can redistribute it and/or modify
116+# it under the terms of the GNU Affero General Public License as
117+# published by the Free Software Foundation, either version 3 of the
118+# License, or (at your option) any later version.
119+#
120+# This program is distributed in the hope that it will be useful,
121+# but WITHOUT ANY WARRANTY; without even the implied warranty of
122+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
123+# GNU Affero General Public License for more details.
124+#
125+# You should have received a copy of the GNU Affero General Public License
126+# along with this program. If not, see <http://www.gnu.org/licenses/>.
127+#
128+##############################################################################
129+
130+from openerp.osv import orm, fields
131+from tools.translate import _
132+
133+
134+class account_voucher(orm.Model):
135+ _inherit = "account.voucher"
136+
137+ _columns = {
138+ 'shadow_move_id': fields.many2one(
139+ 'account.move', 'Shadow Entry', readonly=True),
140+ }
141+
142+ def is_vat_on_payment(self, voucher):
143+ vat_on_p = 0
144+ valid_lines = 0
145+ if voucher.type in ('payment', 'receipt'):
146+ for line in voucher.line_ids:
147+ if line.amount:
148+ valid_lines += 1
149+ if (
150+ line.move_line_id and line.move_line_id.invoice
151+ and line.move_line_id.invoice.vat_on_payment
152+ ):
153+ vat_on_p += 1
154+ if vat_on_p and vat_on_p != valid_lines:
155+ raise osv.except_osv(
156+ _('Error'),
157+ _("""Can't handle VAT on payment if not every invoice
158+ is on a VAT on payment treatment"""))
159+ return vat_on_p
160+
161+ def action_move_line_create(self, cr, uid, ids, context=None):
162+ if context is None:
163+ context = {}
164+ inv_pool = self.pool.get('account.invoice')
165+ journal_pool = self.pool.get('account.journal')
166+ move_line_pool = self.pool.get('account.move.line')
167+ move_pool = self.pool.get('account.move')
168+ currency_obj = self.pool.get('res.currency')
169+ res = False
170+ for voucher in self.browse(cr, uid, ids, context):
171+ entry_posted = voucher.journal_id.entry_posted
172+ # disable the 'skip draft state' option because "mixed" entry
173+ # (shadow + real) won't pass validation. Anyway every entry will be
174+ # posted later (if 'entry_posted' is enabled)
175+ if entry_posted:
176+ journal_pool.write(
177+ cr, uid, voucher.journal_id.id, {'entry_posted': False})
178+ res = super(account_voucher, self).action_move_line_create(
179+ cr, uid, [voucher.id], context)
180+ # because 'move_id' has been updated by 'action_move_line_create'
181+ voucher.refresh()
182+ if entry_posted:
183+ journal_pool.write(
184+ cr, uid, voucher.journal_id.id, {'entry_posted': True})
185+ if self.is_vat_on_payment(voucher):
186+ if not voucher.journal_id.vat_on_payment_related_journal_id:
187+ raise osv.except_osv(
188+ _('Error'),
189+ _("""We are on a VAT on payment treatment
190+ but journal %s does not have a related shadow
191+ journal""")
192+ % voucher.journal_id.name)
193+ lines_to_create = []
194+ amounts_by_invoice = super(
195+ account_voucher, self
196+ ).allocated_amounts_grouped_by_invoice(
197+ cr, uid, voucher, context)
198+ for inv_id in amounts_by_invoice:
199+ invoice = inv_pool.browse(cr, uid, inv_id, context)
200+ for inv_move_line in invoice.move_id.line_id:
201+ if (
202+ inv_move_line.account_id.type != 'receivable'
203+ and inv_move_line.account_id.type != 'payable'
204+ ):
205+ # compute the VAT or base line proportionally to
206+ # the paid amount
207+ if (
208+ voucher.exclude_write_off
209+ and voucher.payment_option == 'with_writeoff'
210+ ):
211+ # avoid including write-off if set in voucher.
212+ # That means: use the invoice's total
213+ # (as we are in 'full reconcile' case)
214+ allocated_amount = amounts_by_invoice[
215+ invoice.id
216+ ]['allocated']
217+ else:
218+ allocated_amount = (
219+ amounts_by_invoice[invoice.id]['allocated']
220+ +
221+ amounts_by_invoice[invoice.id]['write-off']
222+ )
223+ new_line_amount = currency_obj.round(
224+ cr, uid, voucher.company_id.currency_id,
225+ (
226+ allocated_amount
227+ /
228+ amounts_by_invoice[invoice.id]['total']
229+ )
230+ *
231+ (inv_move_line.credit or inv_move_line.debit)
232+ )
233+ new_line_amount_curr = False
234+ if (
235+ amounts_by_invoice[invoice.id].get(
236+ 'allocated_currency')
237+ and amounts_by_invoice[invoice.id].get(
238+ 'foreign_currency_id')
239+ ):
240+ for_curr = currency_obj.browse(
241+ cr, uid,
242+ amounts_by_invoice[invoice.id][
243+ 'foreign_currency_id'],
244+ context=context)
245+ if (
246+ voucher.exclude_write_off
247+ and
248+ voucher.payment_option == 'with_writeoff'
249+ ):
250+ # again
251+ # avoid including write-off if set in
252+ # voucher.
253+ allocated_amount = amounts_by_invoice[
254+ invoice.id]['allocated_currency']
255+ else:
256+ allocated_amount = (
257+ amounts_by_invoice[invoice.id][
258+ 'allocated_currency']
259+ +
260+ amounts_by_invoice[invoice.id][
261+ 'currency-write-off']
262+ )
263+ new_line_amount_curr = currency_obj.round(
264+ cr, uid, for_curr,
265+ (
266+ allocated_amount
267+ /
268+ amounts_by_invoice[
269+ invoice.id
270+ ]['total_currency']
271+ )
272+ *
273+ (inv_move_line.amount_currency)
274+ )
275+
276+ if not inv_move_line.real_account_id:
277+ raise osv.except_osv(
278+ _('Error'),
279+ _("""We are on a VAT on payment treatment
280+ but move line %s does not have a related
281+ real account""")
282+ % inv_move_line.name)
283+
284+ # prepare the real move line
285+ vals = {
286+ 'name': inv_move_line.name,
287+ 'account_id': inv_move_line.real_account_id.id,
288+ 'credit': (
289+ inv_move_line.credit
290+ and new_line_amount or 0.0),
291+ 'debit': (
292+ inv_move_line.debit
293+ and new_line_amount or 0.0),
294+ 'type': 'real',
295+ 'partner_id': (
296+ inv_move_line.partner_id
297+ and inv_move_line.partner_id.id or False)
298+ }
299+ if new_line_amount_curr:
300+ vals['amount_currency'] = new_line_amount_curr
301+ vals['currency_id'] = for_curr.id
302+ if inv_move_line.tax_code_id:
303+ if not inv_move_line.real_tax_code_id:
304+ raise osv.except_osv(
305+ _('Error'),
306+ _("""We are on a VAT on payment
307+ treatment but move line %s does not
308+ have a related real tax code""")
309+ % inv_move_line.name
310+ )
311+ vals[
312+ 'tax_code_id'
313+ ] = inv_move_line.real_tax_code_id.id
314+ if inv_move_line.tax_amount < 0:
315+ vals['tax_amount'] = -new_line_amount
316+ else:
317+ vals['tax_amount'] = new_line_amount
318+ lines_to_create.append(vals)
319+
320+ # prepare the shadow move line
321+ vals = {
322+ 'name': inv_move_line.name,
323+ 'account_id': inv_move_line.account_id.id,
324+ 'credit': (
325+ inv_move_line.debit
326+ and new_line_amount or 0.0),
327+ 'debit': (
328+ inv_move_line.credit
329+ and new_line_amount or 0.0),
330+ 'type': 'shadow',
331+ 'partner_id': (
332+ inv_move_line.partner_id
333+ and inv_move_line.partner_id.id or False)
334+ }
335+ if inv_move_line.tax_code_id:
336+ vals[
337+ 'tax_code_id'
338+ ] = inv_move_line.tax_code_id.id
339+ if inv_move_line.tax_amount < 0:
340+ vals['tax_amount'] = new_line_amount
341+ else:
342+ vals['tax_amount'] = -new_line_amount
343+ lines_to_create.append(vals)
344+
345+ context['journal_id'] = (
346+ voucher.journal_id.vat_on_payment_related_journal_id.id)
347+ context['period_id'] = voucher.move_id.period_id.id
348+ shadow_move_id = move_pool.create(cr, uid, {
349+ 'journal_id': (
350+ voucher.journal_id.vat_on_payment_related_journal_id.id
351+ ),
352+ 'period_id': voucher.move_id.period_id.id,
353+ 'date': voucher.move_id.date,
354+ }, context)
355+
356+ # move the payment move lines to shadow entry
357+ for line in voucher.move_ids:
358+ if line.account_id.type != 'liquidity':
359+ # If the line is related to write-off and user doesn't
360+ # want to compute the tax including write-off,
361+ # write-off move line must stay on the real move
362+ if not (
363+ voucher.exclude_write_off
364+ and voucher.payment_option == 'with_writeoff'
365+ and line.account_id.id
366+ == voucher.writeoff_acc_id.id
367+ ):
368+ line.write({
369+ 'move_id': shadow_move_id,
370+ }, update_check=False)
371+ # this will allow user to see the real entry from
372+ # invoice payment tab
373+ if (
374+ line.account_id.type == 'receivable'
375+ or line.account_id.type == 'payable'
376+ ):
377+ line.write({
378+ 'real_payment_move_id': voucher.move_id.id,
379+ })
380+
381+ for line_to_create in lines_to_create:
382+ if line_to_create['type'] == 'real':
383+ line_to_create['move_id'] = voucher.move_id.id
384+ elif line_to_create['type'] == 'shadow':
385+ line_to_create['move_id'] = shadow_move_id
386+ del line_to_create['type']
387+
388+ move_line_pool.create(cr, uid, line_to_create, context)
389+
390+ voucher.write({'shadow_move_id': shadow_move_id})
391+
392+ super(account_voucher, self).balance_move(
393+ cr, uid, shadow_move_id, context)
394+ super(account_voucher, self).balance_move(
395+ cr, uid, voucher.move_id.id, context)
396+
397+ return res
398+
399+ def cancel_voucher(self, cr, uid, ids, context=None):
400+ res = super(account_voucher, self).cancel_voucher(
401+ cr, uid, ids, context)
402+ reconcile_pool = self.pool.get('account.move.reconcile')
403+ move_pool = self.pool.get('account.move')
404+ for voucher in self.browse(cr, uid, ids, context=context):
405+ recs = []
406+ if voucher.shadow_move_id:
407+ for line in voucher.shadow_move_id.line_id:
408+ if line.reconcile_id:
409+ recs += [line.reconcile_id.id]
410+ if line.reconcile_partial_id:
411+ recs += [line.reconcile_partial_id.id]
412+
413+ reconcile_pool.unlink(cr, uid, recs)
414+
415+ if voucher.shadow_move_id:
416+ move_pool.button_cancel(
417+ cr, uid, [voucher.shadow_move_id.id])
418+ move_pool.unlink(cr, uid, [voucher.shadow_move_id.id])
419+ return res
420+
421+
422+class account_invoice(orm.Model):
423+
424+ def _get_vat_on_payment(self, cr, uid, context=None):
425+ return self.pool.get('res.users').browse(
426+ cr, uid, uid, context).company_id.vat_on_payment
427+
428+ def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines):
429+ """
430+ Use shadow accounts for journal entry to be generated, according to
431+ account and tax code related records
432+ """
433+ move_lines = super(account_invoice, self).finalize_invoice_move_lines(
434+ cr, uid, invoice_browse, move_lines)
435+ acc_pool = self.pool.get('account.account')
436+ tax_code_pool = self.pool.get('account.tax.code')
437+ new_move_lines = []
438+ for line_tup in move_lines:
439+ if invoice_browse.vat_on_payment:
440+ if line_tup[2].get('account_id', False):
441+ account = acc_pool.browse(
442+ cr, uid, line_tup[2]['account_id'])
443+ if (
444+ account.type != 'receivable'
445+ and account.type != 'payable'
446+ ):
447+ if not account.vat_on_payment_related_account_id:
448+ raise osv.except_osv(
449+ _('Error'),
450+ _('''The invoice is \'VAT on payment\' but
451+ account %s does not have a related shadow
452+ account''')
453+ % account.name)
454+ line_tup[2]['real_account_id'] = line_tup[
455+ 2]['account_id']
456+ line_tup[2]['account_id'] = (
457+ account.vat_on_payment_related_account_id.id)
458+ if line_tup[2].get('tax_code_id', False):
459+ tax_code = tax_code_pool.browse(
460+ cr, uid, line_tup[2]['tax_code_id'])
461+ if not tax_code.vat_on_payment_related_tax_code_id:
462+ raise osv.except_osv(
463+ _('Error'),
464+ _('''The invoice is \'VAT on payment\' but
465+ tax code %s does not have a related shadow
466+ tax code''')
467+ % tax_code.name)
468+ line_tup[2]['real_tax_code_id'] = line_tup[
469+ 2]['tax_code_id']
470+ line_tup[2]['tax_code_id'] = (
471+ tax_code.vat_on_payment_related_tax_code_id.id)
472+ new_move_lines.append(line_tup)
473+ return new_move_lines
474+
475+ def onchange_partner_id(
476+ self, cr, uid, ids, type, partner_id, date_invoice=False,
477+ payment_term=False, partner_bank_id=False, company_id=False):
478+ res = super(account_invoice, self).onchange_partner_id(
479+ cr, uid, ids, type, partner_id, date_invoice, payment_term,
480+ partner_bank_id, company_id)
481+ # default value for VAT on Payment is changed every time the
482+ # customer/supplier is changed
483+ partner_obj = self.pool.get("res.partner")
484+ if partner_id:
485+ p = partner_obj.browse(cr, uid, partner_id)
486+ if p.property_account_position:
487+ res['value'][
488+ 'vat_on_payment'
489+ ] = p.property_account_position.default_has_vat_on_payment
490+ return res
491+
492+ _inherit = "account.invoice"
493+ _columns = {
494+ 'vat_on_payment': fields.boolean('Vat on payment'),
495+ }
496+ _defaults = {
497+ 'vat_on_payment': _get_vat_on_payment,
498+ }
499+
500+
501+class account_move_line(orm.Model):
502+ _inherit = "account.move.line"
503+ _columns = {
504+ 'real_payment_move_id': fields.many2one(
505+ 'account.move', 'Real payment entry'),
506+ 'real_account_id': fields.many2one('account.account', 'Real account'),
507+ 'real_tax_code_id': fields.many2one(
508+ 'account.tax.code', 'Real tax code'),
509+ }
510+
511+
512+class account_account(orm.Model):
513+ _inherit = "account.account"
514+ _columns = {
515+ 'vat_on_payment_related_account_id': fields.many2one(
516+ 'account.account', 'Shadow Account for VAT on payment',
517+ help='''Related account used for real registrations on a
518+ VAT on payment basis. Set the shadow account here'''),
519+ }
520+
521+
522+class account_tax_code(orm.Model):
523+ _inherit = "account.tax.code"
524+ _columns = {
525+ 'vat_on_payment_related_tax_code_id': fields.many2one(
526+ 'account.tax.code', 'Shadow Tax code for VAT on payment',
527+ help='''Related tax code used for real registrations on a
528+ VAT on payment basis. Set the shadow tax code here'''),
529+ }
530+
531+
532+class account_journal(orm.Model):
533+ _inherit = "account.journal"
534+ _columns = {
535+ 'vat_on_payment_related_journal_id': fields.many2one(
536+ 'account.journal', 'Shadow Journal for VAT on payment',
537+ help='''Related journal used for shadow registrations on a
538+ VAT on payment basis. Set the shadow journal here'''),
539+ }
540
541=== added file 'account_vat_on_payment/account_view.xml'
542--- account_vat_on_payment/account_view.xml 1970-01-01 00:00:00 +0000
543+++ account_vat_on_payment/account_view.xml 2014-06-03 16:12:49 +0000
544@@ -0,0 +1,104 @@
545+<?xml version="1.0" encoding="utf-8"?>
546+<openerp>
547+ <data>
548+
549+<!-- account -->
550+
551+ <record id="view_account_form" model="ir.ui.view">
552+ <field name="name">account.account.form</field>
553+ <field name="model">account.account</field>
554+ <field name="inherit_id" ref="account.view_account_form"/>
555+ <field name="arch" type="xml">
556+ <field position="after" name="child_consol_ids">
557+ <field name="vat_on_payment_related_account_id"/>
558+ </field>
559+ </field>
560+ </record>
561+
562+<!-- tax code -->
563+
564+ <record id="view_tax_code_form" model="ir.ui.view">
565+ <field name="name">account.tax.code.form</field>
566+ <field name="model">account.tax.code</field>
567+ <field name="inherit_id" ref="account.view_tax_code_form"/>
568+ <field name="arch" type="xml">
569+ <field position="after" name="company_id">
570+ <field name="vat_on_payment_related_tax_code_id"/>
571+ </field>
572+ </field>
573+ </record>
574+
575+<!-- journal -->
576+
577+ <record id="view_account_journal_form" model="ir.ui.view">
578+ <field name="name">account.journal.form</field>
579+ <field name="model">account.journal</field>
580+ <field name="inherit_id" ref="account.view_account_journal_form"/>
581+ <field name="arch" type="xml">
582+ <field name="group_invoice_lines" position="after">
583+ <field name="vat_on_payment_related_journal_id"/>
584+ </field>
585+ </field>
586+ </record>
587+
588+<!-- invoice -->
589+
590+ <record id="invoice_form" model="ir.ui.view">
591+ <field name="name">account.invoice.form</field>
592+ <field name="model">account.invoice</field>
593+ <field name="inherit_id" ref="account.invoice_form"/>
594+ <field name="arch" type="xml">
595+ <field name="payment_term" position="after">
596+ <field name="vat_on_payment"/>
597+ </field>
598+ </field>
599+ </record>
600+ <record id="invoice_supplier_form" model="ir.ui.view">
601+ <field name="name">account.invoice.supplier.form</field>
602+ <field name="model">account.invoice</field>
603+ <field name="inherit_id" ref="account.invoice_supplier_form"/>
604+ <field name="arch" type="xml">
605+ <field name="date_due" position="after">
606+ <field name="vat_on_payment"/>
607+ </field>
608+ </field>
609+ </record>
610+
611+ <!-- move line -->
612+
613+ <record id="view_move_line_form" model="ir.ui.view">
614+ <field name="name">account.move.line.form</field>
615+ <field name="model">account.move.line</field>
616+ <field name="inherit_id" ref="account.view_move_line_form"/>
617+ <field name="arch" type="xml">
618+ <field name="reconcile_partial_id" position="after">
619+ <field name="real_payment_move_id" />
620+ </field>
621+ </field>
622+ </record>
623+
624+ <!-- voucher -->
625+
626+ <record id="view_vendor_receipt_form_shadow_move" model="ir.ui.view">
627+ <field name="name">account.voucher.receipt.form.shadow.move</field>
628+ <field name="model">account.voucher</field>
629+ <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/>
630+ <field name="arch" type="xml">
631+ <field name="move_ids" position="after">
632+ <field name="shadow_move_id" />
633+ </field>
634+ </field>
635+ </record>
636+
637+ <record id="view_vendor_payment_form_shadow_move" model="ir.ui.view">
638+ <field name="name">account.voucher.payment.form.shadow.move</field>
639+ <field name="model">account.voucher</field>
640+ <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"/>
641+ <field name="arch" type="xml">
642+ <field name="move_ids" position="after">
643+ <field name="shadow_move_id" />
644+ </field>
645+ </field>
646+ </record>
647+ </data>
648+</openerp>
649
650=== added file 'account_vat_on_payment/company.py'
651--- account_vat_on_payment/company.py 1970-01-01 00:00:00 +0000
652+++ account_vat_on_payment/company.py 2014-06-03 16:12:49 +0000
653@@ -0,0 +1,42 @@
654+# -*- coding: utf-8 -*-
655+##############################################################################
656+#
657+# OpenERP, Open Source Management Solution
658+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
659+# Copyright (C) 2012-2013 Agile Business Group sagl
660+# (<http://www.agilebg.com>)
661+#
662+# This program is free software: you can redistribute it and/or modify
663+# it under the terms of the GNU Affero General Public License as
664+# published by the Free Software Foundation, either version 3 of the
665+# License, or (at your option) any later version.
666+#
667+# This program is distributed in the hope that it will be useful,
668+# but WITHOUT ANY WARRANTY; without even the implied warranty of
669+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
670+# GNU Affero General Public License for more details.
671+#
672+# You should have received a copy of the GNU Affero General Public License
673+# along with this program. If not, see <http://www.gnu.org/licenses/>.
674+#
675+##############################################################################
676+
677+from openerp.osv import orm, fields
678+from tools.translate import _
679+
680+
681+class res_company(orm.Model):
682+ _inherit = "res.company"
683+ _columns = {
684+ 'vat_on_payment': fields.boolean('VAT on payment treatment'),
685+ }
686+
687+
688+class account_config_settings(orm.TransientModel):
689+ _inherit = 'account.config.settings'
690+ _columns = {
691+ 'vat_on_payment': fields.related(
692+ 'company_id', 'vat_on_payment',
693+ type='boolean',
694+ string="VAT on payment treatment"),
695+ }
696
697=== added file 'account_vat_on_payment/company_view.xml'
698--- account_vat_on_payment/company_view.xml 1970-01-01 00:00:00 +0000
699+++ account_vat_on_payment/company_view.xml 2014-06-03 16:12:49 +0000
700@@ -0,0 +1,21 @@
701+<?xml version="1.0" encoding="utf-8"?>
702+<openerp>
703+ <data>
704+
705+<!-- account -->
706+
707+ <record id="view_account_settings_currency_xchange_form" model="ir.ui.view">
708+ <field name="name">view_account_settings_currency_xchange_form</field>
709+ <field name="model">account.config.settings</field>
710+ <field name="inherit_id" ref="account_voucher_cash_basis.view_account_config_settings"/>
711+ <field name="arch" type="xml">
712+ <xpath expr="/form/group[5]/div" position="inside">
713+ <div>
714+ <field name="vat_on_payment" class="oe_inline"/>
715+ <label for="vat_on_payment"/>
716+ </div>
717+ </xpath>
718+ </field>
719+ </record>
720+ </data>
721+</openerp>
722
723=== added directory 'account_vat_on_payment/i18n'
724=== added file 'account_vat_on_payment/partner.py'
725--- account_vat_on_payment/partner.py 1970-01-01 00:00:00 +0000
726+++ account_vat_on_payment/partner.py 2014-06-03 16:12:49 +0000
727@@ -0,0 +1,36 @@
728+# -*- coding: utf-8 -*-
729+##############################################################################
730+#
731+# OpenERP, Open Source Management Solution
732+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
733+# Copyright (C) 2012-2013 Agile Business Group sagl
734+# (<http://www.agilebg.com>)
735+# Copyright (C) 2014 Develer srl (<http://www.develer.com>)
736+#
737+# This program is free software: you can redistribute it and/or modify
738+# it under the terms of the GNU Affero General Public License as
739+# published by the Free Software Foundation, either version 3 of the
740+# License, or (at your option) any later version.
741+#
742+# This program is distributed in the hope that it will be useful,
743+# but WITHOUT ANY WARRANTY; without even the implied warranty of
744+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
745+# GNU Affero General Public License for more details.
746+#
747+# You should have received a copy of the GNU Affero General Public License
748+# along with this program. If not, see <http://www.gnu.org/licenses/>.
749+#
750+##############################################################################
751+
752+
753+from openerp.osv import fields, orm
754+from openerp.tools.translate import _
755+
756+
757+class account_fiscal_position(orm.Model):
758+ _inherit = 'account.fiscal.position'
759+
760+ _columns = {
761+ 'default_has_vat_on_payment': fields.boolean(
762+ 'VAT on Payment Default Flag'),
763+ }
764
765=== added file 'account_vat_on_payment/partner_view.xml'
766--- account_vat_on_payment/partner_view.xml 1970-01-01 00:00:00 +0000
767+++ account_vat_on_payment/partner_view.xml 2014-06-03 16:12:49 +0000
768@@ -0,0 +1,48 @@
769+<?xml version="1.0"?>
770+
771+<!--
772+# -*- coding: utf-8 -*-
773+##############################################################################
774+#
775+# OpenERP, Open Source Management Solution
776+# Copyright (C) 2011-2012 Domsense s.r.l. (<http://www.domsense.com>).
777+# Copyright (C) 2012-2013 Agile Business Group sagl
778+# (<http://www.agilebg.com>)
779+# Copyright (C) 2014 Develer srl (<http://www.develer.com>)
780+#
781+# This program is free software: you can redistribute it and/or modify
782+# it under the terms of the GNU Affero General Public License as
783+# published by the Free Software Foundation, either version 3 of the
784+# License, or (at your option) any later version.
785+#
786+# This program is distributed in the hope that it will be useful,
787+# but WITHOUT ANY WARRANTY; without even the implied warranty of
788+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
789+# GNU Affero General Public License for more details.
790+#
791+# You should have received a copy of the GNU Affero General Public License
792+# along with this program. If not, see <http://www.gnu.org/licenses/>.
793+#
794+##############################################################################
795+-->
796+
797+
798+<openerp>
799+ <data>
800+
801+ <!-- res.partner customizations -->
802+
803+ <record id="view_partner_form" model="ir.ui.view">
804+ <field name="name">account.fiscal.position.vat.default.view</field>
805+ <field name="model">account.fiscal.position</field>
806+ <field name="inherit_id" ref="account.view_account_position_form"/>
807+ <field name="arch" type="xml">
808+ <field name="active" position="after" version="7.0">
809+ <field name="default_has_vat_on_payment" class="oe_inline"/>
810+ </field>
811+ </field>
812+ </record>
813+
814+
815+ </data>
816+</openerp>