[IMP]: account: Code + Quality improvement for wizards
bzr revid: rpa@openerp.co.in-20100302071315-hxcltca6fnwvot1e
This commit is contained in:
@@ -48,7 +48,6 @@
|
||||
'wizard/account_move_line_reconcile_select_view.xml',
|
||||
'wizard/account_move_journal_view.xml',
|
||||
|
||||
|
||||
'account_wizard.xml',
|
||||
'account_view.xml',
|
||||
'account_end_fy.xml',
|
||||
|
||||
@@ -189,15 +189,17 @@
|
||||
<field name="amount_total"/>
|
||||
<field name="state" select="2"/>
|
||||
<field name="residual"/>
|
||||
<group col="6" colspan="4">
|
||||
<group col="7" colspan="4">
|
||||
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-apply"/>
|
||||
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
|
||||
<!-- <button name='%(wizard_invoice_pay)d' type='action' string='Pay Invoice' states='open,paid,proforma2' icon="STOCK_EXECUTE" /> -->
|
||||
<!-- <button name='%(wizard_invoice_refund)d' type='action' string='Credit Note' icon="STOCK_EXECUTE" />-->
|
||||
<!-- Wizard Buttons: To Remove -->
|
||||
<button name="%(wizard_invoice_pay)d" type="action" string="Pay Invoice" states="open,paid,proforma2" icon="STOCK_EXECUTE" />
|
||||
<button name="%(wizard_invoice_refund)d" type="action" string="Credit Note" icon="STOCK_EXECUTE" />
|
||||
</group>
|
||||
</group>
|
||||
|
||||
</page>
|
||||
<page string="Other Info">
|
||||
<field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
|
||||
@@ -287,8 +289,9 @@
|
||||
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
|
||||
<!-- <button name='%(wizard_invoice_pay)d' type='action' string='Pay Invoice' states='open,paid,proforma2' icon="STOCK_EXECUTE" /> -->
|
||||
<!-- <button name='%(wizard_invoice_refund)d' type='action' string='Credit Note' icon="STOCK_EXECUTE" /> -->
|
||||
<!-- Wizard Buttons: To Remove -->
|
||||
<button name="%(wizard_invoice_pay)d" type="action" string="Pay Invoice" states="open,paid,proforma2" icon="STOCK_EXECUTE" />
|
||||
<button name="%(wizard_invoice_refund)d" type="action" string="Credit Note" icon="STOCK_EXECUTE" />
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
@@ -19,17 +19,14 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# OLD Wizards
|
||||
import wizard_automatic_reconcile
|
||||
import wizard_reconcile_select
|
||||
import wizard_unreconcile_select
|
||||
import wizard_reconcile
|
||||
import wizard_unreconcile
|
||||
import wizard_refund
|
||||
import wizard_pay_invoice
|
||||
|
||||
import wizard_journal
|
||||
import wizard_journal_select
|
||||
import wizard_bank_reconcile
|
||||
import wizard_subscription_generate
|
||||
|
||||
import wizard_aged_trial_balance
|
||||
@@ -38,16 +35,14 @@ import wizard_third_party_ledger
|
||||
import wizard_account_balance_report
|
||||
import wizard_partner_balance_report
|
||||
|
||||
import wizard_period_close
|
||||
import wizard_fiscalyear_close
|
||||
import wizard_fiscalyear_close_state
|
||||
#import wizard_fiscalyear_close_state
|
||||
import wizard_open_closed_fiscalyear
|
||||
|
||||
import wizard_vat
|
||||
|
||||
import wizard_invoice_state
|
||||
import wizard_account_duplicate
|
||||
import wizard_account_chart
|
||||
import wizard_move_line_select
|
||||
|
||||
import wizard_validate_account_move
|
||||
@@ -70,6 +65,3 @@ import account_move_line_reconcile_select
|
||||
import account_move_journal
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -18,63 +18,70 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
import wizard
|
||||
|
||||
class account_chart(osv.osv_memory):
|
||||
"""
|
||||
For account chart
|
||||
For Chart of Accounrs
|
||||
"""
|
||||
|
||||
|
||||
def _get_defaults(self, cr, uid, context):
|
||||
|
||||
"""Return default Fiscalyear value"""
|
||||
|
||||
|
||||
"""Return default Fiscalyear value"""
|
||||
|
||||
fiscalyear_obj = self.pool.get('account.fiscalyear')
|
||||
fiscalyear = fiscalyear_obj.find(cr, uid)
|
||||
return fiscalyear
|
||||
|
||||
|
||||
def _account_chart_open_window(self, cr, uid, ids, context):
|
||||
"""
|
||||
|
||||
Opens chart of Accounts
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: the account chart’s ID or list of IDs if we want more than one
|
||||
@return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
|
||||
@param ids: List of account chart’s IDs
|
||||
@return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
|
||||
"""
|
||||
for form in self.read(cr, uid, ids):
|
||||
|
||||
for data in self.read(cr, uid, ids):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
act_obj = self.pool.get('ir.actions.act_window')
|
||||
|
||||
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
|
||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||
result = act_obj.read(cr, uid, [id], context=context)[0]
|
||||
result['context'] = str({'fiscalyear': form['fiscalyear'],'state':form['target_move']})
|
||||
if form['fiscalyear']:
|
||||
result['name']+=':'+self.pool.get('account.fiscalyear').read(cr,uid,[form['fiscalyear']])[0]['code']
|
||||
|
||||
result['context'] = str({'fiscalyear': data['fiscalyear'], \
|
||||
'state': data['target_move']})
|
||||
if data['fiscalyear']:
|
||||
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']])[0]['code']
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
_name = "account.chart"
|
||||
_description = "chart"
|
||||
_columns = {
|
||||
'fiscalyear':fields.many2one('account.fiscalyear', 'Fiscal year', required=True, help = 'Keep empty for all open fiscal years'),
|
||||
'target_move':fields.selection([
|
||||
('all','All Entries'),
|
||||
('posted','All Posted Entries'),
|
||||
],'Target Moves', required = True),
|
||||
|
||||
'fiscalyear': fields.many2one('account.fiscalyear', \
|
||||
'Fiscal year', required=True, \
|
||||
help = 'Keep empty for all open fiscal years'),
|
||||
'target_move': fields.selection([
|
||||
('all', 'All Entries'),
|
||||
('posted', 'All Posted Entries'),
|
||||
], 'Target Moves', required = True),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'fiscalyear':_get_defaults,
|
||||
'target_move':lambda * a:'all'
|
||||
|
||||
'fiscalyear': _get_defaults,
|
||||
'target_move': lambda * a: 'all'
|
||||
}
|
||||
|
||||
|
||||
account_chart()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_chart" model="ir.ui.view">
|
||||
<field name="name">account.chart.form</field>
|
||||
<field name="model">account.chart</field>
|
||||
@@ -21,6 +22,7 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="wizard_account_chart" model="ir.actions.act_window">
|
||||
<field name="name">Chart of Accounts</field>
|
||||
<field name="res_model">account.chart</field>
|
||||
@@ -29,5 +31,6 @@
|
||||
<field name="view_id" ref="view_account_chart"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -18,23 +18,25 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
import wizard
|
||||
|
||||
class account_fiscalyear_close_state(osv.osv_memory):
|
||||
"""
|
||||
close Account Fiscalyear
|
||||
Closes Account Fiscalyear
|
||||
"""
|
||||
_name = "account.fiscalyear.close.state"
|
||||
_description = "Fiscalyear Close state"
|
||||
_columns = {
|
||||
'fy_id':fields.many2one('account.fiscalyear', 'Fiscal Year to close', required=True),
|
||||
'sure':fields.boolean('Check this box', required=False)
|
||||
'fy_id': fields.many2one('account.fiscalyear', \
|
||||
'Fiscal Year to close', required=True),
|
||||
'sure': fields.boolean('Check this box', required=False)
|
||||
}
|
||||
|
||||
def _data_save(self, cr, uid, ids, context):
|
||||
@@ -42,22 +44,27 @@ class account_fiscalyear_close_state(osv.osv_memory):
|
||||
This function close account fiscalyear
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: account fiscalyear close state’s ID or list of IDs if we want more than one
|
||||
|
||||
@param ids: List of Account fiscalyear close state’s IDs
|
||||
|
||||
"""
|
||||
for form in self.read(cr, uid, ids):
|
||||
if not form['sure']:
|
||||
raise osv.except_osv(_('UserError'), _('Closing of states cancelled, please check the box !'))
|
||||
fy_id = form['fy_id']
|
||||
|
||||
for data in self.read(cr, uid, ids):
|
||||
if not data['sure']:
|
||||
raise osv.except_osv(_('UserError'), _('Closing of states \
|
||||
cancelled, please check the box !'))
|
||||
fy_id = data['fy_id']
|
||||
|
||||
cr.execute('UPDATE account_journal_period ' \
|
||||
'SET state = %s ' \
|
||||
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
|
||||
('done',fy_id))
|
||||
'SET state = %s ' \
|
||||
'WHERE period_id IN (SELECT id FROM account_period \
|
||||
WHERE fiscalyear_id = %s)',
|
||||
('done', fy_id))
|
||||
cr.execute('UPDATE account_period SET state = %s ' \
|
||||
'WHERE fiscalyear_id = %s', ('done',fy_id))
|
||||
'WHERE fiscalyear_id = %s', ('done', fy_id))
|
||||
cr.execute('UPDATE account_fiscalyear ' \
|
||||
'SET state = %s WHERE id = %s', ('done', fy_id))
|
||||
return {}
|
||||
|
||||
|
||||
account_fiscalyear_close_state()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
<field name="view_id" ref="view_account_fiscalyear_close_state"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="wizard_fiscalyear_close_state" id="menu_wizard_fy_close_state" parent="menu_account_end_year_treatments" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -18,34 +18,36 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
import wizard
|
||||
|
||||
class account_invoice_refund(osv.osv_memory):
|
||||
|
||||
"""Account invoice refund or modify or cancel."""
|
||||
|
||||
|
||||
"""Refunds invoice."""
|
||||
|
||||
_name = "account.invoice.refund"
|
||||
_description = "Invoice Refund"
|
||||
_columns = {
|
||||
'date':fields.date('Operation date',required=False),
|
||||
'period':fields.many2one('account.period', 'Force period', required=False),
|
||||
'description':fields.char('Description', size=150, required=True),
|
||||
}
|
||||
|
||||
'date': fields.date('Operation date', required=False),
|
||||
'period': fields.many2one('account.period', 'Force period', required=False),
|
||||
'description': fields.char('Description', size=150, required=True),
|
||||
}
|
||||
|
||||
def _compute_refund(self, cr, uid, ids, mode, context):
|
||||
"""
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: the account invoice refund’s ID or list of IDs if we want more than one
|
||||
|
||||
@param ids: the account invoice refund’s ID or list of IDs
|
||||
|
||||
"""
|
||||
|
||||
inv_obj = self.pool.get('account.invoice')
|
||||
for form in self.read(cr, uid, ids):
|
||||
reconcile_obj = self.pool.get('account.move.reconcile')
|
||||
account_m_line_obj = self.pool.get('account.move.line')
|
||||
@@ -53,7 +55,7 @@ class account_invoice_refund(osv.osv_memory):
|
||||
date = False
|
||||
period = False
|
||||
description = False
|
||||
for inv in self.pool.get('account.invoice').browse(cr, uid, context['active_ids']):
|
||||
for inv in inv_obj.browse(cr, uid, context['active_ids']):
|
||||
if inv.state in ['draft', 'proforma2', 'cancel']:
|
||||
raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
|
||||
if form['period'] :
|
||||
@@ -64,20 +66,23 @@ class account_invoice_refund(osv.osv_memory):
|
||||
if form['date'] :
|
||||
date = form['date']
|
||||
if not form['period'] :
|
||||
cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'")
|
||||
cr.execute("select name from ir_model_fields \
|
||||
where model = 'account.period' \
|
||||
and name = 'company_id'")
|
||||
result_query = cr.fetchone()
|
||||
if result_query:
|
||||
#in multi company mode
|
||||
cr.execute("""SELECT id
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop and company_id = %s limit 1 """,
|
||||
(form['date'],self.pool.get('res.users').browse(cr, uid, uid).company_id.id,))
|
||||
between date_start AND date_stop \
|
||||
and company_id = %s limit 1 """,
|
||||
(form['date'], self.pool.get('res.users').browse(cr, uid, uid).company_id.id,))
|
||||
else:
|
||||
#in mono company mode
|
||||
cr.execute("""SELECT id
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop limit 1 """,
|
||||
(form['date'],))
|
||||
from account_period where date('%s')
|
||||
between date_start AND date_stop \
|
||||
limit 1 """, (form['date'],))
|
||||
res = cr.fetchone()
|
||||
if res:
|
||||
period = res[0]
|
||||
@@ -90,19 +95,21 @@ class account_invoice_refund(osv.osv_memory):
|
||||
description = inv.name
|
||||
|
||||
if not period:
|
||||
raise osv.except_osv(_('Data Insufficient !'), _('No Period found on Invoice!'))
|
||||
raise osv.except_osv(_('Data Insufficient !'), \
|
||||
_('No Period found on Invoice!'))
|
||||
|
||||
refund_id = self.pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
|
||||
refund = self.pool.get('account.invoice').browse(cr, uid, refund_id[0])
|
||||
refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description)
|
||||
refund = inv_obj.browse(cr, uid, refund_id[0])
|
||||
# we compute due date
|
||||
#!!!due date = date inv date on formdate
|
||||
self.pool.get('account.invoice').write(cr, uid, [refund.id],{'date_due':date,'check_total':inv.check_total})
|
||||
inv_obj.write(cr, uid, [refund.id], {'date_due': date,
|
||||
'check_total': inv.check_total})
|
||||
# to make the taxes calculated
|
||||
self.pool.get('account.invoice').button_compute(cr, uid, refund_id)
|
||||
inv_obj.button_compute(cr, uid, refund_id)
|
||||
|
||||
created_inv.append(refund_id[0])
|
||||
#if inv is paid we unreconcile
|
||||
if mode in ('cancel','modify'):
|
||||
if mode in ('cancel', 'modify'):
|
||||
movelines = inv.move_id.line_id
|
||||
#we unreconcile the lines
|
||||
to_reconcile_ids = {}
|
||||
@@ -110,65 +117,66 @@ class account_invoice_refund(osv.osv_memory):
|
||||
#if the account of the line is the as the one in the invoice
|
||||
#we reconcile
|
||||
if line.account_id.id == inv.account_id.id :
|
||||
to_reconcile_ids[line.account_id.id] =[line.id]
|
||||
to_reconcile_ids[line.account_id.id] = [line.id]
|
||||
if type(line.reconcile_id) != osv.orm.browse_null :
|
||||
reconcile_obj.unlink(cr,uid, line.reconcile_id.id)
|
||||
reconcile_obj.unlink(cr, uid, line.reconcile_id.id)
|
||||
#we advance the workflow of the refund to open
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
wf_service.trg_validate(uid, 'account.invoice', refund.id, 'invoice_open', cr)
|
||||
wf_service.trg_validate(uid, 'account.invoice', \
|
||||
refund.id, 'invoice_open', cr)
|
||||
#we reload the browse record
|
||||
refund = self.pool.get('account.invoice').browse(cr, uid, refund_id[0])
|
||||
refund = inv_obj.browse(cr, uid, refund_id[0])
|
||||
#we match the line to reconcile
|
||||
for tmpline in refund.move_id.line_id :
|
||||
if tmpline.account_id.id == inv.account_id.id :
|
||||
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
|
||||
for account in to_reconcile_ids :
|
||||
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
|
||||
writeoff_period_id=period,
|
||||
writeoff_journal_id=inv.journal_id.id,
|
||||
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
|
||||
writeoff_period_id=period,
|
||||
writeoff_journal_id=inv.journal_id.id,
|
||||
writeoff_acc_id=inv.account_id.id
|
||||
)
|
||||
#we create a new invoice that is the copy of the original
|
||||
if mode == 'modify' :
|
||||
invoice = self.pool.get('account.invoice').read(cr, uid, [inv.id],
|
||||
['name', 'type', 'number', 'reference',
|
||||
'comment', 'date_due', 'partner_id', 'address_contact_id',
|
||||
'address_invoice_id', 'partner_insite','partner_contact',
|
||||
'partner_ref', 'payment_term', 'account_id', 'currency_id',
|
||||
'invoice_line', 'tax_line', 'journal_id','period_id'
|
||||
]
|
||||
)
|
||||
invoice = inv_obj.read(cr, uid, [inv.id],
|
||||
['name', 'type', 'number', 'reference',
|
||||
'comment', 'date_due', 'partner_id',
|
||||
'address_contact_id', 'address_invoice_id',
|
||||
'partner_insite', 'partner_contact',
|
||||
'partner_ref', 'payment_term', 'account_id',
|
||||
'currency_id', 'invoice_line', 'tax_line',
|
||||
'journal_id', 'period_id'])
|
||||
invoice = invoice[0]
|
||||
del invoice['id']
|
||||
invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'])
|
||||
invoice_lines = self.pool.get('account.invoice')._refund_cleanup_lines(cr, uid, invoice_lines)
|
||||
invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines)
|
||||
tax_lines = self.pool.get('account.invoice.tax').read(
|
||||
cr, uid, invoice['tax_line'])
|
||||
tax_lines = self.pool.get('account.invoice')._refund_cleanup_lines(cr, uid, tax_lines)
|
||||
tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines)
|
||||
|
||||
invoice.update({
|
||||
'type': inv.type,
|
||||
'date_invoice': date,
|
||||
'state': 'draft',
|
||||
'number': False,
|
||||
'invoice_line': invoice_lines,
|
||||
'tax_line': tax_lines,
|
||||
'period_id': period,
|
||||
'name':description
|
||||
'type': inv.type,
|
||||
'date_invoice': date,
|
||||
'state': 'draft',
|
||||
'number': False,
|
||||
'invoice_line': invoice_lines,
|
||||
'tax_line': tax_lines,
|
||||
'period_id': period,
|
||||
'name': description
|
||||
})
|
||||
|
||||
#take the id part of the tuple returned for many2one fields
|
||||
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
|
||||
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
|
||||
'account_id', 'currency_id', 'payment_term', 'journal_id'):
|
||||
invoice[field] = invoice[field] and invoice[field][0]
|
||||
|
||||
# create the new invoice
|
||||
inv_id = self.pool.get('account.invoice').create(cr, uid, invoice,{})
|
||||
inv_id = inv_obj.create(cr, uid, invoice, {})
|
||||
# we compute due date
|
||||
if inv.payment_term.id:
|
||||
data = self.pool.get('account.invoice').onchange_payment_term_date_invoice(cr, uid, [inv_id],inv.payment_term.id,date)
|
||||
data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], inv.payment_term.id, date)
|
||||
if 'value' in data and data['value']:
|
||||
self.pool.get('account.invoice').write(cr, uid, [inv_id],data['value'])
|
||||
inv_obj.write(cr, uid, [inv_id], data['value'])
|
||||
created_inv.append(inv_id)
|
||||
|
||||
#we get the view id
|
||||
@@ -201,3 +209,6 @@ class account_invoice_refund(osv.osv_memory):
|
||||
return self._compute_refund(cr, uid, ids, 'modify', context)
|
||||
|
||||
account_invoice_refund()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -18,45 +18,50 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
|
||||
import wizard
|
||||
|
||||
class account_move_bank_reconcile(osv.osv_memory):
|
||||
|
||||
"""
|
||||
Bank Reconciliation
|
||||
"""
|
||||
_name = "account.move.bank.reconcile"
|
||||
_description = "Move bank reconcile"
|
||||
_columns = {
|
||||
'journal_id':fields.many2one('account.journal', 'Journal', required=True),
|
||||
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
}
|
||||
|
||||
def _action_open_window(self, cr, uid, ids, context):
|
||||
"""
|
||||
"""
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: account move bank reconcile’s ID or list of IDs if we want more than one
|
||||
@return:dictionary of Open account move line on given journal_id.
|
||||
@param ids: account move bank reconcile’s ID or list of IDs
|
||||
@return: dictionary of Open account move line on given journal_id.
|
||||
"""
|
||||
for form in self.read(cr, uid, ids):
|
||||
cr.execute('select default_credit_account_id from account_journal where id=%s', (form['journal_id'],))
|
||||
for data in self.read(cr, uid, ids):
|
||||
cr.execute('select default_credit_account_id \
|
||||
from account_journal where id=%s', (data['journal_id'],))
|
||||
account_id = cr.fetchone()[0]
|
||||
if not account_id:
|
||||
raise osv.except_osv(_('Error'), _('You have to define the bank account\nin the journal definition for reconciliation.'))
|
||||
raise osv.except_osv(_('Error'), _('You have to define \
|
||||
the bank account\nin the journal definition for reconciliation.'))
|
||||
return {
|
||||
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id),
|
||||
'name': _('Standard Encoding'),
|
||||
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
'view_id': False,
|
||||
'context': "{'journal_id':%d}" % (form['journal_id'],),
|
||||
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data['journal_id'], account_id),
|
||||
'name': _('Standard Encoding'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
'view_id': False,
|
||||
'context': "{'journal_id': %d}" % (data['journal_id'],),
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
account_move_bank_reconcile()
|
||||
account_move_bank_reconcile()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,84 +15,87 @@
|
||||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
import wizard
|
||||
|
||||
|
||||
class account_move_journal(osv.osv_memory):
|
||||
|
||||
|
||||
def _get_period(self, cr, uid, context={}):
|
||||
"""Return default account period value"""
|
||||
|
||||
"""Return default account period value"""
|
||||
|
||||
ids = self.pool.get('account.period').find(cr, uid, context=context)
|
||||
period_id = False
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
return period_id
|
||||
|
||||
|
||||
def _action_open_window(self, cr, uid, ids, context={}):
|
||||
"""
|
||||
This function Open action move line window on given period and Journal/Payment Mode
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: account move journal’s ID or list of IDs if we want more than one
|
||||
@return:dictionary of Open action move line window on given period and Journal/Payment Mode
|
||||
|
||||
@param ids: account move journal’s ID or list of IDs
|
||||
@return: dictionary of Open action move line window on given period and Journal/Payment Mode
|
||||
|
||||
"""
|
||||
for form in self.read(cr, uid, ids,['journal_id', 'period_id']):
|
||||
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form' ))
|
||||
for data in self.read(cr, uid, ids, ['journal_id', 'period_id']):
|
||||
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
|
||||
view_res = cr.fetchone()
|
||||
journal_id = data['journal_id']
|
||||
period_id = data['period_id']
|
||||
jp = self.pool.get('account.journal.period')
|
||||
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
|
||||
|
||||
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), \
|
||||
('period_id', '=', period_id)])
|
||||
|
||||
if not len(ids):
|
||||
print "ids",ids
|
||||
name = self.pool.get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
|
||||
state = self.pool.get('account.period').read(cr, uid, [form['period_id']])[0]['state']
|
||||
name = self.pool.get('account.journal').read(cr, uid, [journal_id])[0]['name']
|
||||
state = self.pool.get('account.period').read(cr, uid, [period_id])[0]['state']
|
||||
if state == 'done':
|
||||
raise osv.except_osv(_('UserError'), _('This period is already closed !'))
|
||||
company = self.pool.get('account.period').read(cr, uid, [form['period_id']])[0]['company_id'][0]
|
||||
jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id'], 'company_id':company})
|
||||
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
|
||||
print "jp",ids
|
||||
company = self.pool.get('account.period').read(cr, uid, [period_id])[0]['company_id'][0]
|
||||
jp.create(cr, uid, {'name': name, 'period_id': period_id, 'journal_id': journal_id, 'company_id': company})
|
||||
|
||||
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)])
|
||||
jp = jp.browse(cr, uid, ids, context=context)[0]
|
||||
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
|
||||
id = mod_obj.read(cr, uid, result, ['res_id'])
|
||||
res = mod_obj.read(cr, uid, result, ['res_id'])
|
||||
|
||||
return {
|
||||
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (form['journal_id'],form['period_id']),
|
||||
'name': name,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
'view_id': view_res,
|
||||
'context': "{'journal_id':%d, 'period_id':%d}" % (form['journal_id'],form['period_id']),
|
||||
'type': 'ir.actions.act_window',
|
||||
'search_view_id': id['res_id']
|
||||
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (journal_id, period_id),
|
||||
'name': name,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move.line',
|
||||
'view_id': view_res,
|
||||
'context': "{'journal_id': %d, 'period_id': %d}" % (journal_id, period_id),
|
||||
'type': 'ir.actions.act_window',
|
||||
'search_view_id': res['res_id']
|
||||
}
|
||||
|
||||
|
||||
_name = "account.move.journal"
|
||||
_description = "Move journal"
|
||||
|
||||
|
||||
_columns = {
|
||||
'journal_id':fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
|
||||
'period_id':fields.many2one('account.period', 'Period', required=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'period_id':_get_period
|
||||
'period_id': _get_period
|
||||
}
|
||||
|
||||
|
||||
account_move_journal()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_move_journal_form" model="ir.ui.view">
|
||||
<field name="name">account.move.journal.form</field>
|
||||
<field name="model">account.move.journal</field>
|
||||
@@ -21,6 +22,7 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_move_journal_line_form" model="ir.actions.act_window">
|
||||
<field name="name">Making Entries by Line</field>
|
||||
<field name="res_model">account.move.journal</field>
|
||||
@@ -29,5 +31,6 @@
|
||||
<field name="view_id" ref="view_account_move_journal_form"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -18,40 +18,44 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
import wizard
|
||||
|
||||
class account_move_line_reconcile_select(osv.osv_memory):
|
||||
_name = "account.move.line.reconcile.select"
|
||||
_description = "Move line reconcile select"
|
||||
_columns = {
|
||||
'account_id':fields.many2one('account.account', 'Account', domain = [('reconcile','=',1)], required=True),
|
||||
'account_id': fields.many2one('account.account', 'Account', \
|
||||
domain = [('reconcile', '=', 1)], required=True),
|
||||
}
|
||||
|
||||
|
||||
def _action_open_window(self, cr, uid, ids, context):
|
||||
"""
|
||||
This function Open account move line window for reconcile on given account id
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: account move line reconcile select’s ID or list of IDs if we want more than one
|
||||
@return:dictionary of Open account move line window for reconcile on given account id
|
||||
|
||||
@param ids: account move line reconcile select’s ID or list of IDs
|
||||
@return: dictionary of Open account move line window for reconcile on given account id
|
||||
|
||||
"""
|
||||
for data in self.read(cr, uid, ids):
|
||||
|
||||
|
||||
return {
|
||||
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'],
|
||||
'name': _('Reconciliation'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'view_id': False,
|
||||
'res_model': 'account.move.line',
|
||||
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'],
|
||||
'name': _('Reconciliation'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'view_id': False,
|
||||
'res_model': 'account.move.line',
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
account_move_line_reconcile_select()
|
||||
|
||||
account_move_line_reconcile_select()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -18,21 +18,23 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
from tools.translate import _
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
|
||||
import wizard
|
||||
|
||||
class account_period_close(osv.osv_memory):
|
||||
"""close period"""
|
||||
"""
|
||||
close period
|
||||
"""
|
||||
_name = "account.period.close"
|
||||
_description = "period close"
|
||||
_columns = {
|
||||
'sure':fields.boolean('Check this box', required=False),
|
||||
'sure': fields.boolean('Check this box', required=False),
|
||||
}
|
||||
|
||||
def _data_save(self, cr, uid, ids, context):
|
||||
@@ -40,19 +42,20 @@ class account_period_close(osv.osv_memory):
|
||||
This function close period
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id:account period close’s ID or list of IDs if we want more than one
|
||||
|
||||
|
||||
@param ids: account period close’s ID or list of IDs
|
||||
"""
|
||||
|
||||
|
||||
mode = 'done'
|
||||
for form in self.read(cr, uid, ids):
|
||||
if form['sure']:
|
||||
for id in context['active_ids']:
|
||||
cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
|
||||
cr.execute('update account_period set state=%s where id=%s', (mode, id))
|
||||
cr.execute('update account_journal_period set state=%s \
|
||||
where period_id=%s', (mode, id))
|
||||
cr.execute('update account_period set state=%s \
|
||||
where id=%s', (mode, id))
|
||||
return {}
|
||||
|
||||
account_period_close()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -218,7 +218,6 @@ def _reconcile(self, cr, uid, data, context):
|
||||
max_amount = form.get('max_amount', 0.0)
|
||||
power = form['power']
|
||||
reconciled = unreconciled = 0
|
||||
print "form",form
|
||||
if not form['account_ids'][0][2]:
|
||||
raise wizard.except_wizard(_('UserError'), _('You must select accounts to reconcile'))
|
||||
for account_id in form['account_ids'][0][2]:
|
||||
|
||||
@@ -47,7 +47,7 @@ class wiz_state_open(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','No','gtk-no'),('yes','Yes','gtk-yes')]}
|
||||
'result': {'type':'form', 'arch':form, 'fields': fields, 'state':[('end','No','gtk-no'),('yes','Yes','gtk-yes')]}
|
||||
},
|
||||
'yes': {
|
||||
'actions': [_change_inv_state],
|
||||
|
||||
Reference in New Issue
Block a user