diff --git a/addons/account/__terp__.py b/addons/account/__terp__.py
index 6faf8772a67..1fe6bd355bd 100644
--- a/addons/account/__terp__.py
+++ b/addons/account/__terp__.py
@@ -46,7 +46,17 @@ module named account_voucherss
'security/account_security.xml',
'security/ir.model.access.csv',
'account_menuitem.xml',
+ 'wizard/account_invoice_refund_view.xml',
+ 'wizard/account_period_close_view.xml',
+ 'wizard/account_fiscalyear_close_state.xml',
+ 'wizard/account_chart_view.xml',
+ 'wizard/account_move_bank_reconcile_view.xml',
+ 'wizard/account_move_line_reconcile_select_view.xml',
+ 'wizard/account_move_journal_view.xml',
'account_wizard.xml',
+ 'wizard/account_move_line_unreconcile_select_view.xml',
+ 'wizard/account_subscription_generate_view.xml',
+ 'project/wizard/project_account_analytic_line_view.xml',
'account_view.xml',
'account_end_fy.xml',
'account_invoice_view.xml',
diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml
index c74868c342c..feeb38dd51b 100644
--- a/addons/account/account_invoice_view.xml
+++ b/addons/account/account_invoice_view.xml
@@ -153,7 +153,7 @@
-
+
diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml
index 260d14e38e8..37d539a4b25 100644
--- a/addons/account/account_menuitem.xml
+++ b/addons/account/account_menuitem.xml
@@ -24,3 +24,4 @@
+
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index e43b2249ae5..88462098852 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -668,9 +668,9 @@
-
+
@@ -1007,9 +1007,9 @@
-
+
@@ -1079,8 +1079,14 @@
groups="group_account_user"/>
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
@@ -21,8 +28,9 @@
type="wizard"
sequence="1"/>
-
+
+
-
+
+
@@ -57,19 +72,24 @@
-
+
+
+
diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml
index e53047b8718..e0854f8d65d 100644
--- a/addons/account/project/project_view.xml
+++ b/addons/account/project/project_view.xml
@@ -204,10 +204,14 @@
form
-
+
-
+
+
Analytic Entries
diff --git a/addons/account/project/wizard/__init__.py b/addons/account/project/wizard/__init__.py
index 21a811ebe5f..f11fa936960 100644
--- a/addons/account/project/wizard/__init__.py
+++ b/addons/account/project/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,7 +15,7 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
@@ -25,7 +25,7 @@ import wizard_account_analytic_inverted_balance_report
import wizard_account_analytic_cost_ledger_report
import wizard_account_analytic_cost_ledger_for_journal_report
import wizard_account_analytic_analytic_check
-import wizard_account_analytic_line
+import project_account_analytic_line
import wizard_analytic_account_chart
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/project/wizard/project_account_analytic_line.py b/addons/account/project/wizard/project_account_analytic_line.py
new file mode 100644
index 00000000000..d84c199ff40
--- /dev/null
+++ b/addons/account/project/wizard/project_account_analytic_line.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+from osv import fields, osv
+from tools.translate import _
+
+class project_account_analytic_line(osv.osv_memory):
+ _name = "project.account.analytic.line"
+ _description = "Analytic Entries by line"
+ _columns = {
+ 'from_date': fields.date('From'),
+ 'to_date': fields.date('To'),
+ }
+
+ def action_open_window(self, cr, uid, ids, context={}):
+ mod_obj =self.pool.get('ir.model.data')
+ domain = []
+ for data in self.read(cr, uid, ids, context=context):
+ from_date = data['from_date']
+ to_date = data['to_date']
+ if from_date and to_date:
+ domain = [('date','>=',from_date), ('date','<=',to_date)]
+ elif from_date:
+ domain = [('date','>=',from_date)]
+ elif to_date:
+ domain = [('date','<=',to_date)]
+ result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter')
+ id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
+ return {
+ 'name': _('Analytic Entries by line'),
+ 'view_type': 'form',
+ "view_mode": 'tree,form',
+ 'res_model': 'account.analytic.line',
+ 'type': 'ir.actions.act_window',
+ 'domain': domain,
+ 'search_view_id': id['res_id'],
+ }
+
+project_account_analytic_line()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/project/wizard/project_account_analytic_line_view.xml b/addons/account/project/wizard/project_account_analytic_line_view.xml
new file mode 100644
index 00000000000..96d9186cfa8
--- /dev/null
+++ b/addons/account/project/wizard/project_account_analytic_line_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+ project.account.analytic.line.form
+ project.account.analytic.line
+ form
+
+
+
+
+
+
+ Entries By Line
+ project.account.analytic.line
+ form
+ tree,form
+
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/project/wizard/wizard_account_analytic_line.py b/addons/account/project/wizard/wizard_account_analytic_line.py
deleted file mode 100644
index 4d63aff05f5..00000000000
--- a/addons/account/project/wizard/wizard_account_analytic_line.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import time
-from tools.translate import _
-
-def _action_open_window(self, cr, uid, data, context):
- domain = []
- from_date = data['form']['from_date']
- to_date = data['form']['to_date']
- if from_date and to_date:
- domain = [('date','>=',from_date),('date','<=',to_date)]
- elif from_date:
- domain = [('date','>=',from_date)]
- elif to_date:
- domain = [('date','<=',to_date)]
- mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter')
- id = mod_obj.read(cr, uid, result, ['res_id'])
-
- return {
- 'name': _('Analytic Entries by line'),
- 'view_type': 'form',
- "view_mode": 'tree,form',
- 'res_model': 'account.analytic.line',
- 'type': 'ir.actions.act_window',
- 'domain': domain,
- 'search_view_id': id['res_id'],}
-
-
-class account_analytic_line(wizard.interface):
- form1 = '''
- '''
- form1_fields = {
- 'from_date': {
- 'string': 'From',
- 'type': 'date',
- },
- 'to_date': {
- 'string': 'To',
- 'type': 'date',
- },
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Entries','gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-account_analytic_line('account.analytic.line')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py
index 7d6e7b1226d..f3a05ebe184 100644
--- a/addons/account/wizard/__init__.py
+++ b/addons/account/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,40 +15,36 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
import wizard_automatic_reconcile
-import wizard_reconcile_select
-import wizard_unreconcile_select
+import account_move_line_reconcile_select
+import account_move_line_unreconcile_select
import wizard_reconcile
import wizard_unreconcile
-import wizard_refund
+import account_invoice_refund
import wizard_pay_invoice
-
-import wizard_journal
+import account_move_journal
import wizard_journal_select
-import wizard_bank_reconcile
-import wizard_subscription_generate
-
+import account_move_bank_reconcile
+import account_subscription_generate
import wizard_aged_trial_balance
import wizard_general_ledger_report
import wizard_third_party_ledger
import wizard_account_balance_report
import wizard_partner_balance_report
-
-import wizard_period_close
+import account_period_close
import wizard_fiscalyear_close
-import wizard_fiscalyear_close_state
+import account_fiscalyear_close_state
import wizard_open_closed_fiscalyear
import wizard_vat
import wizard_compare_account_balance_report
-
import wizard_invoice_state
import wizard_account_duplicate
-import wizard_account_chart
+import account_chart
import wizard_move_line_select
import wizard_validate_account_move
@@ -64,5 +60,4 @@ import wizard_change_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py
new file mode 100644
index 00000000000..7def37807c3
--- /dev/null
+++ b/addons/account/wizard/account_chart.py
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+
+class account_chart(osv.osv_memory):
+ """
+ For Chart of Accounrs
+ """
+ _name = "account.chart"
+ _description = "chart"
+ _columns = {
+ 'fiscalyear': fields.many2one('account.fiscalyear', \
+ 'Fiscal year', \
+ help = 'Keep empty for all open fiscal years'),
+ 'target_move': fields.selection([
+ ('all', 'All Entries'),
+ ('posted', 'All Posted Entries'),
+ ], 'Target Moves', required = True),
+
+ }
+ def _get_defaults(self, cr, uid, context={}):
+ """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 ids: List of account chart’s IDs
+ @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ for data in self.read(cr, uid, ids,context=context):
+ result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
+ id = mod_obj.read(cr, uid, [result], ['res_id'],context=context)[0]['res_id']
+ result = act_obj.read(cr, uid, [id], context=context)[0]
+ 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']],context=context)[0]['code']
+ return result
+
+
+ _defaults = {
+ 'fiscalyear': _get_defaults,
+ 'target_move': lambda * a: 'all'
+ }
+account_chart()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_chart_view.xml b/addons/account/wizard/account_chart_view.xml
new file mode 100644
index 00000000000..66da81d24f6
--- /dev/null
+++ b/addons/account/wizard/account_chart_view.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+ account.chart.form
+ account.chart
+ form
+
+
+
+
+
+
+ Chart of Accounts
+ account.chart
+ form
+ tree,form
+
+ new
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_fiscalyear_close_state.py b/addons/account/wizard/account_fiscalyear_close_state.py
new file mode 100644
index 00000000000..eeb202a0c82
--- /dev/null
+++ b/addons/account/wizard/account_fiscalyear_close_state.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+
+class account_fiscalyear_close_state(osv.osv_memory):
+ """
+ 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)
+ }
+
+ def data_save(self, cr, uid, ids, context={}):
+ """
+ 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 ids: List of Account fiscalyear close state’s IDs
+
+ """
+ for data in self.read(cr, uid, ids,context=context):
+ 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))
+ cr.execute('UPDATE account_period SET state = %s ' \
+ '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:
diff --git a/addons/account/wizard/account_fiscalyear_close_state.xml b/addons/account/wizard/account_fiscalyear_close_state.xml
new file mode 100644
index 00000000000..370aacbf2e3
--- /dev/null
+++ b/addons/account/wizard/account_fiscalyear_close_state.xml
@@ -0,0 +1,39 @@
+
+
+
+
+ account.fiscalyear.close.state.form
+ account.fiscalyear.close.state
+ form
+
+
+
+
+
+
+ Close a Fiscal Year
+ account.fiscalyear.close.state
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py
new file mode 100644
index 00000000000..cc69311b2f7
--- /dev/null
+++ b/addons/account/wizard/account_invoice_refund.py
@@ -0,0 +1,191 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+import netsvc
+
+
+class account_invoice_refund(osv.osv_memory):
+
+ """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),
+ }
+
+ 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 ids: the account invoice refund’s ID or list of IDs
+
+ """
+ inv_obj = self.pool.get('account.invoice')
+ reconcile_obj = self.pool.get('account.move.reconcile')
+ account_m_line_obj = self.pool.get('account.move.line')
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ for form in self.read(cr, uid, ids,context=context):
+ created_inv = []
+ date = False
+ period = False
+ description = False
+ for inv in inv_obj.browse(cr, uid, context['active_ids'],context=context):
+ if inv.state in ['draft', 'proforma2', 'cancel']:
+ raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
+ if form['period'] :
+ period = form['period']
+ else:
+ period = inv.period_id and inv.period_id.id or False
+
+ 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'")
+ result_query = cr.fetchone()
+ if result_query:
+ 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,context=context).company_id.id,))
+ else:
+ cr.execute("""SELECT id
+ from account_period where date('%s')
+ between date_start AND date_stop \
+ limit 1 """, (form['date'],))
+ res = cr.fetchone()
+ if res:
+ period = res[0]
+ else:
+ date = inv.date_invoice
+
+ if form['description'] :
+ description = form['description']
+ else:
+ description = inv.name
+
+ if not period:
+ raise osv.except_osv(_('Data Insufficient !'), \
+ _('No Period found on Invoice!'))
+
+ refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description)
+ refund = inv_obj.browse(cr, uid, refund_id[0],context=context)
+ inv_obj.write(cr, uid, [refund.id], {'date_due': date,
+ 'check_total': inv.check_total})
+ inv_obj.button_compute(cr, uid, refund_id)
+
+ created_inv.append(refund_id[0])
+ if mode in ('cancel', 'modify'):
+ movelines = inv.move_id.line_id
+ to_reconcile_ids = {}
+ for line in movelines :
+ if line.account_id.id == inv.account_id.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)
+ wf_service = netsvc.LocalService('workflow')
+ wf_service.trg_validate(uid, 'account.invoice', \
+ refund.id, 'invoice_open', cr)
+ refund = inv_obj.browse(cr, uid, refund_id[0],context=context)
+ 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,
+ writeoff_acc_id=inv.account_id.id
+ )
+ if mode == 'modify' :
+ 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'],context=context)
+ invoice = invoice[0]
+ del invoice['id']
+ invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'],context=context)
+ 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'],context=context)
+ 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
+ })
+
+ 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]
+
+ inv_id = inv_obj.create(cr, uid, invoice, {})
+ if inv.payment_term.id:
+ data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], inv.payment_term.id, date)
+ if 'value' in data and data['value']:
+ inv_obj.write(cr, uid, [inv_id], data['value'])
+ created_inv.append(inv_id)
+
+ if inv.type == 'out_invoice':
+ xml_id = 'action_invoice_tree1'
+ elif inv.type == 'in_invoice':
+ xml_id = 'action_invoice_tree2'
+ elif type == 'out_refund':
+ xml_id = 'action_invoice_tree3'
+ else:
+ xml_id = 'action_invoice_tree4'
+ result = mod_obj._get_id(cr, uid, 'account', xml_id)
+ id = mod_obj.read(cr, uid, result, ['res_id'],context=context)['res_id']
+ result = act_obj.read(cr, uid, id,context=context)
+ result['res_id'] = created_inv
+
+ return result
+
+ def invoice_refund(self, cr, uid, ids, context={}):
+ return self.compute_refund(cr, uid, ids, 'refund', context=context)
+
+ def invoice_cancel(self, cr, uid, ids, context={}):
+ return self.compute_refund(cr, uid, ids, 'cancel', context=context)
+
+ def invoice_modify(self, cr, uid, ids, context={}):
+ return self.compute_refund(cr, uid, ids, 'modify', context=context)
+
+account_invoice_refund()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_invoice_refund_view.xml b/addons/account/wizard/account_invoice_refund_view.xml
new file mode 100644
index 00000000000..7962bb150cf
--- /dev/null
+++ b/addons/account/wizard/account_invoice_refund_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ account.invoice.refund.form
+ account.invoice.refund
+ form
+
+
+
+
+
+
+ Credit Note
+ account.invoice.refund
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_move_bank_reconcile.py b/addons/account/wizard/account_move_bank_reconcile.py
new file mode 100644
index 00000000000..e2329bf09d9
--- /dev/null
+++ b/addons/account/wizard/account_move_bank_reconcile.py
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+import tools
+from osv import fields, osv
+from tools.translate import _
+
+
+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),
+ }
+
+ 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 ids: account move bank reconcile’s ID or list of IDs
+ @return: dictionary of Open account move line on given journal_id.
+ """
+ for data in self.read(cr, uid, ids,context=context):
+ 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.'))
+ return {
+ '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()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_move_bank_reconcile_view.xml b/addons/account/wizard/account_move_bank_reconcile_view.xml
new file mode 100644
index 00000000000..89342803aaf
--- /dev/null
+++ b/addons/account/wizard/account_move_bank_reconcile_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ account.move.bank.reconcile.form
+ account.move.bank.reconcile
+ form
+
+
+
+
+
+
+ Bank reconciliation
+ account.move.bank.reconcile
+ form
+ tree,form
+
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py
new file mode 100644
index 00000000000..df6e41da566
--- /dev/null
+++ b/addons/account/wizard/account_move_journal.py
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+
+class account_move_journal(osv.osv_memory):
+ _name = "account.move.journal"
+ _description = "Move journal"
+
+ _columns = {
+ 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
+ 'period_id': fields.many2one('account.period', 'Period', required=True),
+ }
+
+
+ def _get_period(self, cr, uid, context={}):
+ """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 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
+
+ """
+ jp = self.pool.get('account.journal.period')
+ mod_obj = self.pool.get('ir.model.data')
+ for data in self.read(cr, uid, ids, ['journal_id', 'period_id'],context=context):
+ 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']
+
+ ids = jp.search(cr, uid, [('journal_id', '=', journal_id), \
+ ('period_id', '=', period_id)],context=context)
+
+ if not len(ids):
+ 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, [period_id])[0]['company_id'][0]
+ jp.create(cr, uid, {'name': name, 'period_id': period_id, 'journal_id': journal_id, 'company_id': company},context=context)
+
+ ids = jp.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)],context=context)
+ jp = jp.browse(cr, uid, ids, context=context)[0]
+ name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
+
+ result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
+ res = mod_obj.read(cr, uid, result, ['res_id'],context=context)
+
+ return {
+ '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']
+ }
+
+
+ _defaults = {
+ 'period_id': _get_period
+ }
+
+account_move_journal()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_move_journal_view.xml b/addons/account/wizard/account_move_journal_view.xml
new file mode 100644
index 00000000000..7a25932bb98
--- /dev/null
+++ b/addons/account/wizard/account_move_journal_view.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+ account.move.journal.form
+ account.move.journal
+ form
+
+
+
+
+
+
+ Entries by Line
+ account.move.journal
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_move_line_reconcile_select.py b/addons/account/wizard/account_move_line_reconcile_select.py
new file mode 100644
index 00000000000..db0ddb10108
--- /dev/null
+++ b/addons/account/wizard/account_move_line_reconcile_select.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+
+
+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),
+ }
+
+ 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 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,context=context):
+
+ 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',
+ 'type': 'ir.actions.act_window'
+ }
+
+account_move_line_reconcile_select()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_move_line_reconcile_select_view.xml b/addons/account/wizard/account_move_line_reconcile_select_view.xml
new file mode 100644
index 00000000000..f7fcccddc4c
--- /dev/null
+++ b/addons/account/wizard/account_move_line_reconcile_select_view.xml
@@ -0,0 +1,41 @@
+
+
+
+
+ account.move.line.reconcile.select.form
+ account.move.line.reconcile.select
+ form
+
+
+
+
+
+
+ Reconcile entries
+ account.move.line.reconcile.select
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_move_line_unreconcile_select.py b/addons/account/wizard/account_move_line_unreconcile_select.py
new file mode 100644
index 00000000000..07fd0017742
--- /dev/null
+++ b/addons/account/wizard/account_move_line_unreconcile_select.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+
+
+class account_move_line_unreconcile_select(osv.osv_memory):
+
+ _name = "account.move.line.unreconcile.select"
+ _description = "Unreconciliation"
+ _columns ={
+ 'account_id': fields.many2one('account.account','Account',required=True),
+
+ }
+
+ def action_open_window(self, cr, uid, ids, context={}):
+ for data in self.read(cr, uid, ids):
+ return {
+ 'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['account_id'],
+ 'name': 'Unreconciliation',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'view_id': False,
+ 'res_model': 'account.move.line',
+ 'type': 'ir.actions.act_window'
+ }
+
+account_move_line_unreconcile_select()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/account/wizard/account_move_line_unreconcile_select_view.xml b/addons/account/wizard/account_move_line_unreconcile_select_view.xml
new file mode 100644
index 00000000000..06c0a0d1e0e
--- /dev/null
+++ b/addons/account/wizard/account_move_line_unreconcile_select_view.xml
@@ -0,0 +1,38 @@
+
+
+
+
+ account.move.line.unreconcile.select.form
+ account.move.line.unreconcile.select
+ form
+
+
+
+
+
+
+ Unreconcile entries
+ account.move.line.unreconcile.select
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py
new file mode 100644
index 00000000000..f4c54263f9a
--- /dev/null
+++ b/addons/account/wizard/account_period_close.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+import tools
+
+class account_period_close(osv.osv_memory):
+ """
+ close period
+ """
+ _name = "account.period.close"
+ _description = "period close"
+ _columns = {
+ 'sure': fields.boolean('Check this box', required=False),
+ }
+
+ def data_save(self, cr, uid, ids, context={}):
+ """
+ This function close period
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: account period close’s ID or list of IDs
+ """
+
+ mode = 'done'
+ for form in self.read(cr, uid, ids,context=context):
+ 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))
+ return {}
+
+account_period_close()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_period_close_view.xml b/addons/account/wizard/account_period_close_view.xml
new file mode 100644
index 00000000000..0866e64bdb6
--- /dev/null
+++ b/addons/account/wizard/account_period_close_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ account.period.close.form
+ account.period.close
+ form
+
+
+
+
+
+
+ Close a Period
+ account.period.close
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
+ client_action_multi
+
+ action
+ account.period
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_subscription_generate.py b/addons/account/wizard/account_subscription_generate.py
new file mode 100644
index 00000000000..8d2727478ae
--- /dev/null
+++ b/addons/account/wizard/account_subscription_generate.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+import time
+
+from osv import fields, osv
+
+class account_subscription_generate(osv.osv_memory):
+
+ _name = "account.subscription.generate"
+ _description = "Subscription Compute"
+ _columns = {
+ 'date': fields.date('Date', required=True),
+ }
+ _defaults = {
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ }
+ def action_generate(self, cr, uid, ids, context={}):
+ for data in self.read(cr, uid, ids, context=context):
+ cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],))
+ ids = map(lambda x: x[0], cr.fetchall())
+ self.pool.get('account.subscription.line').move_create(cr, uid, ids, context=context)
+ return {}
+
+account_subscription_generate()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_subscription_generate_view.xml b/addons/account/wizard/account_subscription_generate_view.xml
new file mode 100644
index 00000000000..252865f322e
--- /dev/null
+++ b/addons/account/wizard/account_subscription_generate_view.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ account.subscription.generate.form
+ account.subscription.generate
+ form
+
+
+
+
+
+
+ Create Subscription Entries
+ account.subscription.generate
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
diff --git a/addons/account/wizard/wizard_account_chart.py b/addons/account/wizard/wizard_account_chart.py
deleted file mode 100644
index ae6b29b0f43..00000000000
--- a/addons/account/wizard/wizard_account_chart.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-
-class wizard_account_chart(wizard.interface):
- _account_chart_arch = '''
- '''
-
- _account_chart_fields = {
- 'fiscalyear': {
- 'string': 'Fiscal year',
- 'type': 'many2one',
- 'relation': 'account.fiscalyear',
- 'help': 'Keep empty for all open fiscal years',
- },
- 'target_move': {
- 'string': 'Target Moves',
- 'type': 'selection',
- 'selection': [('all','All Entries'),('posted','All Posted Entries')],
- 'required': True,
- 'default': lambda *a:"all",
- },
- }
-
- def _get_defaults(self, cr, uid, data, context):
- fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
- data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
- return data['form']
-
-
- def _account_chart_open_window(self, cr, uid, data, context):
- mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
- act_obj = pooler.get_pool(cr.dbname).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': data['form']['fiscalyear'],'state':data['form']['target_move']})
- if data['form']['fiscalyear']:
- result['name']+=':'+pooler.get_pool(cr.dbname).get('account.fiscalyear').read(cr,uid,[data['form']['fiscalyear']])[0]['code']
- return result
-
- states = {
- 'init': {
- 'actions': [_get_defaults],
- 'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('open', 'Open', 'gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
- }
- }
-wizard_account_chart('account.chart')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_bank_reconcile.py b/addons/account/wizard/wizard_bank_reconcile.py
deleted file mode 100644
index 8770af7c535..00000000000
--- a/addons/account/wizard/wizard_bank_reconcile.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-from tools.translate import _
-
-_journal_form = '''
-''' % ('Open Bank reconciliation',)
-
-_journal_fields = {
- 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
-}
-
-def _action_open_window(self, cr, uid, data, context):
- form = data['form']
- cr.execute('select default_credit_account_id from account_journal where id=%s', (form['journal_id'],))
- account_id = cr.fetchone()[0]
- if not account_id:
- raise wizard.except_wizard(_('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'],),
- 'type': 'ir.actions.act_window'
- }
-
-class wiz_journal(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('open','Open', 'gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-wiz_journal('account.move.bank.reconcile')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_fiscalyear_close_state.py b/addons/account/wizard/wizard_fiscalyear_close_state.py
deleted file mode 100644
index 5d876f9b0a3..00000000000
--- a/addons/account/wizard/wizard_fiscalyear_close_state.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import osv
-import pooler
-from tools.translate import _
-
-_transaction_form = '''
-'''
-
-_transaction_fields = {
- 'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
- 'sure': {'string':'Check this box', 'type':'boolean'},
-}
-
-def _data_save(self, cr, uid, data, context):
- if not data['form']['sure']:
- raise wizard.except_wizard(_('UserError'), _('Closing of states cancelled, please check the box !'))
- pool = pooler.get_pool(cr.dbname)
-
- fy_id = data['form']['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))
- cr.execute('UPDATE account_period SET state = %s ' \
- 'WHERE fiscalyear_id = %s', ('done',fy_id))
- cr.execute('UPDATE account_fiscalyear ' \
- 'SET state = %s WHERE id = %s', ('done', fy_id))
- return {}
-
-class wiz_journal_close_state(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel', 'gtk-cancel'),('close','Close states', 'gtk-ok')]}
- },
- 'close': {
- 'actions': [_data_save],
- 'result': {'type': 'state', 'state':'end'}
- }
- }
-wiz_journal_close_state('account.fiscalyear.close.state')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_journal.py b/addons/account/wizard/wizard_journal.py
deleted file mode 100644
index 093c22f10e8..00000000000
--- a/addons/account/wizard/wizard_journal.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-from osv import osv
-import pooler
-from tools.translate import _
-
-_journal_form = '''
-'''
-
-def _period_get(self, cr, uid, datas, ctx={}):
- try:
- pool = pooler.get_pool(cr.dbname)
- ids = pool.get('account.period').find(cr, uid, context=ctx)
- return {'period_id': ids[0]}
- except:
- return {}
-
-_journal_fields = {
- 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
- 'period_id': {
- 'string':'Period',
- 'type':'many2one',
- 'relation':'account.period',
- 'required':True,
- }
-}
-
-def _action_open_window(self, cr, uid, data, context):
- form = data['form']
- cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
- view_res = cr.fetchone()
- jp = pooler.get_pool(cr.dbname).get('account.journal.period')
- ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
- if not len(ids):
- name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
- state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state']
- if state == 'done':
- raise wizard.except_wizard(_('UserError'), _('This period is already closed !'))
- company = pooler.get_pool(cr.dbname).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'])])
- jp = jp.browse(cr, uid, ids, context=context)[0]
- name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
-
- mod_obj = pooler.get_pool(cr.dbname).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'])
- 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']
- }
-
-class wiz_journal(wizard.interface):
- states = {
- 'init': {
- 'actions': [_period_get],
- 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('open','Open Journal', 'gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-wiz_journal('account.move.journal')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_reconcile_select.py b/addons/account/wizard/wizard_reconcile_select.py
deleted file mode 100644
index 594020debd4..00000000000
--- a/addons/account/wizard/wizard_reconcile_select.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-from tools.translate import _
-
-
-_journal_form = '''
-''' % ('Reconciliation',)
-
-_journal_fields = {
- 'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account','domain': [('reconcile','=',1)], 'required':True},
-}
-
-def _action_open_window(self, cr, uid, data, context):
- return {
- 'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['form']['account_id'],
- 'name': _('Reconciliation'),
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'view_id': False,
- 'res_model': 'account.move.line',
- 'type': 'ir.actions.act_window'
- }
-
-class wiz_rec_select(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for reconciliation')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-wiz_rec_select('account.move.line.reconcile.select')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py
deleted file mode 100644
index 42526f3cc0a..00000000000
--- a/addons/account/wizard/wizard_refund.py
+++ /dev/null
@@ -1,226 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import osv
-import netsvc
-import time
-from tools.translate import _
-
-sur_form = '''
-'''
-
-sur_fields = {
- 'date': {'string':'Operation date','type':'date', 'required':'False'},
- 'period':{'string': 'Force period', 'type': 'many2one',
- 'relation': 'account.period', 'required': False},
- 'description':{'string':'Description', 'type':'char', 'required':'True'},
- }
-
-
-class wiz_refund(wizard.interface):
-
- def _invoice_refund(self, cr, uid, data, context):
- return self._compute_refund(cr, uid, data, 'refund', context)
-
- def _invoice_cancel(self, cr, uid, data, context):
- return self._compute_refund(cr, uid, data, 'cancel', context)
-
- def _invoice_modify(self, cr, uid, data, context):
- return self._compute_refund(cr, uid, data, 'modify', context)
-
- def _compute_refund(self, cr, uid, data, mode, context):
- form = data['form']
- pool = pooler.get_pool(cr.dbname)
- reconcile_obj = pool.get('account.move.reconcile')
- account_m_line_obj = pool.get('account.move.line')
- created_inv = []
- date = False
- period = False
- description = False
- for inv in pool.get('account.invoice').browse(cr, uid, data['ids']):
- if inv.state in ['draft', 'proforma2', 'cancel']:
- raise wizard.except_wizard(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
- if form['period'] :
- period = form['period']
- else:
- period = inv.period_id and inv.period_id.id or False
-
- 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'")
- 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'],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'],))
- res = cr.fetchone()
- if res:
- period = res[0]
- else:
- date = inv.date_invoice
-
- if form['description'] :
- description = form['description']
- else:
- description = inv.name
-
- if not period:
- raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
-
- refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
- refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
- # we compute due date
- #!!!due date = date inv date on formdate
- pool.get('account.invoice').write(cr, uid, [refund.id],{'date_due':date,'check_total':inv.check_total})
- # to make the taxes calculated
- pool.get('account.invoice').button_compute(cr, uid, refund_id)
-
- created_inv.append(refund_id[0])
- #if inv is paid we unreconcile
- if mode in ('cancel','modify'):
- movelines = inv.move_id.line_id
- #we unreconcile the lines
- to_reconcile_ids = {}
- for line in movelines :
- #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]
- if type(line.reconcile_id) != osv.orm.browse_null :
- 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)
- #we reload the browse record
- refund = pool.get('account.invoice').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,
- writeoff_acc_id=inv.account_id.id
- )
- #we create a new invoice that is the copy of the original
- if mode == 'modify' :
- invoice = 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 = invoice[0]
- del invoice['id']
- invoice_lines = pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'])
- invoice_lines = pool.get('account.invoice')._refund_cleanup_lines(cr, uid, invoice_lines)
- tax_lines = pool.get('account.invoice.tax').read(
- cr, uid, invoice['tax_line'])
- tax_lines = pool.get('account.invoice')._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
- })
-
- #take the id part of the tuple returned for many2one fields
- 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 = pool.get('account.invoice').create(cr, uid, invoice,{})
- # we compute due date
- if inv.payment_term.id:
- data = pool.get('account.invoice').onchange_payment_term_date_invoice(cr, uid, [inv_id],inv.payment_term.id,date)
- if 'value' in data and data['value']:
- pool.get('account.invoice').write(cr, uid, [inv_id],data['value'])
- created_inv.append(inv_id)
-
- #we get the view id
- mod_obj = pool.get('ir.model.data')
- act_obj = pool.get('ir.actions.act_window')
- if inv.type == 'out_invoice':
- xml_id = 'action_invoice_tree5'
- elif inv.type == 'in_invoice':
- xml_id = 'action_invoice_tree8'
- elif type == 'out_refund':
- xml_id = 'action_invoice_tree10'
- else:
- xml_id = 'action_invoice_tree12'
- #we get the model
- result = mod_obj._get_id(cr, uid, 'account', xml_id)
- id = mod_obj.read(cr, uid, result, ['res_id'])['res_id']
- # we read the act window
- result = act_obj.read(cr, uid, id)
- result['res_id'] = created_inv
-
- return result
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'form', 'arch':sur_form, 'fields':sur_fields, 'state':[('end','Cancel'),('refund','Refund Invoice'),('cancel_invoice','Cancel Invoice'),('modify_invoice','Modify Invoice')]}
- },
- 'refund': {
- 'actions': [],
- 'result': {'type':'action', 'action':_invoice_refund, 'state':'end'},
- },
- 'cancel_invoice': {
- 'actions': [],
- 'result': {'type':'action', 'action':_invoice_cancel, 'state':'end'},
- },
- 'modify_invoice': {
- 'actions': [],
- 'result': {'type':'action', 'action':_invoice_modify, 'state':'end'},
- },
-
- }
-wiz_refund('account.invoice.refund')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_subscription_generate.py b/addons/account/wizard/wizard_subscription_generate.py
deleted file mode 100644
index 1df25b219cd..00000000000
--- a/addons/account/wizard/wizard_subscription_generate.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import time
-import wizard
-import pooler
-
-#
-# TODO: add an intermediate screen for checks
-#
-
-_subscription_form = '''
-''' % ('Subscription Compute',)
-
-_subscription_fields = {
- 'date': {'string':'Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
-}
-
-class wiz_subscription(wizard.interface):
- def _action_generate(self, cr, uid, data, context={}):
- cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['form']['date'],))
- ids = map(lambda x: x[0], cr.fetchall())
- pooler.get_pool(cr.dbname).get('account.subscription.line').move_create(cr, uid, ids)
- return {}
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_subscription_form, 'fields':_subscription_fields, 'state':[('end','Cancel', 'gtk-cancel'),('generate','Compute', 'gtk-ok')]}
- },
- 'generate': {
- 'actions': [_action_generate],
- 'result': {'type': 'state', 'state':'end'}
- }
- }
-wiz_subscription('account.subscription.generate')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_unreconcile_select.py b/addons/account/wizard/wizard_unreconcile_select.py
deleted file mode 100644
index 998be07a5f2..00000000000
--- a/addons/account/wizard/wizard_unreconcile_select.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-
-_journal_form = '''
-''' % ('Unreconciliation',)
-
-_journal_fields = {
- 'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
-}
-
-def _action_open_window(self, cr, uid, data, context):
- return {
- 'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['form']['account_id'],
- 'name': 'Unreconciliation',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'view_id': False,
- 'res_model': 'account.move.line',
- 'type': 'ir.actions.act_window'
- }
-
-class wiz_unrec_select(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('open','Open for unreconciliation', 'gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-wiz_unrec_select('account.move.line.unreconcile.select')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/audittrail/__terp__.py b/addons/audittrail/__terp__.py
index d8b573a704a..7ec81b4eb7e 100644
--- a/addons/audittrail/__terp__.py
+++ b/addons/audittrail/__terp__.py
@@ -37,6 +37,7 @@
'depends': ['base'],
'init_xml': [],
'update_xml': [
+ 'wizard/audittrail_view_log_view.xml',
'audittrail_view.xml',
'security/ir.model.access.csv',
'security/audittrail_security.xml'
diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py
index 22ddcafd7f9..80166298edb 100644
--- a/addons/audittrail/audittrail.py
+++ b/addons/audittrail/audittrail.py
@@ -19,35 +19,39 @@
#
##############################################################################
-
from osv import fields, osv
from osv.osv import osv_pool
from tools.translate import _
import ir
-import netsvc
import pooler
-import string
-import time, copy
+import time
class audittrail_rule(osv.osv):
+ """
+ For Auddittrail Rule
+ """
_name = 'audittrail.rule'
+ _description = "Audittrail Rule"
_columns = {
- "name": fields.char("Rule Name", size=32, required=True),
- "object_id": fields.many2one('ir.model', 'Object', required=True),
- "user_id": fields.many2many('res.users', 'audittail_rules_users', 'user_id', 'rule_id', 'Users'),
- "log_read": fields.boolean("Log reads"),
- "log_write": fields.boolean("Log writes"),
- "log_unlink": fields.boolean("Log deletes"),
- "log_create": fields.boolean("Log creates"),
- "state": fields.selection((("draft", "Draft"), ("subscribed", "Subscribed")), "State", required=True),
- "action_id":fields.many2one('ir.actions.act_window', "Action ID"),
+ "name": fields.char("Rule Name", size=32, required=True),
+ "object_id": fields.many2one('ir.model', 'Object', required=True),
+ "user_id": fields.many2many('res.users', 'audittail_rules_users',
+ 'user_id', 'rule_id', 'Users'),
+ "log_read": fields.boolean("Log reads"),
+ "log_write": fields.boolean("Log writes"),
+ "log_unlink": fields.boolean("Log deletes"),
+ "log_create": fields.boolean("Log creates"),
+ "state": fields.selection((("draft", "Draft"),
+ ("subscribed", "Subscribed")),
+ "State", required=True),
+ "action_id": fields.many2one('ir.actions.act_window', "Action ID"),
}
_defaults = {
- 'state': lambda *a: 'draft',
- 'log_create': lambda *a: 1,
- 'log_unlink': lambda *a: 1,
- 'log_write': lambda *a: 1,
+ 'state': lambda *a: 'draft',
+ 'log_create': lambda *a: 1,
+ 'log_unlink': lambda *a: 1,
+ 'log_write': lambda *a: 1,
}
_sql_constraints = [
@@ -56,59 +60,86 @@ class audittrail_rule(osv.osv):
__functions = {}
def subscribe(self, cr, uid, ids, *args):
+ """
+ Subscribe Rule for auditing changes on object and apply shortcut for logs on that object.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Auddittrail Rule’s IDs.
+ @return: True
+ """
+ obj_action = self.pool.get('ir.actions.act_window')
+ obj_model = self.pool.get('ir.model.data')
+ #start Loop
for thisrule in self.browse(cr, uid, ids):
obj = self.pool.get(thisrule.object_id.model)
if not obj:
raise osv.except_osv(
- _('WARNING:audittrail is not part of the pool'),
+ _('WARNING: audittrail is not part of the pool'),
_('Change audittrail depends -- Setting rule as DRAFT'))
self.write(cr, uid, [thisrule.id], {"state": "draft"})
- val={
- "name":'View Log',
- "res_model":'audittrail.log',
- "src_model":thisrule.object_id.model,
- "domain":"[('object_id','=',"+str(thisrule.object_id.id)+"),('res_id', '=', active_id)]"
+ val = {
+ "name": 'View Log',
+ "res_model": 'audittrail.log',
+ "src_model": thisrule.object_id.model,
+ "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
}
- id=self.pool.get('ir.actions.act_window').create(cr, uid, val)
- self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id":id})
+ id = obj_action.create(cr, uid, val)
+ self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": id})
keyword = 'client_action_relate'
- value = 'ir.actions.act_window,'+str(id)
- res=self.pool.get('ir.model.data').ir_set(cr, uid, 'action', keyword, 'View_log_'+thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
+ value = 'ir.actions.act_window,' + str(id)
+ res = obj_model.ir_set(cr, uid, 'action', keyword, 'View_log_' + thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
+ #End Loop
return True
-
-
def unsubscribe(self, cr, uid, ids, *args):
+ """
+ Unsubscribe Auditing Rule on object
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Auddittrail Rule’s IDs.
+ @return: True
+ """
+ obj_action = self.pool.get('ir.actions.act_window')
+ val_obj = self.pool.get('ir.values')
+ #start Loop
for thisrule in self.browse(cr, uid, ids):
- if thisrule.id in self.__functions :
+ if thisrule.id in self.__functions:
for function in self.__functions[thisrule.id]:
setattr(function[0], function[1], function[2])
- w_id=self.pool.get('ir.actions.act_window').search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)])
- self.pool.get('ir.actions.act_window').unlink(cr, uid, w_id)
- val_obj=self.pool.get('ir.values')
- value="ir.actions.act_window"+','+str(w_id[0])
- val_id=val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)])
+ w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)])
+ obj_action.unlink(cr, uid, w_id)
+ value = "ir.actions.act_window" + ',' + str(w_id[0])
+ val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)])
if val_id:
res = ir.ir_del(cr, uid, val_id[0])
self.write(cr, uid, [thisrule.id], {"state": "draft"})
+ #End Loop
return True
audittrail_rule()
class audittrail_log(osv.osv):
+ """
+ For Audittrail Log
+ """
_name = 'audittrail.log'
+ _description = "Audittrail Log"
_columns = {
- "name": fields.char("Name", size=32),
- "object_id": fields.many2one('ir.model', 'Object'),
- "user_id": fields.many2one('res.users', 'User'),
- "method": fields.selection((('read', 'Read'), ('write', 'Write'), ('unlink', 'Delete'), ('create', 'Create')), "Method"),
- "timestamp": fields.datetime("Date"),
- "res_id":fields.integer('Resource Id'),
- "line_ids":fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
+ "name": fields.char("Name", size=32),
+ "object_id": fields.many2one('ir.model', 'Object'),
+ "user_id": fields.many2one('res.users', 'User'),
+ "method": fields.selection((('read', 'Read'),
+ ('write', 'Write'),
+ ('unlink', 'Delete'),
+ ('create', 'Create')), "Method"),
+ "timestamp": fields.datetime("Date"),
+ "res_id": fields.integer('Resource Id'),
+ "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
}
+
_defaults = {
"timestamp": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S")
}
@@ -116,235 +147,293 @@ class audittrail_log(osv.osv):
audittrail_log()
+
class audittrail_log_line(osv.osv):
- _name='audittrail.log.line'
- _columns={
- 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
- 'log_id':fields.many2one('audittrail.log', 'Log'),
- 'log':fields.integer("Log ID"),
- 'old_value':fields.text("Old Value"),
- 'new_value':fields.text("New Value"),
- 'old_value_text':fields.text('Old value Text'),
- 'new_value_text':fields.text('New value Text'),
- 'field_description':fields.char('Field Description' , size=64),
- }
+ """
+ Audittrail Log Line.
+ """
+ _name = 'audittrail.log.line'
+ _description = "Log Line"
+ _columns = {
+ 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
+ 'log_id': fields.many2one('audittrail.log', 'Log'),
+ 'log': fields.integer("Log ID"),
+ 'old_value': fields.text("Old Value"),
+ 'new_value': fields.text("New Value"),
+ 'old_value_text': fields.text('Old value Text'),
+ 'new_value_text': fields.text('New value Text'),
+ 'field_description': fields.char('Field Description', size=64),
+ }
audittrail_log_line()
+
class audittrail_objects_proxy(osv_pool):
- def get_value_text(self, cr, uid, field_name, values, object, context={}):
- pool = pooler.get_pool(cr.dbname)
- obj=pool.get(object.model)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object.model)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
- if f_id:
- field=pool.get('ir.model.fields').read(cr, uid, f_id)[0]
- model=field['relation']
+ """ Uses Object proxy for auditing changes on object of subscribed Rules"""
+
+ def get_value_text(self, cr, uid, field_name, values, object, context=None):
+ """
+ Gets textual values for the fields
+ e.g.: For field of type many2one it gives its name value instead of id
- if field['ttype']=='many2one':
- if values:
- if type(values)==tuple:
- values=values[0]
- val=pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
- if len(val):
- return val[0][pool.get(model)._rec_name]
- elif field['ttype'] == 'many2many':
- value=[]
- if values:
- for id in values:
- val=pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
- if len(val):
- value.append(val[0][pool.get(model)._rec_name])
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param field_name: List of fields for text values
+ @param values: Values for field to be converted into textual values
+ @return: values: List of textual values for given fields
+ """
+ if not context:
+ context = {}
+ pool = pooler.get_pool(cr.dbname)
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
+ if f_id:
+ field = pool.get('ir.model.fields').read(cr, uid, f_id)[0]
+ model = field['relation']
+
+ if field['ttype'] == 'many2one':
+ if values:
+ if type(values) == tuple:
+ values = values[0]
+ val = pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
+ if val:
+ return val[0][pool.get(model)._rec_name]
+ elif field['ttype'] == 'many2many':
+ value = []
+ if values:
+ for id in values:
+ val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+ if val:
+ value.append(val[0][pool.get(model)._rec_name])
+ return value
+
+ elif field['ttype'] == 'one2many':
+ if values:
+ value = []
+ for id in values:
+ val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+
+ if val:
+ value.append(val[0][pool.get(model)._rec_name])
return value
-
- elif field['ttype'] == 'one2many':
- if values:
- value=[]
- for id in values:
- val=pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
-
- if len(val):
- value.append(val[0][pool.get(model)._rec_name])
- return value
return values
def create_log_line(self, cr, uid, id, object, lines=[]):
+ """
+ Creates lines for changed fields with its old and new values
+
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param object: Object who's values are being changed
+ @param lines: List of values for line is to be created
+ """
+
pool = pooler.get_pool(cr.dbname)
- obj=pool.get(object.model)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object.model)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ obj = pool.get(object.model)
+ #start Loop
for line in lines:
if obj._inherits:
- inherits_ids= pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
+ inherits_ids = pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
else:
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
- if len(f_id):
- fields=pool.get('ir.model.fields').read(cr, uid, f_id)
- old_value='old_value' in line and line['old_value'] or ''
- new_value='new_value' in line and line['new_value'] or ''
- old_value_text='old_value_text' in line and line['old_value_text'] or ''
- new_value_text='new_value_text' in line and line['new_value_text'] or ''
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
+ if f_id:
+ fields = pool.get('ir.model.fields').read(cr, uid, f_id)
+ old_value = 'old_value' in line and line['old_value'] or ''
+ new_value = 'new_value' in line and line['new_value'] or ''
+ old_value_text = 'old_value_text' in line and line['old_value_text'] or ''
+ new_value_text = 'new_value_text' in line and line['new_value_text'] or ''
if old_value_text == new_value_text:
continue
- if fields[0]['ttype']== 'many2one':
- if type(old_value)==tuple:
- old_value=old_value[0]
- if type(new_value)==tuple:
- new_value=new_value[0]
- log_line_id = pool.get('audittrail.log.line').create(cr, uid, {"log_id": id, "field_id": f_id[0] , "old_value":old_value , "new_value":new_value, "old_value_text":old_value_text , "new_value_text":new_value_text, "field_description":fields[0]['field_description']})
+ if fields[0]['ttype'] == 'many2one':
+ if type(old_value) == tuple:
+ old_value = old_value[0]
+ if type(new_value) == tuple:
+ new_value = new_value[0]
+ vals = {
+ "log_id": id,
+ "field_id": f_id[0],
+ "old_value": old_value,
+ "new_value": new_value,
+ "old_value_text": old_value_text,
+ "new_value_text": new_value_text,
+ "field_description": fields[0]['field_description']
+ }
+ line_id = pool.get('audittrail.log.line').create(cr, uid, vals)
cr.commit()
+ #End Loop
return True
def log_fct(self, db, uid, object, method, fct_src, *args):
- logged_uids = []
- pool = pooler.get_pool(db)
- cr = pooler.get_db(db).cursor()
- obj=pool.get(object)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
- if method in ('create'):
- res_id = fct_src(db, uid, object, method, *args)
+ """
+ Logging function: This function is performs logging oprations according to method
+ @param db: the current database
+ @param uid: the current user’s ID for security checks,
+ @param object: Object who's values are being changed
+ @param method: method to log: create, read, write, unlink
+ @param fct_src: execute method of Object proxy
+
+ @return: Returns result as per method of Object proxy
+ """
+ logged_uids = []
+ pool = pooler.get_pool(db)
+ cr = pooler.get_db(db).cursor()
+ obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
+ model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ if method in ('create'):
+ res_id = fct_src(db, uid, object, method, *args)
+ cr.commit()
+ new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
+ if 'id' in new_value:
+ del new_value['id']
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ vals = {
+ "method": method,
+ "object_id": model_object.id,
+ "user_id": uid, "res_id": res_id,
+ "name": resource_name
+ }
+ id = pool.get('audittrail.log').create(cr, uid, vals)
+ lines = []
+ for field in new_value:
+ if new_value[field]:
+ line = {
+ 'name': field,
+ 'new_value': new_value[field],
+ 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
+ }
+ lines.append(line)
+ self.create_log_line(cr, uid, id, model_object, lines)
+ cr.commit()
+ cr.close()
+ return res_id
+
+ if method in ('write'):
+ res_ids = args[0]
+ for res_id in res_ids:
+ old_values = pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
+ old_values_text = {}
+ for field in args[1].keys():
+ old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
+ res = fct_src(db, uid, object, method, *args)
cr.commit()
- new_value=pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
- if 'id' in new_value:
- del new_value['id']
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in new_value:
- if new_value[field]:
- line={
- 'name':field,
- 'new_value':new_value[field],
- 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
- }
- lines.append(line)
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.commit()
- cr.close()
- return res_id
-
- if method in ('write'):
- res_ids=args[0]
- for res_id in res_ids:
- old_values=pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
- old_values_text={}
- for field in args[1].keys():
- old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
- res =fct_src(db, uid, object, method, *args)
- cr.commit()
- if res:
- new_values=pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in args[1].keys():
- if args[1].keys():
- line={
- 'name':field,
- 'new_value':field in new_values and new_values[field] or '',
- 'old_value':field in old_values and old_values[field] or '',
- 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
- 'old_value_text':old_values_text[field]
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('read'):
- res_ids=args[0]
- old_values={}
- res =fct_src(db, uid, object, method, *args)
- if type(res)==list:
-
- for v in res:
- old_values[v['id']]=v
- else:
- old_values[res['id']]=res
- for res_id in old_values:
- if not len(logged_uids) or uid in logged_uids:
+ if res:
+ new_values = pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
+ if not logged_uids or uid in logged_uids:
resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line={
- 'name':field,
- 'old_value':old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('unlink'):
- res_ids=args[0]
- old_values={}
- for res_id in res_ids:
- old_values[res_id]=pool.get(model_object.model).read(cr, uid, res_id, [])
-
- for res_id in res_ids:
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line={
- 'name':field,
- 'old_value':old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in args[1].keys():
+ if args[1].keys():
+ line = {
+ 'name': field,
+ 'new_value': field in new_values and new_values[field] or '',
+ 'old_value': field in old_values and old_values[field] or '',
+ 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
+ 'old_value_text': old_values_text[field]
}
lines.append(line)
cr.commit()
self.create_log_line(cr, uid, id, model_object, lines)
- res =fct_src(db, uid, object, method, *args)
cr.close()
return res
+
+ if method in ('read'):
+ res_ids = args[0]
+ old_values = {}
+ res = fct_src(db, uid, object, method, *args)
+ if type(res) == list:
+
+ for v in res:
+ old_values[v['id']] = v
+ else:
+ old_values[res['id']] = res
+ for res_id in old_values:
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in old_values[res_id]:
+ if old_values[res_id][field]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ }
+ lines.append(line)
+ cr.commit()
+ self.create_log_line(cr, uid, id, model_object, lines)
cr.close()
+ return res
+
+ if method in ('unlink'):
+ res_ids = args[0]
+ old_values = {}
+ for res_id in res_ids:
+ old_values[res_id] = pool.get(model_object.model).read(cr, uid, res_id, [])
+
+ for res_id in res_ids:
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in old_values[res_id]:
+ if old_values[res_id][field]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ }
+ lines.append(line)
+ cr.commit()
+ self.create_log_line(cr, uid, id, model_object, lines)
+ res = fct_src(db, uid, object, method, *args)
+ cr.close()
+ return res
+ cr.close()
def execute(self, db, uid, object, method, *args, **kw):
+ """
+ Overrides Object Proxy execute method
+ @param db: the current database
+ @param uid: the current user’s ID for security checks,
+ @param object: Object who's values are being changed
+ @param method: method to log: create, read, write, unlink
+
+ @return: Returns result as per method of Object proxy
+ """
pool = pooler.get_pool(db)
cr = pooler.get_db(db).cursor()
cr.autocommit(True)
- obj=pool.get(object)
logged_uids = []
fct_src = super(audittrail_objects_proxy, self).execute
def my_fct(db, uid, object, method, *args):
field = method
rule = False
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object)])
+ obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
for obj_name in pool.obj_list():
if obj_name == 'audittrail.rule':
rule = True
if not rule:
return fct_src(db, uid, object, method, *args)
- if not len(obj_ids):
+ if not obj_ids:
return fct_src(db, uid, object, method, *args)
- rule_ids=pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
- if not len(rule_ids):
+ rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
+ if not rule_ids:
return fct_src(db, uid, object, method, *args)
for thisrule in pool.get('audittrail.rule').browse(cr, uid, rule_ids):
for user in thisrule.user_id:
logged_uids.append(user.id)
- if not len(logged_uids) or uid in logged_uids:
+ if not logged_uids or uid in logged_uids:
if field in ('read', 'write', 'create', 'unlink'):
- if getattr(thisrule, 'log_'+field):
+ if getattr(thisrule, 'log_' + field):
return self.log_fct(db, uid, object, method, fct_src, *args)
return fct_src(db, uid, object, method, *args)
res = my_fct(db, uid, object, method, *args)
diff --git a/addons/audittrail/audittrail_view.xml b/addons/audittrail/audittrail_view.xml
index 98a4ecc00e9..dec025b7e98 100644
--- a/addons/audittrail/audittrail_view.xml
+++ b/addons/audittrail/audittrail_view.xml
@@ -1,6 +1,9 @@
+
+
+
audittrail.rule.formaudittrail.rule
@@ -17,12 +20,15 @@
-
-
+
+
+
audittrail.rule.treeaudittrail.rule
@@ -40,6 +46,9 @@
+
+
+
Rulesaudittrail.rule
@@ -48,8 +57,11 @@
tree,form
-
-
+
+
+
@@ -60,6 +72,8 @@
[('state','=','subscribed')]
+
+
audittrail.log.form
@@ -73,23 +87,34 @@
-
+
@@ -117,15 +142,19 @@
+
+
Logsaudittrail.logform
-
+
-
-
+
+
-
+
diff --git a/addons/audittrail/security/ir.model.access.csv b/addons/audittrail/security/ir.model.access.csv
index ac367182f26..9aba9ddf598 100644
--- a/addons/audittrail/security/ir.model.access.csv
+++ b/addons/audittrail/security/ir.model.access.csv
@@ -5,3 +5,4 @@
"access_audittrail_rule_all_users","audittrail rule all","model_audittrail_rule","base.group_user",1,0,0,0
"access_audittrail_log_all_users","audittrail log all","model_audittrail_log","base.group_user",1,0,1,0
"access_audittrail_log_line_all_users","audittrail log line all","model_audittrail_log_line","base.group_user",1,0,1,0
+"access_audittrail_view_log","audittrail.view.log","model_audittrail_view_log","base.group_user",1,1,1,1
diff --git a/addons/audittrail/wizard/__init__.py b/addons/audittrail/wizard/__init__.py
index c7b5a20d884..9b2af466a01 100644
--- a/addons/audittrail/wizard/__init__.py
+++ b/addons/audittrail/wizard/__init__.py
@@ -19,6 +19,6 @@
#
##############################################################################
-import wizard_view_log
+import audittrail_view_log
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/audittrail/wizard/audittrail_view_log.py b/addons/audittrail/wizard/audittrail_view_log.py
new file mode 100644
index 00000000000..aa26c8cfd4c
--- /dev/null
+++ b/addons/audittrail/wizard/audittrail_view_log.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+import time
+
+class audittrail_view_log(osv.osv_memory):
+
+ _name = "audittrail.view.log"
+ _description = "View Log"
+ _columns = {
+ 'from':fields.datetime('Log From'),
+ 'to':fields.datetime('Log To', required = True)
+ }
+ _defaults = {
+ 'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
+ }
+
+ def log_open_window(self, cr, uid, ids, context=None):
+ """
+ Open Log form from given date range..
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of audittrail view log’s IDs.
+ @return: Dictionary of audittrail log form on given date range.
+ """
+ if not context:
+ context = {}
+
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
+ id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
+ result = act_obj.read(cr, uid, [id])[0]
+ #log_obj = self.pool.get(result['res_model'])
+ #log_id = log_obj.search(cr, uid, [])
+ #log_model = log_obj.read(cr, uid, log_id, ['object_id'])
+
+ #start Loop
+ for datas in self.read(cr, uid, ids):
+ if not datas.get('from', None):
+ if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"):
+ result['domain'] = str([('timestamp', '<', datas.get('to'))])
+ else:
+ pass
+ else:
+ result['domain'] = str([('timestamp', '>', datas.get('from', None)), ('timestamp', '<', datas.get('to'))])
+ #End Loop
+ return result
+
+audittrail_view_log()
diff --git a/addons/audittrail/wizard/audittrail_view_log_view.xml b/addons/audittrail/wizard/audittrail_view_log_view.xml
new file mode 100644
index 00000000000..e32bc65de40
--- /dev/null
+++ b/addons/audittrail/wizard/audittrail_view_log_view.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+ audittrail.view.log.form
+ audittrail.view.log
+ form
+
+
+
+
+
+
+
+
+ View log
+ audittrail.view.log
+ form
+ tree,form
+
+ new
+
+
+
+
diff --git a/addons/audittrail/wizard/wizard_view_log.py b/addons/audittrail/wizard/wizard_view_log.py
deleted file mode 100644
index 81936bcd54c..00000000000
--- a/addons/audittrail/wizard/wizard_view_log.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import time
-
-class wizard_view_log(wizard.interface):
-
- form1 = '''
- '''
-
- form1_fields = {
- 'from': {
- 'string': 'Log From',
- 'type': 'datetime',
-
- },
- 'to': {
- 'string': 'Log To',
- 'type': 'datetime',
- 'default': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
- 'required':True
- },
- }
-
-
- def _log_open_window(self, cr, uid, data, context):
- mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
- act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
- result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
- id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
- result = act_obj.read(cr, uid, [id])[0]
- log_obj= pooler.get_pool(cr.dbname).get(result['res_model'])
- log_id = log_obj.search(cr, uid, [])
- log_model=log_obj.read(cr, uid,log_id,['object_id'])
- if not data['form']['from']:
- if data['form']['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
- result['domain'] = str([('timestamp', '<',data['form']['to'])])
- else:
- pass
- else:
- result['domain'] = str([('timestamp', '>',data['form']['from']),('timestamp', '<',data['form']['to'])])
-
- return result
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel'), ('open', 'Open Logs')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action':_log_open_window, 'state':'end'}
- }
- }
-wizard_view_log('audittrail.view.log')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py
index 020d2740d4d..f4129998bcc 100644
--- a/addons/base_action_rule/base_action_rule.py
+++ b/addons/base_action_rule/base_action_rule.py
@@ -29,61 +29,86 @@ from osv.orm import except_orm
from tools.translate import _
class base_action_rule(osv.osv):
+ """ Base Action Rules """
+
_name = 'base.action.rule'
- _description = 'Action Rules'
-
-
+ _description = 'Action Rules'
+
_columns = {
'name': fields.many2one('ir.model', 'Model', required=True),
- 'max_level': fields.integer('Max Level', help='Specifies maximum level.'),
+ 'max_level': fields.integer('Max Level', help='Specifies maximum level.'),
'rule_lines': fields.one2many('base.action.rule.line','rule_id','Rule Lines'),
'create_date': fields.datetime('Create Date', readonly=1),
'active': fields.boolean('Active')
}
-
+
_defaults = {
'active': lambda *a: True,
'max_level': lambda *a: 15,
}
def format_body(self, body):
+ """ Foramat Action rule's body
+ @param self: The object pointer """
+
return body and tools.ustr(body) or ''
def format_mail(self, obj, body):
+ """ Foramat Mail
+ @param self: The object pointer """
+
data = {
'object_id': obj.id,
'object_subject': hasattr(obj, 'name') and obj.name or False,
'object_date': hasattr(obj, 'date') and obj.date or False,
'object_description': hasattr(obj, 'description') and obj.description or False,
'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/',
- 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email) or '/',
- 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
+ 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and \
+ obj.user_id.address_id and obj.user_id.address_id.email) or '/',
+ 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and\
+ obj.user_id.address_id and obj.user_id.address_id.phone) or '/',
'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/',
- 'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and obj.partner_address_id.email) or '/',
+ 'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and\
+ obj.partner_address_id.email) or '/',
}
return self.format_body(body % data)
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from',False), context={}):
+ """ send email
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param email: pass the emails
+ @param emailfrom: Pass name the email From else False
+ @param context: A standard dictionary for contextual values """
+
body = self.format_mail(obj, body)
if not emailfrom:
- if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email:
+ if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\
+ obj.user_id.address_id.email:
emailfrom = obj.user_id.address_id.email
-
+
name = '[%d] %s' % (obj.id, tools.ustr(obj.name))
emailfrom = tools.ustr(emailfrom)
- reply_to = emailfrom
+ reply_to = emailfrom
if not emailfrom:
raise osv.except_osv(_('Error!'),
_("No E-Mail ID Found for your Company address!"))
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
-
+
def do_check(self, cr, uid, action, obj, context={}):
- ok = True
- if hasattr(obj, 'user_id'):
+ """ check Action
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
+ ok = True
+ if hasattr(obj, 'user_id'):
ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==obj.user_id.id)
if hasattr(obj, 'partner_id'):
- ok = ok and (not action.trg_partner_id.id or action.trg_partner_id.id==obj.partner_id.id)
+ ok = ok and (not action.trg_partner_id.id or action.trg_partner_id.id==obj.partner_id.id)
ok = ok and (
not action.trg_partner_categ_id.id or
(
@@ -113,14 +138,22 @@ class base_action_rule(osv.osv):
return ok
def do_action(self, cr, uid, action, model_obj, obj, context={}):
+ """ Do Action
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param action: pass action
+ @param model_obj: pass Model object
+ @param context: A standard dictionary for contextual values """
+
if action.server_action_id:
context.update({'active_id':obj.id,'active_ids':[obj.id]})
self.pool.get('ir.actions.server').run(cr, uid, [action.server_action_id.id], context)
- write = {}
+ write = {}
if hasattr(obj, 'user_id') and action.act_user_id:
obj.user_id = action.act_user_id
write['user_id'] = action.act_user_id.id
- if hasattr(obj, 'date_action_last'):
+ if hasattr(obj, 'date_action_last'):
write['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
if hasattr(obj, 'state') and action.act_state:
obj.state = action.act_state
@@ -135,7 +168,7 @@ class base_action_rule(osv.osv):
write['priority'] = action.act_priority
model_obj.write(cr, uid, [obj.id], write, context)
-
+
if hasattr(model_obj, 'remind_user') and action.act_remind_user:
model_obj.remind_user(cr, uid, [obj.id], context, attach=action.act_remind_attach)
if hasattr(model_obj, 'remind_partner') and action.act_remind_partner:
@@ -146,7 +179,7 @@ class base_action_rule(osv.osv):
if hasattr(obj, 'user_id') and action.act_mail_to_user:
if obj.user_id and obj.user_id.address_id:
emails.append(obj.user_id.address_id.email)
-
+
if action.act_mail_to_watchers:
emails += (action.act_email_cc or '').split(',')
if action.act_mail_to_email:
@@ -158,11 +191,19 @@ class base_action_rule(osv.osv):
return True
def _action(self, cr, uid, ids, objects, scrit=None, context={}):
+ """ Do Action
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Basic Action Rule’s IDs,
+ @param objects: pass objects
+ @param context: A standard dictionary for contextual values """
+
if not scrit:
scrit = []
rule_line_obj = self.pool.get('base.action.rule.line')
- for rule in self.browse(cr, uid, ids):
- level = rule.max_level
+ for rule in self.browse(cr, uid, ids):
+ level = rule.max_level
if not level:
break
newactions = []
@@ -184,7 +225,8 @@ class base_action_rule(osv.osv):
base = mx.DateTime.strptime(obj.date_action_last, '%Y-%m-%d %H:%M:%S')
else:
base = mx.DateTime.strptime(obj.create_date[:19], '%Y-%m-%d %H:%M:%S')
- elif hasattr(obj, 'date_deadline') and action.trg_date_type=='deadline' and obj.date_deadline:
+ elif hasattr(obj, 'date_deadline') and action.trg_date_type=='deadline' \
+ and obj.date_deadline:
base = mx.DateTime.strptime(obj.date_deadline, '%Y-%m-%d %H:%M:%S')
elif hasattr(obj, 'date') and action.trg_date_type=='date' and obj.date:
base = mx.DateTime.strptime(obj.date, '%Y-%m-%d %H:%M:%S')
@@ -212,7 +254,7 @@ class base_action_rule(osv.osv):
if ok:
self.do_action(cr, uid, action, model_obj, obj, context)
- break
+ break
level -= 1
return True
base_action_rule()
@@ -222,20 +264,46 @@ class base_action_rule_line(osv.osv):
_description = 'Action Rule Lines'
def _state_get(self, cr, uid, context={}):
+ """ Get State
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return self.state_get(cr, uid, context=context)
def _priority_get(self, cr, uid, context={}):
+ """ Get Priority
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return self.priority_get(cr, uid, context=context)
def state_get(self, cr, uid, context={}):
+ """ Get State
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return [('','')]
def priority_get(self, cr, uid, context={}):
+ """ Get Priority
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values """
+
return [('','')]
_columns = {
'name': fields.char('Rule Name',size=64, required=True),
'rule_id': fields.many2one('base.action.rule','Rule'),
- 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the rule without removing it."),
- 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of rules."),
+ 'active': fields.boolean('Active', help="If the active field is set to true,\
+ it will allow you to hide the rule without removing it."),
+ 'sequence': fields.integer('Sequence', help="Gives the sequence order when\
+ displaying a list of rules."),
'trg_date_type': fields.selection([
('none','None'),
@@ -243,11 +311,13 @@ class base_action_rule_line(osv.osv):
('action_last','Last Action Date'),
('date','Date'),
], 'Trigger Date', size=16),
- 'trg_date_range': fields.integer('Delay after trigger date',help="Delay After Trigger Date, specifies you can put a negative number " \
- "if you need a delay before the trigger date, like sending a reminder 15 minutes before a meeting."),
- 'trg_date_range_type': fields.selection([('minutes', 'Minutes'),('hour','Hours'),('day','Days'),('month','Months')], 'Delay type'),
+ 'trg_date_range': fields.integer('Delay after trigger date',help="Delay After Trigger Date,\
+ specifies you can put a negative number " \
+ "if you need a delay before the trigger date, like sending a reminder 15 minutes before a meeting."),
+ 'trg_date_range_type': fields.selection([('minutes', 'Minutes'),('hour','Hours'),\
+ ('day','Days'),('month','Months')], 'Delay type'),
+
-
'trg_user_id': fields.many2one('res.users', 'Responsible'),
'trg_partner_id': fields.many2one('res.partner', 'Partner'),
@@ -255,42 +325,59 @@ class base_action_rule_line(osv.osv):
'trg_state_from': fields.selection(_state_get, 'State', size=16),
'trg_state_to': fields.selection(_state_get, 'Button Pressed', size=16),
'trg_priority_from': fields.selection(_priority_get, 'Minimum Priority'),
- 'trg_priority_to': fields.selection(_priority_get, 'Maximum Priority'),
-
- 'act_method': fields.char('Call Object Method', size=64),
- 'act_user_id': fields.many2one('res.users', 'Set responsible to'),
+ 'trg_priority_to': fields.selection(_priority_get, 'Maximum Priority'),
+
+ 'act_method': fields.char('Call Object Method', size=64),
+ 'act_user_id': fields.many2one('res.users', 'Set responsible to'),
'act_state': fields.selection(_state_get, 'Set state to', size=16),
- 'act_priority': fields.selection(_priority_get, 'Set priority to'),
- 'act_email_cc': fields.char('Add watchers (Cc)', size=250, help="These people will receive a copy of the future communication between partner and users by email"),
+ 'act_priority': fields.selection(_priority_get, 'Set priority to'),
+ 'act_email_cc': fields.char('Add watchers (Cc)', size=250, help="These people\
+ will receive a copy of the future communication between partner and users by email"),
- 'act_remind_partner': fields.boolean('Remind Partner', help="Check this if you want the rule to send a reminder by email to the partner."),
- 'act_remind_user': fields.boolean('Remind responsible', help="Check this if you want the rule to send a reminder by email to the user."),
+ 'act_remind_partner': fields.boolean('Remind Partner', help="Check this if\
+ you want the rule to send a reminder by email to the partner."),
+ 'act_remind_user': fields.boolean('Remind responsible', help="Check this if \
+ you want the rule to send a reminder by email to the user."),
'act_reply_to': fields.char('Reply-To', size=64),
- 'act_remind_attach': fields.boolean('Remind with attachment', help="Check this if you want that all documents attached to the object be attached to the reminder email sent."),
+ 'act_remind_attach': fields.boolean('Remind with attachment', help="Check this if\
+ you want that all documents attached to the object be attached \
+ to the reminder email sent."),
- 'act_mail_to_user': fields.boolean('Mail to responsible',help="Check this if you want the rule to send an email to the responsible person."),
- 'act_mail_to_watchers': fields.boolean('Mail to watchers (CC)',help="Check this if you want the rule to mark CC(mail to any other person defined in actions)."),
- 'act_mail_to_email': fields.char('Mail to these emails', size=128,help="Email-id of the persons whom mail is to be sent"),
+ 'act_mail_to_user': fields.boolean('Mail to responsible',help="Check this if \
+ you want the rule to send an email to the responsible person."),
+ 'act_mail_to_watchers': fields.boolean('Mail to watchers (CC)',help="Check this\
+ if you want the rule to mark CC(mail to any other person\
+ defined in actions)."),
+ 'act_mail_to_email': fields.char('Mail to these emails', size=128,help="Email-id \
+ of the persons whom mail is to be sent"),
'act_mail_body': fields.text('Mail body',help="Content of mail"),
'regex_name': fields.char('Regular Expression on Model Name', size=128),
- 'server_action_id': fields.many2one('ir.actions.server','Server Action',help="Describes the action name." \
- "eg:on which object which action to be taken on basis of which condition"),
+ 'server_action_id': fields.many2one('ir.actions.server','Server Action',help="Describes the\
+ action name." \
+ "eg:on which object which action to be taken on basis of which condition"),
}
-
+
_defaults = {
'active': lambda *a: 1,
'trg_date_type': lambda *a: 'none',
'trg_date_range_type': lambda *a: 'day',
'act_mail_to_user': lambda *a: 0,
'act_remind_partner': lambda *a: 0,
- 'act_remind_user': lambda *a: 0,
+ 'act_remind_user': lambda *a: 0,
'act_mail_to_watchers': lambda *a: 0,
}
-
- _order = 'sequence'
-
-
+
+ _order = 'sequence'
+
+
def _check_mail(self, cr, uid, ids, context=None):
+ """ Check Mail
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Action Rule’s IDs
+ @param context: A standard dictionary for contextual values """
+
empty = orm.browse_null()
rule_obj = self.pool.get('base.action.rule')
for rule in self.browse(cr, uid, ids):
@@ -300,10 +387,11 @@ class base_action_rule_line(osv.osv):
except (ValueError, KeyError, TypeError):
return False
return True
-
+
_constraints = [
(_check_mail, 'Error: The mail is not well formated', ['act_mail_body']),
]
-
+
base_action_rule_line()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml
index 9892886c675..06837e2c2da 100644
--- a/addons/base_action_rule/base_action_rule_view.xml
+++ b/addons/base_action_rule/base_action_rule_view.xml
@@ -1,10 +1,11 @@
-
+
-
base.action.rule.form
@@ -21,6 +22,8 @@
+
+
base.action.rule.treebase.action.rule
@@ -34,6 +37,8 @@
+
+
Action Rulesbase.action.rule
@@ -42,10 +47,11 @@
-
+
-
base.action.rule.line.form
@@ -127,6 +133,9 @@
+
+
+
base.action.rule.line.treebase.action.rule.line
diff --git a/addons/base_calendar/__init__.py b/addons/base_calendar/__init__.py
old mode 100644
new mode 100755
diff --git a/addons/base_calendar/__terp__.py b/addons/base_calendar/__terp__.py
old mode 100644
new mode 100755
index c0169db368b..e8b528db1a3
--- a/addons/base_calendar/__terp__.py
+++ b/addons/base_calendar/__terp__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,36 +15,33 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
-
{
- "name" : "Basic Calendar Functionality",
- "version" : "1.0",
- "depends" : [
- "base",
- ],
- 'description': """
- Full featured calendar system that support:
- - Alerts (create requests)
- - Recurring events (*)
- - Invitations to other people
-""",
- "author" : "Tiny",
- 'category': 'Generic Modules/Others',
- 'website': 'http://www.openerp.com',
+ "name" : "Basic Calendar Functionality",
+ "version" : "1.0",
+ "depends" : ["base"],
+ 'description': """Full featured calendar system that support:
+ - Alerts (create requests)
+ - Recurring events (*)
+ - Invitations to others people""",
+ "author" : "Tiny",
+ 'category': 'Generic Modules/Others',
+ 'website': 'http://www.openerp.com',
"init_xml" : [
- 'base_calendar_data.xml'
- ],
- "demo_xml" : [],
+ 'base_calendar_data.xml'
+ ],
+ "demo_xml" : [],
"update_xml" : [
- 'security/ir.model.access.csv',
- 'base_calendar_view.xml'
- ],
- "installable" : True,
- "active" : False,
+ 'security/ir.model.access.csv',
+ 'wizard/calendar_event_edit_all_view.xml',
+ 'wizard/base_calendar_invite_attendee_view.xml',
+ 'base_calendar_view.xml'
+ ],
+ "installable" : True,
+ "active" : False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py
index 3c99b7b5410..f7608219b9d 100644
--- a/addons/base_calendar/base_calendar.py
+++ b/addons/base_calendar/base_calendar.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,31 +15,39 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
+
from datetime import datetime, timedelta
from dateutil import parser
from dateutil import rrule
from osv import fields, osv
from service import web_services
from tools.translate import _
-import base64
-import pooler
import pytz
import re
import time
import tools
months = {
- 1:"January", 2:"February", 3:"March", 4:"April", \
- 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", \
- 10:"October", 11:"November", 12:"December"}
+ 1: "January", 2: "February", 3: "March", 4: "April", \
+ 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
+ 10: "October", 11: "November", 12: "December"}
def get_recurrent_dates(rrulestring, exdate, startdate=None):
+ """
+ Get recurrent dates based on Rule string considering exdate and start date
+ @param rrulestring: Rulestring
+ @param exdate: List of exception dates for rrule
+ @param startdate: Startdate for computing recurrent dates
+ @return: List of Recurrent dates
+ """
+
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)))
return val
+
if not startdate:
startdate = datetime.now()
rset1 = rrule.rrulestr(rrulestring, dtstart=startdate, forceset=True)
@@ -51,8 +59,15 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None):
return re_dates
def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
+ """
+ This function converts virtual event id into real id of actual event
+ @param base_calendar_id: Id of calendar
+ @param with_date: If value passed to this param it will return dates based on value of withdate + base_calendar_id
+ """
+
if base_calendar_id and isinstance(base_calendar_id, (str, unicode)):
res = base_calendar_id.split('-')
+
if len(res) >= 2:
real_id = res[0]
if with_date:
@@ -62,9 +77,17 @@ def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
end = start + timedelta(hours=with_date)
return (int(real_id), real_date, end.strftime("%Y-%m-%d %H:%M:%S"))
return int(real_id)
+
return base_calendar_id and int(base_calendar_id) or base_calendar_id
def real_id2base_calendar_id(real_id, recurrent_date):
+ """
+ Convert real id of record into virtual id using recurrent_date
+ e.g. real id is 1 and recurrent_date is 01-12-2009 10:00:00 then it will return
+ 1-20091201100000
+ @return: real id with recurrent date.
+ """
+
if real_id and recurrent_date:
recurrent_date = time.strftime("%Y%m%d%H%M%S", \
time.strptime(recurrent_date, "%Y-%m-%d %H:%M:%S"))
@@ -73,9 +96,17 @@ def real_id2base_calendar_id(real_id, recurrent_date):
def _links_get(self, cr, uid, context={}):
+ """
+ Get request link.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param context: A standard dictionary for contextual values
+ @return: list of dictionary which contain object and name and id.
+ """
+
obj = self.pool.get('res.request.link')
ids = obj.search(cr, uid, [])
- res = obj.read(cr, uid, ids, ['object', 'name'], context)
+ res = obj.read(cr, uid, ids, ['object', 'name'], context=context)
return [(r['object'], r['name']) for r in res]
html_invitation = """
@@ -184,101 +215,10 @@ html_invitation = """