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_period_close.py b/addons/account/wizard/wizard_period_close.py
deleted file mode 100644
index abdbb9c815e..00000000000
--- a/addons/account/wizard/wizard_period_close.py
+++ /dev/null
@@ -1,57 +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
-
-_transaction_form = '''
-'''
-
-_transaction_fields = {
- 'sure': {'string':'Check this box', 'type':'boolean'},
-}
-
-def _data_save(self, cr, uid, data, context):
- mode = 'done'
- if data['form']['sure']:
- for id in data['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 {}
-
-class wiz_journal_close(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel', 'gtk-cancel'),('close','Close Period', 'gtk-ok')]}
- },
- 'close': {
- 'actions': [_data_save],
- 'result': {'type': 'state', 'state':'end'}
- }
- }
-wiz_journal_close('account.period.close')
-
-
-# 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/event/__terp__.py b/addons/event/__terp__.py
index 654492e4ddf..3e76b9d19a2 100644
--- a/addons/event/__terp__.py
+++ b/addons/event/__terp__.py
@@ -41,13 +41,14 @@
'depends': ['crm', 'base_contact', 'account'],
'init_xml': ['event_data.xml'],
'update_xml': [
- 'event_wizard.xml',
+ 'wizard/event_confirm_registration_view.xml',
'event_view.xml',
'event_sequence.xml',
'security/event_security.xml',
'security/ir.model.access.csv',
'wizard/event_registration_view.xml',
'wizard/event_registrations_partner.xml',
+ 'wizard/event_make_invoice_view.xml',
],
'demo_xml': ['event_demo.xml'],
'installable': True,
diff --git a/addons/event/event.py b/addons/event/event.py
index e5485edc44e..ffdeb84d15d 100644
--- a/addons/event/event.py
+++ b/addons/event/event.py
@@ -151,6 +151,31 @@ event()
class event_registration(osv.osv):
+ def check_confirm(self, cr, uid, ids, context):
+ mod_obj = self.pool.get('ir.model.data')
+ current_registration = self.browse(cr, uid, [ids[0]])[0]
+ total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
+ if total_confirmed <= current_registration.event_id.register_max or current_registration.event_id.register_max == 0:
+ self.write(cr, uid, [ids[0]], {'state':'open'}, context=context)
+ self._history(cr, uid, [ids[0]], 'Open', history=True)
+ self.mail_user(cr, uid, [ids[0]])
+ return True
+ else:
+ model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_event_confirm_registration')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ context.update({'reg_id': ids[0]})
+ return {
+ 'name': _('Confirm Registration'),
+ 'context': context,
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'event.confirm.registration',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'nodestroy': True
+ }
+
def _history(self, cr, uid,ids,keyword, history=False, email=False, context={}):
for case in self.browse(cr, uid, ids):
if not case.case_id:
@@ -244,14 +269,14 @@ class event_registration(osv.osv):
"invoice_id":fields.many2one("account.invoice","Invoice"),
'date_closed': fields.datetime('Closed', readonly=True),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
- 'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
+ 'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id)]"),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
-
+
}
_defaults = {
'nb_register': lambda *a: 1,
diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml
index f257c8df6e4..3655e73afe6 100644
--- a/addons/event/event_view.xml
+++ b/addons/event/event_view.xml
@@ -162,7 +162,7 @@
-
+
@@ -203,7 +203,7 @@
-
+
diff --git a/addons/event/event_wizard.xml b/addons/event/event_wizard.xml
deleted file mode 100644
index 2888bd8587f..00000000000
--- a/addons/event/event_wizard.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/event/wizard/__init__.py b/addons/event/wizard/__init__.py
index f197adebe0a..81191b5a2f9 100644
--- a/addons/event/wizard/__init__.py
+++ b/addons/event/wizard/__init__.py
@@ -20,7 +20,7 @@
##############################################################################
import event_registration
-import make_invoice
+import event_make_invoice
import event_registrations_partner
-import confirm_registration
+import event_confirm_registration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/event/wizard/confirm_registration.py b/addons/event/wizard/confirm_registration.py
deleted file mode 100644
index 3c0cdac180d..00000000000
--- a/addons/event/wizard/confirm_registration.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 time
-import wizard
-import ir
-import pooler
-from osv.osv import except_osv
-from osv import fields,osv
-import netsvc
-
-ARCH = '''
-'''
-
-ARCH_fields={}
-
-def _confirm(self, cr, uid, data, context):
- registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
- current_registration = registration_obj.browse(cr, uid, [data['id']])[0]
-
- total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
- if total_confirmed <= current_registration.event_id.register_max or current_registration.event_id.register_max == 0:
- return 'confirm'
- return 'split'
-
-
-def _check_confirm(self, cr, uid, data, context):
- registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
- registration_obj.write(cr, uid, [data['id']], {'state':'open',})
- registration_obj._history(cr, uid, [data['id']], 'Open', history=True)
- registration_obj.mail_user(cr,uid,[data['id']])
- return {}
-
-
-class confirm_registration(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'choice', 'next_state' : _confirm}
- },
-
- 'split' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : ARCH,'fields':ARCH_fields,
- 'state' : [('end', 'Cancel'),('confirm', 'Confirm Anyway') ]}
- },
-
- 'confirm' : {
- 'actions' : [],
- 'result' : {'type' : 'action', 'action': _check_confirm, 'state' : 'end'}
- },
- 'end' : {
- 'actions' : [],
- 'result': {'type': 'state', 'state': 'end'},
- },
- }
-
-confirm_registration('event.confirm_registration')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/event/wizard/event_confirm_registration.py b/addons/event/wizard/event_confirm_registration.py
new file mode 100644
index 00000000000..f8a9d02de7d
--- /dev/null
+++ b/addons/event/wizard/event_confirm_registration.py
@@ -0,0 +1,47 @@
+# -*- 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
+
+class event_confirm_registration(osv.osv_memory):
+ """
+ Confirm Event Registration
+ """
+ _name = "event.confirm.registration"
+ _description = "Event Registraion"
+ _columns = {
+ 'msg': fields.text('Message', readonly=True),
+ }
+ _defaults={
+ 'msg':lambda *a:'The event limit is reached. What do you want to do?'
+ }
+
+ def confirm(self, cr, uid, ids, context):
+ registration_obj = self.pool.get('event.registration')
+ reg_id = context.get('reg_id', False) or context.get('active_id', False)
+ if reg_id:
+ registration_obj.write(cr, uid, [reg_id], {'state':'open',})
+ registration_obj._history(cr, uid, [reg_id], 'Open', history=True)
+ registration_obj.mail_user(cr,uid,[reg_id])
+ return {}
+
+event_confirm_registration()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/event/wizard/event_confirm_registration_view.xml b/addons/event/wizard/event_confirm_registration_view.xml
new file mode 100644
index 00000000000..03733d2045d
--- /dev/null
+++ b/addons/event/wizard/event_confirm_registration_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Registration Confirmation
+ event.confirm.registration
+ form
+
+
+
+
+
+
+ Registrations
+ ir.actions.act_window
+ event.confirm.registration
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/event/wizard/event_make_invoice.py b/addons/event/wizard/event_make_invoice.py
new file mode 100644
index 00000000000..1df4d2f2277
--- /dev/null
+++ b/addons/event/wizard/event_make_invoice.py
@@ -0,0 +1,140 @@
+# -*- 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
+
+class event_make_invoice(osv.osv_memory):
+ """
+ Make Invoices
+ """
+ _name = "event.make.invoice"
+ _description = "Event Make Invoice"
+ _columns = {
+ 'inv_created': fields.char('Invoice Created', size=32, readonly=True),
+ 'inv_rejected': fields.char('Invoice Rejected', size=32, readonly=True),
+ 'inv_rej_reason': fields.text('Error Messages', readonly=True),
+# 'invoice_ids': fields.char('Invoice Ids', size=128), # Improve me
+ }
+
+ def _makeInvoices(self, cr, uid, context={}):
+ invoices = {}
+ invoice_ids = []
+ create_ids=[]
+ tax_ids=[]
+ inv_create = 0
+ inv_reject = 0
+ inv_rej_reason = ""
+ list_inv = []
+ obj_event_reg = self.pool.get('event.registration')
+ obj_lines = self.pool.get('account.invoice.line')
+ inv_obj = self.pool.get('account.invoice')
+ data_event_reg = obj_event_reg.browse(cr,uid, context['active_ids'], context=context)
+
+ for reg in data_event_reg:
+ if reg.state=='draft':
+ inv_reject = inv_reject + 1
+ inv_rej_reason += "ID "+str(reg.id)+": Invoice cannot be created if the registration is in draft state. \n"
+ continue
+ if (not reg.tobe_invoiced):
+ inv_reject = inv_reject + 1
+ inv_rej_reason += "ID "+str(reg.id)+": Registration is set as 'Cannot be invoiced'. \n"
+ continue
+ if reg.invoice_id:
+ inv_reject = inv_reject + 1
+ inv_rej_reason += "ID "+str(reg.id)+": Registration already has an invoice linked. \n"
+ continue
+ if not reg.event_id.product_id:
+ inv_reject = inv_reject + 1
+ inv_rej_reason += "ID "+str(reg.id)+": Event related doesn't have any product defined. \n"
+ continue
+ if not reg.partner_invoice_id:
+ inv_reject = inv_reject + 1
+ inv_rej_reason += "ID "+str(reg.id)+": Registration doesn't have any partner to invoice. \n"
+ continue
+ partner_address_list = reg.partner_invoice_id and self.pool.get('res.partner').address_get(cr, uid, [reg.partner_invoice_id.id], adr_pref=['invoice'])
+ partner_address_id = partner_address_list['invoice']
+ if not partner_address_id:
+ inv_reject = inv_reject + 1
+ inv_rej_reason += "ID "+str(reg.id)+": Registered partner doesn't have an address to make the invoice. \n"
+ continue
+
+ inv_create = inv_create + 1
+ value = obj_lines.product_id_change(cr, uid, [], reg.event_id.product_id.id,uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id)
+ data_product = self.pool.get('product.product').browse(cr,uid,[reg.event_id.product_id.id])
+ for tax in data_product[0].taxes_id:
+ tax_ids.append(tax.id)
+
+ vals = value['value']
+ vals.update({
+ 'name': reg.name,
+ 'price_unit': reg.unit_price,
+ 'quantity': reg.nb_register,
+ 'product_id':reg.event_id.product_id.id,
+ 'invoice_line_tax_id': [(6, 0, tax_ids)],
+ })
+ inv_line_ids = obj_event_reg._create_invoice_lines(cr, uid, [reg.id], vals)
+
+ inv = {
+ 'name': reg.invoice_label,
+ 'origin': reg.invoice_label,
+ 'type': 'out_invoice',
+ 'reference': False,
+ 'account_id': reg.partner_invoice_id.property_account_receivable.id,
+ 'partner_id': reg.partner_invoice_id.id,
+ 'address_invoice_id':partner_address_id,
+ 'address_contact_id':partner_address_id,
+ 'invoice_line': [(6,0,[inv_line_ids])],
+ 'currency_id' :reg.partner_invoice_id.property_product_pricelist.currency_id.id,
+ 'comment': "",
+ 'payment_term':reg.partner_invoice_id.property_payment_term.id,
+ 'fiscal_position': reg.partner_invoice_id.property_account_position.id
+ }
+
+ inv_id = inv_obj.create(cr, uid, inv)
+ list_inv.append(inv_id)
+ obj_event_reg.write(cr, uid, reg.id, {'invoice_id': inv_id, 'state': 'done'})
+ obj_event_reg._history(cr, uid, [reg.id], 'Invoiced', history=True)
+
+# {'inv_created' : str(inv_create) , 'inv_rejected' : str(inv_reject), 'invoice_ids': str(list_inv), 'inv_rej_reason': inv_rej_reason}
+ return {'inv_created' : str(inv_create) , 'inv_rejected' : str(inv_reject), 'inv_rej_reason': inv_rej_reason}
+
+ def default_get(self, cr, uid, fields_list, context=None):
+ res = super(event_make_invoice, self).default_get(cr, uid, fields_list, context)
+ res.update(self._makeInvoices(cr, uid, context=context))
+ return res
+
+ def confirm(self, cr, uid, ids, context={}):
+ obj_model = self.pool.get('ir.model.data')
+ data_inv = self.read(cr, uid, ids, [], context)[0]
+ model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')])
+ resource_id = obj_model.read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
+ return {
+# 'domain': "[('id','in', ["+','.join(map(str,data_inv['invoice_ids']))+"])]",
+ 'name': 'Invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'views': [(False,'tree'),(resource_id,'form')],
+ 'context': "{'type':'out_invoice'}",
+ 'type': 'ir.actions.act_window'
+ }
+
+event_make_invoice()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/event/wizard/event_make_invoice_view.xml b/addons/event/wizard/event_make_invoice_view.xml
new file mode 100644
index 00000000000..0f4c7c9c152
--- /dev/null
+++ b/addons/event/wizard/event_make_invoice_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ event.make.invoice
+ event.make.invoice
+ form
+
+
+
+
+
+
+ Make Invoices
+ ir.actions.act_window
+ event.make.invoice
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/event/wizard/make_invoice.py b/addons/event/wizard/make_invoice.py
deleted file mode 100644
index 7df7fc2b6f0..00000000000
--- a/addons/event/wizard/make_invoice.py
+++ /dev/null
@@ -1,158 +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 netsvc
-import pooler
-
-from osv import fields, osv
-form = """
-
-"""
-fields = {
- 'inv_created': {'string':'Invoice Created', 'type':'char', 'readonly':True},
- 'inv_rejected': {'string':'Invoice Rejected', 'type':'char', 'readonly':True},
- 'inv_rej_reason': {'string':'Error Messages', 'type':'text', 'readonly':True},
-}
-
-def _makeInvoices(self, cr, uid, data, context):
- invoices = {}
- invoice_ids = []
- create_ids=[]
- tax_ids=[]
- pool_obj=pooler.get_pool(cr.dbname)
-
- inv_create = 0
- inv_reject = 0
- inv_rej_reason = ""
- list_inv = []
- obj_event_reg=pool_obj.get('event.registration')
- data_event_reg=obj_event_reg.browse(cr,uid,data['ids'])
- obj_lines=pool_obj.get('account.invoice.line')
-
- for reg in data_event_reg:
- if reg.state=='draft':
- inv_reject = inv_reject + 1
- inv_rej_reason += "ID "+str(reg.id)+": Invoice cannot be created if the registration is in draft state. \n"
- continue
- if (not reg.tobe_invoiced):
- inv_reject = inv_reject + 1
- inv_rej_reason += "ID "+str(reg.id)+": Registration is set as 'Cannot be invoiced'. \n"
- continue
- if reg.invoice_id:
- inv_reject = inv_reject + 1
- inv_rej_reason += "ID "+str(reg.id)+": Registration already has an invoice linked. \n"
- continue
- if not reg.event_id.product_id:
- inv_reject = inv_reject + 1
- inv_rej_reason += "ID "+str(reg.id)+": Event related doesn't have any product defined. \n"
- continue
- if not reg.partner_invoice_id:
- inv_reject = inv_reject + 1
- inv_rej_reason += "ID "+str(reg.id)+": Registration doesn't have any partner to invoice. \n"
- continue
- partner_address_list = reg.partner_invoice_id and pool_obj.get('res.partner').address_get(cr, uid, [reg.partner_invoice_id.id], adr_pref=['invoice'])
- partner_address_id = partner_address_list['invoice']
- if not partner_address_id:
- inv_reject = inv_reject + 1
- inv_rej_reason += "ID "+str(reg.id)+": Registered partner doesn't have an address to make the invoice. \n"
- continue
-
- inv_create = inv_create + 1
- value=obj_lines.product_id_change(cr, uid, [], reg.event_id.product_id.id,uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id)
- data_product=pool_obj.get('product.product').browse(cr,uid,[reg.event_id.product_id.id])
- for tax in data_product[0].taxes_id:
- tax_ids.append(tax.id)
-
- vals = value['value']
- vals.update({
- 'name': reg.name,
- 'price_unit': reg.unit_price,
- 'quantity': reg.nb_register,
- 'product_id':reg.event_id.product_id.id,
- 'invoice_line_tax_id': [(6,0,tax_ids)],
- })
- inv_line_ids = obj_event_reg._create_invoice_lines(cr, uid, [reg.id], vals)
-
- inv = {
- 'name': reg.invoice_label,
- 'origin': reg.invoice_label,
- 'type': 'out_invoice',
- 'reference': False,
- 'account_id': reg.partner_invoice_id.property_account_receivable.id,
- 'partner_id': reg.partner_invoice_id.id,
- 'address_invoice_id':partner_address_id,
- 'address_contact_id':partner_address_id,
- 'invoice_line': [(6,0,[inv_line_ids])],
- 'currency_id' :reg.partner_invoice_id.property_product_pricelist.currency_id.id,
- 'comment': "",
- 'payment_term':reg.partner_invoice_id.property_payment_term.id,
- 'fiscal_position': reg.partner_invoice_id.property_account_position.id
- }
-
- inv_obj = pool_obj.get('account.invoice')
- inv_id = inv_obj.create(cr, uid, inv)
- list_inv.append(inv_id)
- obj_event_reg.write(cr, uid,reg.id, {'invoice_id' : inv_id,'state':'done'})
- obj_event_reg._history(cr, uid,[reg.id], 'Invoiced', history=True)
-
- return {'inv_created' : str(inv_create) , 'inv_rejected' : str(inv_reject) , 'invoice_ids': list_inv, 'inv_rej_reason': inv_rej_reason}
-
-class make_invoice(wizard.interface):
-
- def _list_invoice(self, cr, uid, data, context):
- pool_obj = pooler.get_pool(cr.dbname)
- model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')])
- resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
- return {
- 'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]",
- 'name': 'Invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'views': [(False,'tree'),(resource_id,'form')],
- 'context': "{'type':'out_invoice'}",
- 'type': 'ir.actions.act_window'
- }
-
- states = {
- 'init' : {
- 'actions' : [_makeInvoices],
- 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state':[('end','Ok'),('open','Open')]}
- },
-
- 'open': {
- 'actions': [],
- 'result': {'type':'action', 'action':_list_invoice, 'state':'end'}
- }
-
- }
-
-make_invoice("event.reg_make_invoice")
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/l10n_be/__init__.py b/addons/l10n_be/__init__.py
index 444b6e3c625..1b2677d295e 100644
--- a/addons/l10n_be/__init__.py
+++ b/addons/l10n_be/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,11 +15,11 @@
# 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 company
import wizard
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/l10n_be/__terp__.py b/addons/l10n_be/__terp__.py
index 618367dfef7..6c13990fc45 100644
--- a/addons/l10n_be/__terp__.py
+++ b/addons/l10n_be/__terp__.py
@@ -18,10 +18,7 @@
# along with this program. If not, see .
#
##############################################################################
-
-
-{
- 'name': 'Belgium - Plan Comptable Minimum Normalise',
+{ 'name': 'Belgium - Plan Comptable Minimum Normalise',
'version': '1.1',
'category': 'Localisation/Account Charts',
'description': """
@@ -34,8 +31,12 @@
* This is the same wizard that runs from Financial Management/Configuration/Financial Accounting/Financial Accounts/Generate Chart of Accounts from a Chart Template.
Wizards provided by this module:
- * Enlist the partners with their related VAT and invoiced amounts.Prepares an XML file format.Path to access : Financial Management/Reporting/Listing of VAT Customers.
- * Prepares an XML file for Vat Declaration of the Main company of the User currently Logged in.Path to access : Financial Management/Reporting/Listing of VAT Customers.
+ * Partner VAT Intra: Enlist the partners with their related VAT and invoiced amounts.Prepares an XML file format.
+ Path to access : Financial Management/Reporting//Legal Statements/Belgium Statements/Partner VAT Listing
+ * Periodical VAT Declaration: Prepares an XML file for Vat Declaration of the Main company of the User currently Logged in.
+ Path to access : Financial Management/Reporting/Legal Statements/Belgium Statements/Periodical VAT Declaration
+ * Annual Listing Of VAT-Subjected Customers: Prepares an XML file for Vat Declaration of the Main company of the User currently Logged in.Based on Fiscal year
+ Path to access : Financial Management/Reporting/Legal Statements/Belgium Statements/Annual Listing Of VAT-Subjected Customers
""",
'author': 'Tiny',
@@ -51,13 +52,13 @@
'account_pcmn_belgium.xml',
'l10n_be_wizard.xml',
'wizard/l10n_be_account_vat_declaration_view.xml',
+ 'wizard/l10n_be_vat_intra_view.xml',
+ 'wizard/l10n_be_partner_vat_listing.xml',
'l10n_be_sequence.xml',
'fiscal_templates.xml',
'security/ir.model.access.csv'
],
- 'demo_xml': [
- 'account.report.report.csv'
- ],
+ 'demo_xml': ['account.report.report.csv'],
'installable': True,
'certificate': '0031977724637',
}
diff --git a/addons/l10n_be/l10n_be_wizard.xml b/addons/l10n_be/l10n_be_wizard.xml
index 86c4d828b70..317effd19b7 100644
--- a/addons/l10n_be/l10n_be_wizard.xml
+++ b/addons/l10n_be/l10n_be_wizard.xml
@@ -2,90 +2,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- step.vat.listing
- vat.listing.clients
- form
-
-
-
-
-
-
- step.vat.listing
- vat.listing.clients
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/l10n_be/wizard/__init__.py b/addons/l10n_be/wizard/__init__.py
index b811c54a6e4..2e09bbb17db 100644
--- a/addons/l10n_be/wizard/__init__.py
+++ b/addons/l10n_be/wizard/__init__.py
@@ -19,10 +19,8 @@
#
##############################################################################
-import account_vat_declaration
-import partner_vat_listing
-import wizard_vat_intra
+import l10_be_partner_vat_listing
+import l10n_be_vat_intra
import l10n_be_account_vat_declaration
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/l10n_be/wizard/partner_vat_listing.py b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py
similarity index 53%
rename from addons/l10n_be/wizard/partner_vat_listing.py
rename to addons/l10n_be/wizard/l10_be_partner_vat_listing.py
index ba5620a0b4e..049a625830b 100644
--- a/addons/l10n_be/wizard/partner_vat_listing.py
+++ b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py
@@ -1,3 +1,6 @@
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+
# -*- coding: utf-8 -*-
##############################################################################
#
@@ -19,13 +22,8 @@
#
##############################################################################
import time
-import datetime
import base64
-from tools.translate import _
-import tools
-import wizard
-import pooler
from tools.translate import _
import tools
from osv import fields, osv
@@ -33,75 +31,32 @@ from osv import fields, osv
class vat_listing_clients(osv.osv_memory):
_name = 'vat.listing.clients'
_columns = {
- 'name': fields.char('Cleint Name', size=64),
+ 'name': fields.char('Client Name', size=64),
'vat': fields.char('VAT', size=64),
'country': fields.char('Country', size=64),
'amount': fields.float('Amount'),
'turnover': fields.float('Turnover'),
- }
+ }
vat_listing_clients()
-form = """
-"""
+class partner_vat(osv.osv_memory):
+ """ Vat Listing """
+ _name = "partner.vat"
-fields = {
- 'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True,},
- 'mand_id':{'string':'MandataireId','type':'char','size':'30','required': True,},
- 'limit_amount':{'string':'Limit Amount','type':'integer','required': True, },
- 'test_xml': {'string':'Test XML file', 'type':'boolean', },
- }
-
-client_form = """
-"""
-
-client_fields = {
- 'partners': {'string': 'Cleints', 'type': 'many2many', 'relation': 'vat.listing.clients', 'required': False, 'help': 'You can remove clients/partners which you do not want to show in xml file'},
- }
-
-msg_form = """
-"""
-
-msg_fields = {
- 'name': {'string': 'File name', 'type':'char', 'size':'32'},
- 'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},
- 'file_save':{'string': 'Save File',
- 'type': 'binary',
- 'readonly': True,},
-}
-
-class wizard_vat(wizard.interface):
-
- def _get_partner(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- period = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fyear'])])
- p_id_list = pool.get('res.partner').search(cr,uid,[('vat_subjected','!=',False)])
+ def get_partner(self, cursor, user, ids, context={}):
+ obj_period = self.pool.get('account.period')
+ obj_partner = self.pool.get('res.partner')
+ obj_vat_lclient = self.pool.get('vat.listing.clients')
+ obj_model_data = self.pool.get('ir.model.data')
+ data = self.read(cursor, user, ids)[0]
+ period = obj_period.search(cursor, user, [('fiscalyear_id', '=', data['fyear'])], context=context)
+ p_id_list = obj_partner.search(cursor, user, [('vat_subjected', '!=', False)], context=context)
if not p_id_list:
- raise wizard.except_wizard(_('Data Insufficient!'),_('No partner has a VAT Number asociated with him.'))
+ raise osv.except_osv(_('Data Insufficient!'), _('No partner has a VAT Number asociated with him.'))
partners = []
records = []
- for obj_partner in pool.get('res.partner').browse(cr, uid, p_id_list):
-
+ for obj_partner in obj_partner.browse(cursor, user, p_id_list, context=context):
record = {} # this holds record per partner
#This listing is only for customers located in belgium, that's the
@@ -114,8 +69,8 @@ class wizard_vat(wizard.interface):
break
if not go_ahead:
continue
- cr.execute('select b.code,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in %s and l.partner_id=%s and l.period_id=ANY(%s) group by b.code',(('produit','tax'),obj_partner.id,period,))
- line_info = cr.fetchall()
+ cursor.execute('select b.code, sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in %s and l.partner_id=%s and l.period_id=ANY(%s) group by b.code',(('produit','tax'),obj_partner.id,period,))
+ line_info = cursor.fetchall()
if not line_info:
continue
@@ -127,7 +82,7 @@ class wizard_vat(wizard.interface):
#~addr = pool.get('res.partner').address_get(cr, uid, [obj_partner.id], ['invoice'])
#~ if addr.get('invoice',False):
- #~ads=pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
+ #~ads=pool.get('res.partner.address').browse(cr, uid, [addr['invoice']])[0]
#~ if ads.country_id:
#~ record.append(ads.country_id.code)
@@ -141,38 +96,81 @@ class wizard_vat(wizard.interface):
record['amount'] = 0
record['turnover'] = 0
record['name'] = obj_partner.name
-
for item in line_info:
- if item[0]=='produit':
+ if item[0] == 'produit':
record['turnover'] += item[1]
else:
record['amount'] += item[1]
- id_client = pool.get('vat.listing.clients').create(cr, uid, record)
+ id_client = obj_vat_lclient.create(cursor, user, record, context=context)
partners.append(id_client)
records.append(record)
+ context.update({'partner_ids': partners, 'fyear': data['fyear'], 'limit_amount': data['limit_amount'], 'mand_id':data['mand_id']})
+ model_data_ids = obj_model_data.search(cursor, user, [('model','=','ir.ui.view'), ('name','=','view_vat_listing')])
+ resource_id = obj_model_data.read(cursor, user, model_data_ids, fields=['res_id'])[0]['res_id']
+ return {
+# 'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]",
+ 'name': 'Vat Listing',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'partner.vat.list',
+ 'views': [(resource_id,'form')],
+ 'context': context,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
- return {'partners':partners}
+ _columns = {
+ 'fyear': fields.many2one('account.fiscalyear','Fiscal Year', required=True),
+ 'mand_id': fields.char('MandataireId', size=14, required=True, help="This identifies the representative of the sending company. This is a string of 14 characters"),
+ 'limit_amount': fields.integer('Limit Amount', required=True),
+ 'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"),
+ }
+partner_vat()
- def _create_xml(self, cr, uid, data, context):
+class partner_vat_list(osv.osv_memory):
+
+ """ Partner Vat Listing """
+ _name = "partner.vat.list"
+ _columns = {
+ 'partner_ids': fields.many2many('vat.listing.clients', 'vat_partner_rel', 'vat_id', 'partner_id', 'Clients', required=False, help='You can remove clients/partners which you do not want to show in xml file'),
+ 'name': fields.char('File Name', size=32),
+ 'msg': fields.text('File created', size=64, readonly=True),
+ 'file_save' : fields.binary('Save File', readonly=True),
+ }
+
+ def _get_partners(self, cursor, user, context={}):
+ return context.get('partner_ids', [])
+
+ _defaults={
+ 'partner_ids': _get_partners
+ }
+
+ def create_xml(self, cursor, user, ids, context={}):
datas=[]
- pool = pooler.get_pool(cr.dbname)
- seq_controlref = pool.get('ir.sequence').get(cr, uid,'controlref')
- seq_declarantnum = pool.get('ir.sequence').get(cr, uid,'declarantnum')
- obj_cmpny = pool.get('res.users').browse(cr, uid, uid).company_id
+ obj_sequence = self.pool.get('ir.sequence')
+ obj_users = self.pool.get('res.users')
+ obj_partner = self.pool.get('res.partner')
+ obj_fyear = self.pool.get('account.fiscalyear')
+ obj_addr = self.pool.get('res.partner.address')
+ obj_vat_lclient = self.pool.get('vat.listing.clients')
+ obj_model_data = self.pool.get('ir.model.data')
+
+ seq_controlref = obj_sequence.get(cursor, user, 'controlref')
+ seq_declarantnum = obj_sequence.get(cursor, user, 'declarantnum')
+ obj_cmpny = obj_users.browse(cursor, user, user, context=context).company_id
company_vat = obj_cmpny.partner_id.vat
if not company_vat:
- raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
+ raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
cref = company_vat + seq_controlref
dnum = cref + seq_declarantnum
-
- obj_year=pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear'])
+ obj_year= obj_fyear.browse(cursor, user, context['fyear'], context=context)
street = zip_city = country = ''
- addr = pool.get('res.partner').address_get(cr, uid, [obj_cmpny.partner_id.id], ['invoice'])
+ addr = obj_partner.address_get(cursor, user, [obj_cmpny.partner_id.id], ['invoice'])
if addr.get('invoice',False):
- ads=pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
+ ads = obj_addr.browse(cursor, user, [addr['invoice']], context=context)[0]
- zip_city = pool.get('res.partner.address').get_city(cr,uid,ads.id)
+ zip_city = obj_addr.get_city(cursor, user, ads.id)
if not zip_city:
zip_city = ''
if ads.street:
@@ -185,8 +183,8 @@ class wizard_vat(wizard.interface):
sender_date = time.strftime('%Y-%m-%d')
data_file = '\n'
data_file += '\n\n\t\n\t\t'+str(company_vat)+'\n\t\t'+tools.ustr(obj_cmpny.name)+'\n\t\t'+ tools.ustr(street) +'\n\t\t'+ tools.ustr(zip_city) +''
@@ -194,25 +192,24 @@ class wizard_vat(wizard.interface):
data_comp = '\n\n\t'+str(company_vat)+'\n\t'+tools.ustr(obj_cmpny.name)+'\n\t'+ tools.ustr(street) +'\n\t'+ tools.ustr(zip_city) +'\n\t'+ tools.ustr(country) +'\n'
data_period = '\n'+ tools.ustr(obj_year.date_stop[:4]) +''
error_message = []
-
- for partner in data['form']['partners']:
+ data = self.read(cursor, user, ids)[0]
+ for partner in data['partner_ids']:
if isinstance(partner, list) and partner:
datas.append(partner[2])
else:
- client_data = pool.get('vat.listing.clients').read(cr, uid, partner, context=context)
+ client_data = obj_vat_lclient.read(cursor, user, partner, context=context)
datas.append(client_data)
-
- seq=0
- data_clientinfo=''
- sum_tax=0.00
- sum_turnover=0.00
+ seq = 0
+ data_clientinfo = ''
+ sum_tax = 0.00
+ sum_turnover = 0.00
if len(error_message):
- data['form']['msg']='Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
- return data['form']
+ msg ='Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
+ return msg
for line in datas:
if not line:
continue
- if line['turnover'] < data['form']['limit_amount']:
+ if line['turnover'] < context['limit_amount']:
continue
seq +=1
sum_tax +=line['amount']
@@ -221,28 +218,11 @@ class wizard_vat(wizard.interface):
data_decl ='\n'
data_file += tools.ustr(data_decl) + tools.ustr(data_comp) + tools.ustr(data_period) + tools.ustr(data_clientinfo) + '\n'
+ msg = 'Save the File with '".xml"' extension.'
+ file_save = base64.encodestring(data_file.encode('utf8'))
+ self.write(cursor, user, ids, {'file_save':file_save, 'msg':msg, 'name':'vat_list.xml'}, context=context)
+ return True
- data['form']['msg'] = 'Save the File with '".xml"' extension.'
- data['form']['file_save'] = base64.encodestring(data_file.encode('utf8'))
- data['form']['name'] = 'vat_list.xml'
- return data['form']
+partner_vat_list()
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancel', 'gtk-cancel'),('go_step','View Clients', 'gtk-ok')]},
- },
- 'go_step': {
- 'actions': [_get_partner],
- 'result': {'type':'form', 'arch':client_form, 'fields':client_fields, 'state':[('end','Cancel', 'gtk-cancel'),('go','Create XML', 'gtk-ok')]},
- },
- 'go': {
- 'actions': [_create_xml],
- 'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok', 'gtk-cancel')]},
- }
-
- }
-
-wizard_vat('list.vat.detail')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py
index 490709b15ec..9dd5ea5b269 100644
--- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py
+++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py
@@ -18,27 +18,25 @@
# along with this program. If not, see .
#
##############################################################################
-
-import time
-import datetime
import base64
+
from osv import osv, fields
from tools.translate import _
class l10n_be_vat_declaration(osv.osv_memory):
- """ Vat Declaration """
+ """ Periodical VAT Declaration """
_name = "l1on_be.vat.declaration"
_description = "Vat Declaration"
_columns = {
'period_id': fields.many2one('account.period','Period', required=True),
'msg': fields.text('File created', size=64, readonly=True),
- 'file_save' : fields.binary('Save File'),
- }
+ 'file_save': fields.binary('Save File'),
+ }
_defaults = {
'msg': lambda *a:'''Save the File with '".xml"' extension.''',
- }
+ }
def create_xml(self, cr, uid, ids, context={}):
obj_fyear = self.pool.get('account.fiscalyear')
@@ -53,7 +51,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
user_cmpny = obj_company.name
vat_no=obj_company.partner_id.vat
if not vat_no:
- raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
+ raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
tax_code_ids = obj_tax_code.search(cr, uid, [], context=context)
ctx = context.copy()
@@ -66,8 +64,6 @@ class l10n_be_vat_declaration(osv.osv_memory):
address = post_code = city = ''
city, post_code, address = obj_comp._get_default_ad(obj_company.partner_id.address)
-
-
year_id = obj_fyear.find(cr, uid)
account_period = obj_acc_period.browse(cr, uid, data['period_id'], context=context)
@@ -89,23 +85,23 @@ class l10n_be_vat_declaration(osv.osv_memory):
#starting month and ending month of selected period are not the same
#it means that the accounting isn't based on periods of 1 month but on quarters
quarter = str(((int(starting_month) - 1) / 3) + 1)
- data_of_file += ''+quarter+'\n\t\t\t'
+ data_of_file += '' + quarter + '\n\t\t\t'
else:
- data_of_file += ''+starting_month+'\n\t\t\t'
+ data_of_file += '' + starting_month + '\n\t\t\t'
data_of_file += '' + str(account_period.date_stop[:4]) + '\n\t\t\n\t\t'
data_of_file +='\n\t\t\n\t\t\t'
for item in tax_info:
if item['code']:
if item['code'] == '71-72':
- item['code']='71'
+ item['code'] = '71'
if item['code'] in list_of_tags:
- data_of_file +='\n\t\t\t\t' + str(int(item['sum_period']*100)) + ''
+ data_of_file +='\n\t\t\t\t' + str(int(item['sum_period']*100)) + ''
data_of_file +='\n\t\t\t\n\t\t\n\t\n'
data['file_save'] = base64.encodestring(data_of_file)
self.write(cr, uid, ids, {'file_save':data['file_save']}, context=context)
-
+ return True
l10n_be_vat_declaration()
diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml b/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml
index f0c19198bf3..56f8b6477f9 100644
--- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml
+++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml
@@ -3,9 +3,9 @@
+ id="menu_finance_belgian_statement"
+ name="Belgium Statements"
+ parent="account.menu_finance_legal_statement"/>
Select Period
@@ -13,9 +13,9 @@
form