[MERGE] branch with improvements of refunds handling in account_voucher + whipping of some dead code (in account_voucher too)
bzr revid: qdp-launchpad@openerp.com-20120810152331-h837mhhvdq8x0j1y
This commit is contained in:
@@ -163,8 +163,10 @@
|
||||
<sheet string="Supplier Invoice">
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<label string="Draft Invoice" attrs="{'invisible': [('state', '<>', 'draft')]}"/>
|
||||
<label string="Invoice" attrs="{'invisible': [('state', '=', 'draft')]}"/>
|
||||
<label string="Draft Invoice" attrs="{'invisible': ['|',('state','<>','draft'), ('type','<>','in_invoice')]}"/>
|
||||
<label string="Draft Refund" attrs="{'invisible': ['|',('state','<>','draft'), ('type','<>','in_refund')]}"/>
|
||||
<label string="Invoice" attrs="{'invisible': ['|',('state', '=', 'draft'), ('type','<>','in_invoice')]}"/>
|
||||
<label string="Refund" attrs="{'invisible': ['|',('state', '=', 'draft'), ('type','<>','in_refund')]}"/>
|
||||
<field name="number" class="oe_inline" attrs="{'invisible': [('state', '=', 'draft')]}"/>
|
||||
</h1>
|
||||
</div>
|
||||
@@ -309,9 +311,11 @@
|
||||
</header>
|
||||
<sheet string="Invoice">
|
||||
<h1>
|
||||
<label string="Draft Invoice " attrs="{'invisible': [('state','not in',('draft',))]}"/>
|
||||
<label string="Draft Invoice " attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','<>','out_invoice')]}"/>
|
||||
<label string="Draft Refund " attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','<>','out_refund')]}"/>
|
||||
<label string="Pro Forma Invoice " attrs="{'invisible': [('state','not in',('proforma','proforma2'))]}"/>
|
||||
<label string="Invoice " attrs="{'invisible': [('state','in',('draft','proforma','proforma2'))]}"/>
|
||||
<label string="Invoice " attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','<>','out_invoice')]}"/>
|
||||
<label string="Refund " attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','<>','out_refund')]}"/>
|
||||
<field name="number" readonly="1" class="oe_inline"/>
|
||||
</h1>
|
||||
<field name="type" invisible="1"/>
|
||||
|
||||
@@ -49,7 +49,6 @@ eInvoicing & Payments module manage all Voucher Entries such as "Reconciliation
|
||||
"account_voucher_sequence.xml",
|
||||
"account_voucher_workflow.xml",
|
||||
"account_voucher_report.xml",
|
||||
"wizard/account_voucher_unreconcile_view.xml",
|
||||
"wizard/account_statement_from_invoice_view.xml",
|
||||
"account_voucher_view.xml",
|
||||
"voucher_payment_receipt_view.xml",
|
||||
|
||||
@@ -46,11 +46,7 @@ class account_voucher(osv.osv):
|
||||
def _check_paid(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
paid = False
|
||||
for line in voucher.move_ids:
|
||||
if (line.account_id.type, 'in', ('receivable', 'payable')) and line.reconcile_id:
|
||||
paid = True
|
||||
res[voucher.id] = paid
|
||||
res[voucher.id] = any([((line.account_id.type, 'in', ('receivable', 'payable')) and line.reconcile_id) for line in voucher.move_ids])
|
||||
return res
|
||||
|
||||
def _get_type(self, cr, uid, context=None):
|
||||
@@ -186,15 +182,16 @@ class account_voucher(osv.osv):
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount):
|
||||
def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount, type):
|
||||
debit = credit = 0.0
|
||||
sign = type == 'payment' and -1 or 1
|
||||
for l in line_dr_ids:
|
||||
debit += l['amount']
|
||||
for l in line_cr_ids:
|
||||
credit += l['amount']
|
||||
return abs(amount - abs(credit - debit))
|
||||
return amount - sign * (credit - debit)
|
||||
|
||||
def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_currency, context=None):
|
||||
def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_currency, type, context=None):
|
||||
context = context or {}
|
||||
if not line_dr_ids and not line_cr_ids:
|
||||
return {'value':{}}
|
||||
@@ -215,7 +212,7 @@ class account_voucher(osv.osv):
|
||||
if voucher_line.get('currency_id', company_currency) != company_currency:
|
||||
is_multi_currency = True
|
||||
break
|
||||
return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount), 'is_multi_currency': is_multi_currency}}
|
||||
return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount, type), 'is_multi_currency': is_multi_currency}}
|
||||
|
||||
def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None):
|
||||
if not ids: return {}
|
||||
@@ -223,12 +220,13 @@ class account_voucher(osv.osv):
|
||||
res = {}
|
||||
debit = credit = 0.0
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
sign = voucher.type == 'payment' and -1 or 1
|
||||
for l in voucher.line_dr_ids:
|
||||
debit += l.amount
|
||||
for l in voucher.line_cr_ids:
|
||||
credit += l.amount
|
||||
currency = voucher.currency_id or voucher.company_id.currency_id
|
||||
res[voucher.id] = currency_obj.round(cr, uid, currency, abs(voucher.amount - abs(credit - debit)))
|
||||
res[voucher.id] = currency_obj.round(cr, uid, currency, voucher.amount - sign * (credit - debit))
|
||||
return res
|
||||
|
||||
def _paid_amount_in_company_currency(self, cr, uid, ids, name, args, context=None):
|
||||
@@ -716,7 +714,7 @@ class account_voucher(osv.osv):
|
||||
default['value']['pre_line'] = 1
|
||||
elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
|
||||
default['value']['pre_line'] = 1
|
||||
default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price)
|
||||
default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price, ttype)
|
||||
return default
|
||||
|
||||
def onchange_payment_rate_currency(self, cr, uid, ids, currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context=None):
|
||||
|
||||
@@ -40,7 +40,7 @@ class invoice(osv.osv):
|
||||
'domain': '[]',
|
||||
'context': {
|
||||
'default_partner_id': inv.partner_id.id,
|
||||
'default_amount': inv.residual,
|
||||
'default_amount': inv.type in ('out_refund', 'in_refund') and -inv.residual or inv.residual,
|
||||
'default_name':inv.name,
|
||||
'close_after_process': True,
|
||||
'invoice_type':inv.type,
|
||||
|
||||
@@ -173,12 +173,12 @@
|
||||
self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 10.0
|
||||
I check that writeoff amount computed is -10.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_seagate'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 10.0), "Writeoff amount is not 10.0"
|
||||
assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
@@ -266,12 +266,12 @@
|
||||
self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
|
||||
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 5.0
|
||||
I check that writeoff amount computed is -5.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_seagate'))])
|
||||
voucher_id = self.browse(cr, uid, voucher[0])
|
||||
assert (voucher_id.writeoff_amount == 5.0), "Writeoff amount is not 5.0"
|
||||
assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
|
||||
@@ -107,11 +107,11 @@
|
||||
self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
|
||||
assert (voucher.state=='draft'), "Voucher is not in draft state"
|
||||
-
|
||||
I check that writeoff amount computed is 50.0
|
||||
I check that writeoff amount computed is -50.0
|
||||
-
|
||||
!python {model: account.voucher}: |
|
||||
voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
|
||||
assert (voucher.writeoff_amount == 50.0), "Writeoff amount is not 50.0"
|
||||
assert (voucher.writeoff_amount == -50.0), "Writeoff amount is not -50.0"
|
||||
-
|
||||
I confirm the voucher
|
||||
-
|
||||
@@ -167,4 +167,4 @@
|
||||
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
|
||||
move_line = move_line_obj.browse(cr, uid, move_lines[0])
|
||||
assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for Invoice"
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Payment Information">
|
||||
<field name="line_dr_ids" attrs="{'invisible': [('type', '=', 'receipt')]}" context="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, context)">
|
||||
<field name="line_dr_ids" attrs="{'invisible': [('type', '=', 'receipt')]}" context="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, type, context)">
|
||||
<tree string="Open Supplier Journal Entries" editable="bottom" colors="gray:amount==0">
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
@@ -87,7 +87,7 @@
|
||||
<field name="amount" sum="Total Allocation"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="line_cr_ids" attrs="{'invisible': [('type', '=', 'payment')]}" context="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, context)">
|
||||
<field name="line_cr_ids" attrs="{'invisible': [('type', '=', 'payment')]}" context="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, type, context)">
|
||||
<tree string="Open Customer Journal Entries" editable="bottom" colors="gray:amount==0">
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
@@ -332,7 +332,7 @@
|
||||
|
||||
<notebook>
|
||||
<page string="Payment Information" groups="base.group_user">
|
||||
<field name="line_cr_ids" context="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, context)">
|
||||
<field name="line_cr_ids" context="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, type, context)">
|
||||
<tree string="Invoices and outstanding transactions" editable="bottom" colors="gray:amount==0">
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
@@ -348,7 +348,7 @@
|
||||
<field name="amount" sum="Total Allocation" on_change="onchange_amount(amount, amount_unreconciled, context)" string="Allocation"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="line_dr_ids" attrs="{'invisible': [('pre_line','=',False)]}" context="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, context)">
|
||||
<field name="line_dr_ids" attrs="{'invisible': [('pre_line','=',False)]}" context="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, type, context)">
|
||||
<tree string="Credits" editable="bottom" colors="gray:amount==0">
|
||||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_voucher_unreconcile
|
||||
import account_statement_from_invoice
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -75,16 +75,26 @@ class account_statement_from_invoice_lines(osv.osv_memory):
|
||||
statement.currency.id, amount, context=ctx)
|
||||
|
||||
context.update({'move_line_ids': [line.id]})
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, amount=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), date=line_date, context=context)
|
||||
voucher_res = { 'type':(amount < 0 and 'payment' or 'receipt'),
|
||||
type = 'general'
|
||||
ttype = amount < 0 and 'payment' or 'receipt'
|
||||
sign = 1
|
||||
if line.journal_id.type in ('sale', 'sale_refund'):
|
||||
type = 'customer'
|
||||
ttype = 'receipt'
|
||||
elif line.journal_id.type in ('purchase', 'purhcase_refund'):
|
||||
type = 'supplier'
|
||||
ttype = 'payment'
|
||||
sign = -1
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, amount=sign*amount, currency_id= statement.currency.id, ttype=ttype, date=line_date, context=context)
|
||||
voucher_res = { 'type': ttype,
|
||||
'name': line.name,
|
||||
'partner_id': line.partner_id.id,
|
||||
'journal_id': statement.journal_id.id,
|
||||
'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id), # improve me: statement.journal_id.default_credit_account_id.id
|
||||
'company_id':statement.company_id.id,
|
||||
'currency_id':statement.currency.id,
|
||||
'date':line.date,
|
||||
'amount':abs(amount),
|
||||
'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id),
|
||||
'company_id': statement.company_id.id,
|
||||
'currency_id': statement.currency.id,
|
||||
'date': line.date,
|
||||
'amount': sign*amount,
|
||||
'period_id':statement.period_id.id}
|
||||
voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
|
||||
|
||||
@@ -97,12 +107,6 @@ class account_statement_from_invoice_lines(osv.osv_memory):
|
||||
if voucher_line_dict:
|
||||
voucher_line_dict.update({'voucher_id': voucher_id})
|
||||
voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
|
||||
if line.journal_id.type == 'sale':
|
||||
type = 'customer'
|
||||
elif line.journal_id.type == 'purchase':
|
||||
type = 'supplier'
|
||||
else:
|
||||
type = 'general'
|
||||
statement_line_obj.create(cr, uid, {
|
||||
'name': line.name or '?',
|
||||
'amount': amount,
|
||||
@@ -112,81 +116,10 @@ class account_statement_from_invoice_lines(osv.osv_memory):
|
||||
'statement_id': statement_id,
|
||||
'ref': line.ref,
|
||||
'voucher_id': voucher_id,
|
||||
'date': time.strftime('%Y-%m-%d'), #time.strftime('%Y-%m-%d'), #line.date_maturity or,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
}, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
account_statement_from_invoice_lines()
|
||||
|
||||
class account_statement_from_invoice(osv.osv_memory):
|
||||
"""
|
||||
Generate Entries by Statement from Invoices
|
||||
"""
|
||||
_name = "account.statement.from.invoice"
|
||||
_description = "Entries by Statement from Invoices"
|
||||
_columns = {
|
||||
'date': fields.date('Date payment',required=True),
|
||||
'journal_ids': fields.many2many('account.journal', 'account_journal_relation', 'account_id', 'journal_id', 'Journal'),
|
||||
'line_ids': fields.many2many('account.move.line', 'account_move_line_relation', 'move_id', 'line_id', 'Invoices'),
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
|
||||
def search_invoices(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
line_obj = self.pool.get('account.move.line')
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
statement_id = 'statement_id' in context and context['statement_id']
|
||||
|
||||
data = self.read(cr, uid, ids, context=context)[0]
|
||||
statement = statement_obj.browse(cr, uid, statement_id, context=context)
|
||||
args_move_line = []
|
||||
repeated_move_line_ids = []
|
||||
# Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again)
|
||||
for st_line in statement.line_ids:
|
||||
args_move_line = []
|
||||
args_move_line.append(('name', '=', st_line.name))
|
||||
args_move_line.append(('ref', '=', st_line.ref))
|
||||
if st_line.partner_id:
|
||||
args_move_line.append(('partner_id', '=', st_line.partner_id.id))
|
||||
args_move_line.append(('account_id', '=', st_line.account_id.id))
|
||||
|
||||
move_line_id = line_obj.search(cr, uid, args_move_line, context=context)
|
||||
if move_line_id:
|
||||
repeated_move_line_ids += move_line_id
|
||||
|
||||
journal_ids = data['journal_ids']
|
||||
if journal_ids == []:
|
||||
journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale', 'cash', 'purchase'))], context=context)
|
||||
|
||||
args = [
|
||||
('reconcile_id', '=', False),
|
||||
('journal_id', 'in', journal_ids),
|
||||
('account_id.reconcile', '=', True)]
|
||||
|
||||
if repeated_move_line_ids:
|
||||
args.append(('id', 'not in', repeated_move_line_ids))
|
||||
|
||||
line_ids = line_obj.search(cr, uid, args,
|
||||
context=context)
|
||||
|
||||
model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'view_account_statement_from_invoice_lines')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join([str(x) for x in line_ids])+"])]",
|
||||
'name': _('Import Entries'),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'account.statement.from.invoice.lines',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
account_statement_from_invoice()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,34 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_account_statement_from_invoice" model="ir.ui.view">
|
||||
<field name="name">account.statement.from.invoice.form</field>
|
||||
<field name="model">account.statement.from.invoice</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import Invoices in Statement" version="7.0">
|
||||
<group>
|
||||
<field name="date"/>
|
||||
<field name="journal_ids" domain="[('type','in',['sale','purchase','cash'])]"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Go" name="search_invoices" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_account_statement_from_invoice" model="ir.actions.act_window">
|
||||
<field name="name">Import Invoices in Statement</field>
|
||||
<field name="res_model">account.statement.from.invoice</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_account_statement_from_invoice"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_statement_from_invoice_lines" model="ir.ui.view">
|
||||
<field name="name">account.statement.from.invoice.lines.form</field>
|
||||
<field name="model">account.statement.from.invoice.lines</field>
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
|
||||
class account_voucher_unreconcile(osv.osv_memory):
|
||||
_name = "account.voucher.unreconcile"
|
||||
_description = "Account voucher unreconcile"
|
||||
|
||||
_columns = {
|
||||
'remove':fields.boolean('Want to remove accounting entries too ?', required=False),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'remove': True,
|
||||
}
|
||||
|
||||
def trans_unrec(self, cr, uid, ids, context=None):
|
||||
# res = self.browse(cr, uid, ids[0])
|
||||
if context is None:
|
||||
context = {}
|
||||
voucher_pool = self.pool.get('account.voucher')
|
||||
reconcile_pool = self.pool.get('account.move.reconcile')
|
||||
if context.get('active_id'):
|
||||
voucher = voucher_pool.browse(cr, uid, context.get('active_id'), context=context)
|
||||
recs = []
|
||||
for line in voucher.move_ids:
|
||||
if line.reconcile_id:
|
||||
recs += [line.reconcile_id.id]
|
||||
if line.reconcile_partial_id:
|
||||
recs += [line.reconcile_partial_id.id]
|
||||
#for rec in recs:
|
||||
reconcile_pool.unlink(cr, uid, recs)
|
||||
# if res.remove:
|
||||
voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context)
|
||||
# wf_service = netsvc.LocalService("workflow")
|
||||
# wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr)
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
account_voucher_unreconcile()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_voucher_unreconcile" model="ir.ui.view">
|
||||
<field name="name">Account voucher unreconcile</field>
|
||||
<field name="model">account.voucher.unreconcile</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Unreconciliation" version="7.0">
|
||||
<separator string="Unreconciliation Transactions" />
|
||||
<label string="If you unreconciliate transactions, you must also verify all the actions that are linked to those transactions because they will not be disable"/>
|
||||
<footer>
|
||||
<button name="trans_unrec" default_focus="1" string="Unreconcile" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_view_account_voucher_unreconcile">
|
||||
<field name="name">Unreconcile entries</field>
|
||||
<field name="res_model">account.voucher.unreconcile</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_account_voucher_unreconcile"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user