diff --git a/addons/account/__terp__.py b/addons/account/__openerp__.py
similarity index 85%
rename from addons/account/__terp__.py
rename to addons/account/__openerp__.py
index bfa5f8fb47b..ca5caee014d 100644
--- a/addons/account/__terp__.py
+++ b/addons/account/__openerp__.py
@@ -54,8 +54,20 @@ module named account_voucherss
'wizard/account_move_line_reconcile_select_view.xml',
'wizard/account_move_journal_view.xml',
'account_wizard.xml',
+ 'wizard/account_open_closed_fiscalyear_view.xml',
'wizard/account_move_line_unreconcile_select_view.xml',
+ 'wizard/account_vat_view.xml',
+ 'wizard/account_print_journal_view.xml',
+ 'wizard/account_general_journal_view.xml',
+ 'wizard/account_central_journal_view.xml',
'wizard/account_subscription_generate_view.xml',
+ 'wizard/account_fiscalyear_close_view.xml',
+ 'wizard/account_state_open_view.xml',
+ 'wizard/account_journal_select_view.xml',
+ 'wizard/account_change_currency_view.xml',
+ 'wizard/account_validate_move_view.xml',
+ 'wizard/account_statement_from_invoice_view.xml',
+ 'wizard/account_pay_invoice_view.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_view.xml',
'account_end_fy.xml',
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index 789ae810457..deb010c7cd0 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -27,6 +27,26 @@ from tools.misc import currency
from tools.translate import _
class account_bank_statement(osv.osv):
+
+ def button_import_invoice(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.model.data')
+ if context is None:
+ context = {}
+ model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_account_statement_from_invoice')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ context.update({'statement_id': ids[0]})
+ return {
+ 'name': _('Import Invoice'),
+ 'context': context,
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.statement.from.invoice',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'nodestroy': True
+ }
+
def _default_journal_id(self, cr, uid, context={}):
if context.get('journal_id', False):
return context['journal_id']
@@ -352,16 +372,16 @@ class account_bank_statement(osv.osv):
raise osv.except_osv(_('Invalid action !'), _('Cannot delete bank statement which are already confirmed !'))
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True
-
+
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
if context is None:
- context = {}
+ context = {}
default = default.copy()
default['move_line_ids'] = []
return super(account_bank_statement, self).copy(cr, uid, id, default, context)
-
+
account_bank_statement()
diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml
index 5b7c1f5d977..5ef07f6c88b 100644
--- a/addons/account/account_invoice_view.xml
+++ b/addons/account/account_invoice_view.xml
@@ -203,7 +203,7 @@
-
+
@@ -295,7 +295,7 @@
-
+
diff --git a/addons/account/account_report.xml b/addons/account/account_report.xml
index 5c99ebdde13..9d449f116f4 100644
--- a/addons/account/account_report.xml
+++ b/addons/account/account_report.xml
@@ -24,25 +24,33 @@
-
+
-
- -->
+
+
@@ -66,6 +74,7 @@
rml="account/report/compare_account_balance.rml"
auto="False"
menu="False"/>
+
-
+
+
+
@@ -652,23 +653,7 @@
-
-
-
-
-
-
-
- tree_but_open
- account.journal.period
- Open Journal
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
@@ -59,12 +39,12 @@
-
+
+
+
+
+
+
@@ -110,10 +90,10 @@
-
+
@@ -122,7 +102,7 @@
-
+
@@ -131,15 +111,15 @@
-
+
-
+
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index e79774e36e4..20eea676611 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -443,8 +443,9 @@ class account_invoice(osv.osv):
return {'value': {}}
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id):
- val={}
- dom={}
+ val = {}
+ dom = {}
+ obj_journal = self.pool.get('account.journal')
if company_id and part_id and type:
acc_id = False
partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id)
@@ -488,13 +489,20 @@ class account_invoice(osv.osv):
_('invoice line account company is not match with invoice company.'))
else:
continue
- if company_id:
- val['journal_id']=False
- journal_ids=self.pool.get('account.journal').search(cr,uid,[('company_id','=',company_id)])
- dom={'journal_id': [('id','in',journal_ids)]}
+ if company_id and type:
+ if type in ('out_invoice', 'out_refund'):
+ journal_type = 'sale'
+ else:
+ journal_type = 'purchase'
+ journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)])
+ if journal_ids:
+ val['journal_id'] = journal_ids[0]
+ else:
+ raise osv.except_osv(_('Configration Error !'),
+ _('Can not find account journal for this company in invoice, Please Create journal.'))
+ dom = {'journal_id': [('id', 'in', journal_ids)]}
else:
- journal_ids=self.pool.get('account.journal').search(cr,uid,[])
- dom={'journal_id': [('id','in',journal_ids)]}
+ journal_ids = obj_journal.search(cr, uid, [])
if currency_id and company_id:
currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
@@ -644,6 +652,7 @@ class account_invoice(osv.osv):
def compute_invoice_totals(self, cr, uid, inv, company_currency, ref, invoice_move_lines):
total = 0
total_currency = 0
+ cur_obj = self.pool.get('res.currency')
for i in invoice_move_lines:
if inv.currency_id.id != company_currency:
i['currency_id'] = inv.currency_id.id
diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py
index 830f8152120..5b8418be430 100644
--- a/addons/account/report/account_journal.py
+++ b/addons/account/report/account_journal.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,19 +15,19 @@
# 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 time
+
from report import report_sxw
#
# Use period and Journal for selection or resources
#
class journal_print(report_sxw.rml_parse):
- def __init__(self, cr, uid, name, context):
+ def __init__(self, cr, uid, name, context={}):
super(journal_print, self).__init__(cr, uid, name, context=context)
self.localcontext.update( {
'time': time,
@@ -37,11 +37,13 @@ class journal_print(report_sxw.rml_parse):
})
def lines(self, period_id, journal_id, sort_selection='date', *args):
- if type(period_id)==type([]):
+ obj_jperiod = self.pool.get('account.journal.period')
+ obj_mline = self.pool.get('account.move.line')
+ if type(period_id) == type([]):
ids_final = []
for journal in journal_id:
for period in period_id:
- ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)])
+ ids_journal_period = obj_jperiod.search(self.cr, self.uid, [('journal_id','=',journal), ('period_id','=',period)])
if ids_journal_period:
self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal,period,'draft'))
self.cr.commit()
@@ -50,14 +52,14 @@ class journal_print(report_sxw.rml_parse):
ids_final.append(ids)
line_ids = []
for line_id in ids_final:
- a = self.pool.get('account.move.line').browse(self.cr, self.uid, line_id )
+ a = obj_mline.browse(self.cr, self.uid, line_id)
line_ids.append(a)
return line_ids
self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft'))
self.cr.commit()
self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by date,id', (period_id, journal_id))
ids = map(lambda x: x[0], self.cr.fetchall())
- return self.pool.get('account.move.line').browse(self.cr, self.uid, ids )
+ return obj_mline.browse(self.cr, self.uid, ids)
def _sum_debit(self, period_id, journal_id):
self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id))
@@ -66,8 +68,9 @@ class journal_print(report_sxw.rml_parse):
def _sum_credit(self, period_id, journal_id):
self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
-report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print,header=False)
-report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print,header=False)
+
+report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header=False)
+report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/report/central_journal.py b/addons/account/report/central_journal.py
index 9bc2cfdd1b9..36c61b877ff 100644
--- a/addons/account/report/central_journal.py
+++ b/addons/account/report/central_journal.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 .
#
##############################################################################
@@ -59,8 +59,8 @@ class journal_print(report_sxw.rml_parse):
def _sum_credit(self, period_id, journal_id):
self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
-report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print, header=False)
-report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml',parser=journal_print, header=False)
+report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml', parser=journal_print, header=False)
+report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml', parser=journal_print, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py
index 2da07e04cfd..112ce970694 100644
--- a/addons/account/report/general_journal.py
+++ b/addons/account/report/general_journal.py
@@ -122,8 +122,8 @@ class journal_print(report_sxw.rml_parse):
return 0.0
self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,))
return self.cr.fetchone()[0] or 0.0
-report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print)
-report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False)
+report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print)
+report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py
index 3910622ad68..daa010a0453 100644
--- a/addons/account/report/tax_report.py
+++ b/addons/account/report/tax_report.py
@@ -20,16 +20,15 @@
##############################################################################
import time
-import pooler
-import rml_parse
import copy
+
+import rml_parse
from report import report_sxw
-import pdb
-import re
class tax_report(rml_parse.rml_parse):
_name = 'report.account.vat.declaration'
- def __init__(self, cr, uid, name, context):
+ def __init__(self, cr, uid, name, context={}):
+ print "tax______init", name, context
super(tax_report, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
@@ -42,19 +41,19 @@ class tax_report(rml_parse.rml_parse):
})
- def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0):
- res = self._get_codes(based_on,company_id,parent,level,period_list)
+ def _get_lines(self, based_on, period_list, company_id=False, parent=False, level=0, context={}):
+ res = self._get_codes(based_on, company_id, parent, level, period_list, context=context)
- if period_list[0][2] :
- res = self._add_codes(based_on,res,period_list)
+ if period_list:
+ res = self._add_codes(based_on, res, period_list, context=context)
else :
self.cr.execute ("select id from account_fiscalyear")
fy = self.cr.fetchall()
self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],))
periods = self.cr.fetchall()
for p in periods :
- period_list[0][2].append(p[0])
- res = self._add_codes(based_on,res,period_list)
+ period_list.append(p[0])
+ res = self._add_codes(based_on, res, period_list, context=context)
i = 0
top_result = []
@@ -71,7 +70,7 @@ class tax_report(rml_parse.rml_parse):
}
top_result.append(res_dict)
- res_general = self._get_general(res[i][1].id,period_list,company_id,based_on)
+ res_general = self._get_general(res[i][1].id, period_list, company_id, based_on, context=context)
ind_general = 0
while ind_general < len(res_general) :
res_general[ind_general]['type'] = 2
@@ -84,11 +83,12 @@ class tax_report(rml_parse.rml_parse):
return top_result
#return array_result
- def _get_period(self, period_id):
- return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
+ def _get_period(self, period_id, context={}):
+ return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name
- def _get_general(self, tax_code_id,period_list ,company_id, based_on):
+ def _get_general(self, tax_code_id,period_list ,company_id, based_on, context={}):
res=[]
+ obj_account = self.pool.get('account.account')
if based_on == 'payments':
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
SUM(line.debit) AS debit, \
@@ -110,8 +110,8 @@ class tax_report(rml_parse.rml_parse):
AND line.period_id =ANY(%s) \
AND ((invoice.state = %s) \
OR (invoice.id IS NULL)) \
- GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
- company_id, period_list[0][2],'paid',))
+ GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
+ company_id, period_list, 'paid',))
else :
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
@@ -129,52 +129,54 @@ class tax_report(rml_parse.rml_parse):
AND account.company_id = %s \
AND line.period_id =ANY(%s)\
AND account.active \
- GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
- company_id,period_list[0][2],))
+ GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
+ company_id, period_list,))
res = self.cr.dictfetchall()
#AND line.period_id IN ('+ period_sql_list +') \
i = 0
while i= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ):
- tot_elem = copy.copy(accounts[bcl_rup_ind])
+ tot_elem = copy.copy(accounts[bcl_rup_ind], context=context)
res_tot = { 'code' : accounts[bcl_rup_ind]['code'],
'name' : '',
'debit' : 0,
@@ -218,6 +220,6 @@ class tax_report(rml_parse.rml_parse):
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
- 'addons/account/report/tax_report.rml', parser=tax_report, header=False)
+ 'addons/account/report/tax_report.rml', parser=tax_report, header=True)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py
index f3a05ebe184..6183ee3acee 100644
--- a/addons/account/wizard/__init__.py
+++ b/addons/account/wizard/__init__.py
@@ -25,9 +25,9 @@ import account_move_line_unreconcile_select
import wizard_reconcile
import wizard_unreconcile
import account_invoice_refund
-import wizard_pay_invoice
+import account_pay_invoice
import account_move_journal
-import wizard_journal_select
+import account_journal_select
import account_move_bank_reconcile
import account_subscription_generate
import wizard_aged_trial_balance
@@ -36,27 +36,27 @@ import wizard_third_party_ledger
import wizard_account_balance_report
import wizard_partner_balance_report
import account_period_close
-import wizard_fiscalyear_close
+import account_fiscalyear_close
import account_fiscalyear_close_state
-import wizard_open_closed_fiscalyear
+import account_vat
+import account_open_closed_fiscalyear
-import wizard_vat
import wizard_compare_account_balance_report
import wizard_invoice_state
import wizard_account_duplicate
import account_chart
import wizard_move_line_select
-import wizard_validate_account_move
+import account_validate_account_move
import wizard_use_model
-import wizard_state_open
+import account_state_open
-import wizard_statement_from_invoice
-import wizard_print_journal
-import wizard_central_journal
-import wizard_general_journal
-import wizard_change_currency
+import account_statement_from_invoice
+import account_print_journal
+import account_central_journal
+import account_general_journal
+import account_change_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_central_journal.py b/addons/account/wizard/account_central_journal.py
new file mode 100644
index 00000000000..08fe881c81a
--- /dev/null
+++ b/addons/account/wizard/account_central_journal.py
@@ -0,0 +1,62 @@
+# -*- 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 osv, fields
+from tools.translate import _
+
+class account_central_journal(osv.osv_memory):
+ _name = 'account.central.journal'
+ _description = 'Account Central Journal'
+
+ _columns = {
+ 'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
+ 'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
+ }
+
+ def check_data(self, cr, uid, ids, context={}):
+ obj_jperiod = self.pool.get('account.journal.period')
+ datas = {}
+ datas['ids'] = []
+ datas['model'] = 'account.journal.period'
+ datas['form'] = self.read(cr, uid, ids)[0]
+ period_id = datas['form']['period_id']
+ journal_id = datas['form']['journal_id']
+
+ if type(period_id)==type([]):
+ ids_final = []
+ for journal in journal_id:
+ for period in period_id:
+ ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context)
+ if ids_journal_period:
+ ids_final.append(ids_journal_period)
+ if not ids_final:
+ raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'account.central.journal',
+ 'datas': datas,
+ }
+
+account_central_journal()
+
+#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+
diff --git a/addons/account/wizard/account_central_journal_view.xml b/addons/account/wizard/account_central_journal_view.xml
new file mode 100644
index 00000000000..ec3f0eabb5d
--- /dev/null
+++ b/addons/account/wizard/account_central_journal_view.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+ Account central Journal
+ account.central.journal
+ form
+
+
+
+
+
+
+ Account Central Journal
+ ir.actions.act_window
+ account.central.journal
+ form
+ form
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py
new file mode 100644
index 00000000000..707a182a2aa
--- /dev/null
+++ b/addons/account/wizard/account_change_currency.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- encoding: 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 osv, fields
+from tools.translate import _
+
+class account_change_currency(osv.osv_memory):
+ _name = 'account.change.currency'
+ _description = 'Change Currency'
+ _columns = {
+ 'currency_id': fields.many2one('res.currency', 'New Currency', required=True),
+ }
+
+ def view_init(self, cr , uid , fields_list, context=None):
+ obj_inv = self.pool.get('account.invoice')
+ if context is None:
+ context = {}
+ state = obj_inv.browse(cr, uid, context['active_id']).state
+ if obj_inv.browse(cr, uid, context['active_id']).state != 'draft':
+ raise osv.except_osv(_('Error'), _('You can not change currency for Open Invoice !'))
+ pass
+
+ def change_currency(self, cr, uid, ids, context=None):
+ obj_inv = self.pool.get('account.invoice')
+ obj_inv_line = self.pool.get('account.invoice.line')
+ obj_currency = self.pool.get('res.currency')
+ if context is None:
+ context = {}
+ data = self.read(cr, uid, ids)[0]
+ new_currency = data['currency_id']
+
+ for invoice in obj_inv.browse(cr, uid, context['active_ids'], context=context):
+ if invoice.currency_id.id == new_currency:
+ continue
+
+ for line in invoice.invoice_line:
+ rate = obj_currency.browse(cr, uid, new_currency).rate
+ new_price = 0
+ if invoice.company_id.currency_id.id == invoice.currency_id.id:
+ new_price = line.price_unit * rate
+
+ if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
+ old_rate = invoice.currency_id.rate
+ new_price = line.price_unit / old_rate
+
+ if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
+ old_rate = invoice.currency_id.rate
+ new_price = (line.price_unit / old_rate ) * rate
+
+ obj_inv_line.write(cr, uid, [line.id], {'price_unit' : new_price})
+ obj_inv.write(cr, uid, [invoice.id], {'currency_id' : new_currency})
+ return {}
+
+account_change_currency()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_change_currency_view.xml b/addons/account/wizard/account_change_currency_view.xml
new file mode 100644
index 00000000000..33b351bb85c
--- /dev/null
+++ b/addons/account/wizard/account_change_currency_view.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+ Change Currency
+ account.change.currency
+ form
+
+
+
+
+
+
+ Change Currency
+ ir.actions.act_window
+ account.change.currency
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+ Change Currency
+ client_action_multi
+
+ action
+ account.invoice
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py
index 7def37807c3..38f47114490 100644
--- a/addons/account/wizard/account_chart.py
+++ b/addons/account/wizard/account_chart.py
@@ -21,7 +21,6 @@
from osv import fields, osv
from tools.translate import _
-import tools
class account_chart(osv.osv_memory):
"""
diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py
new file mode 100644
index 00000000000..c71c85ea4a3
--- /dev/null
+++ b/addons/account/wizard/account_fiscalyear_close.py
@@ -0,0 +1,228 @@
+# -*- 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(osv.osv_memory):
+ """
+ Closes Account Fiscalyear and Generate Opening entries for New Fiscalyear
+ """
+ _name = "account.fiscalyear.close"
+ _description = "Fiscalyear Close"
+ _columns = {
+ 'fy_id': fields.many2one('account.fiscalyear', \
+ 'Fiscal Year to close', required=True),
+ 'fy2_id': fields.many2one('account.fiscalyear', \
+ 'New Fiscal Year', required=True),
+ 'journal_id': fields.many2one('account.journal', \
+ 'Opening Entries Journal', required=True),
+ 'period_id': fields.many2one('account.period', \
+ 'Opening Entries Period', required=True),
+ 'report_name': fields.char('Name of new entries',size=64, required=True),
+ 'sure': fields.boolean('Check this box'),
+ }
+ _defaults = {
+ 'report_name':'End of Fiscal Year Entry',
+ }
+
+ def data_save(self, cr, uid, ids, context=None):
+ """
+ This function close account fiscalyear and create entries in new 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
+
+ """
+ obj_acc_period = self.pool.get('account.period')
+ obj_acc_fiscalyear = self.pool.get('account.fiscalyear')
+ obj_acc_journal = self.pool.get('account.journal')
+ obj_acc_move_line = self.pool.get('account.move.line')
+ obj_acc_account = self.pool.get('account.account')
+ obj_acc_journal_period = self.pool.get('account.journal.period')
+
+ data = self.read(cr, uid, ids, context=context)
+
+ if context is None:
+ context = {}
+ if not data[0]['sure']:
+ raise osv.except_osv(_('UserError'), _('Closing of fiscal year cancelled, please check the box !'))
+ fy_id = data[0]['fy_id']
+
+
+ period_ids = obj_acc_period.search(cr, uid, [('fiscalyear_id', '=', fy_id)])
+ periods_fy2 = obj_acc_period.search(cr, uid, [('fiscalyear_id', '=', data[0]['fy2_id'])])
+
+ period = obj_acc_period.browse(cr, uid, data[0]['period_id'], context=context)
+ new_fyear = obj_acc_fiscalyear.browse(cr, uid, data[0]['fy2_id'], context=context)
+ old_fyear = obj_acc_fiscalyear.browse(cr, uid, data[0]['fy_id'], context=context)
+
+ new_journal = data[0]['journal_id']
+ new_journal = obj_acc_journal.browse(cr, uid, new_journal, context=context)
+
+ if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
+ raise osv.except_osv(_('UserError'),
+ _('The journal must have default credit and debit account'))
+ if not new_journal.centralisation:
+ raise osv.except_osv(_('UserError'),
+ _('The journal must have centralised counterpart'))
+
+ move_ids = obj_acc_move_line.search(cr, uid, [
+ ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)])
+ if move_ids:
+ raise osv.except_osv(_('UserError'),
+ _('The opening journal must not have any entry in the new fiscal year !'))
+ query = "SELECT id FROM account_fiscalyear WHERE date_stop < '" + str(new_fyear.date_start) + "'"
+ cr.execute(query)
+ result = cr.dictfetchall()
+ fy_ids = ','.join([str(x['id']) for x in result])
+ query_line = obj_acc_move_line._query_get(cr, uid,
+ obj='account_move_line', context={'fiscalyear': fy_ids})
+ cr.execute('select id from account_account WHERE active')
+ ids = map(lambda x: x[0], cr.fetchall())
+ for account in obj_acc_account.browse(cr, uid, ids,
+ context={'fiscalyear': fy_id}):
+
+ accnt_type_data = account.user_type
+ if not accnt_type_data:
+ continue
+ if accnt_type_data.close_method=='none' or account.type == 'view':
+ continue
+ if accnt_type_data.close_method=='balance':
+ if abs(account.balance)>0.0001:
+ obj_acc_move_line.create(cr, uid, {
+ 'debit': account.balance>0 and account.balance,
+ 'credit': account.balance<0 and -account.balance,
+ 'name': data[0]['report_name'],
+ 'date': period.date_start,
+ 'journal_id': new_journal.id,
+ 'period_id': period.id,
+ 'account_id': account.id
+ }, {'journal_id': new_journal.id, 'period_id':period.id})
+ if accnt_type_data.close_method == 'unreconciled':
+ offset = 0
+ limit = 100
+ while True:
+ cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
+ 'amount_currency, currency_id, blocked, partner_id, ' \
+ 'date_maturity, date_created ' \
+ 'FROM account_move_line ' \
+ 'WHERE account_id = %s ' \
+ 'AND ' + query_line + ' ' \
+ 'AND reconcile_id is NULL ' \
+ 'ORDER BY id ' \
+ 'LIMIT %s OFFSET %s', (account.id, limit, offset))
+ result = cr.dictfetchall()
+ if not result:
+ break
+ for move in result:
+ move.pop('id')
+ move.update({
+ 'date': period.date_start,
+ 'journal_id': new_journal.id,
+ 'period_id': period.id,
+ })
+ obj_acc_move_line.create(cr, uid, move, {
+ 'journal_id': new_journal.id,
+ 'period_id': period.id,
+ })
+ offset += limit
+
+ #We have also to consider all move_lines that were reconciled
+ #on another fiscal year, and report them too
+ offset = 0
+ limit = 100
+ while True:
+ #TODO: this query could be improved in order to work if there is more than 2 open FY
+ # a.period_id IN ('+fy2_period_set+') is the problematic clause
+ cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \
+ 'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \
+ 'b.date_maturity, b.date_created ' \
+ 'FROM account_move_line a, account_move_line b ' \
+ 'WHERE b.account_id = %s ' \
+ 'AND b.reconcile_id is NOT NULL ' \
+ 'AND a.reconcile_id = b.reconcile_id ' \
+ 'AND b.period_id =ANY(%s)'\
+ 'AND a.period_id =ANY(%s)' \
+ 'ORDER BY id ' \
+ 'LIMIT %s OFFSET %s', (account.id,period_ids,periods_fy2,limit, offset))
+ result = cr.dictfetchall()
+ if not result:
+ break
+ for move in result:
+ move.pop('id')
+ move.update({
+ 'date': period.date_start,
+ 'journal_id': new_journal.id,
+ 'period_id': period.id,
+ })
+ obj_acc_move_line.create(cr, uid, move, {
+ 'journal_id': new_journal.id,
+ 'period_id': period.id,
+ })
+ offset += limit
+ if accnt_type_data.close_method=='detail':
+ offset = 0
+ limit = 100
+ while True:
+ cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
+ 'amount_currency, currency_id, blocked, partner_id, ' \
+ 'date_maturity, date_created ' \
+ 'FROM account_move_line ' \
+ 'WHERE account_id = %s ' \
+ 'AND ' + query_line + ' ' \
+ 'ORDER BY id ' \
+ 'LIMIT %s OFFSET %s', (account.id, limit, offset))
+
+ result = cr.dictfetchall()
+ if not result:
+ break
+ for move in result:
+ move.pop('id')
+ move.update({
+ 'date': period.date_start,
+ 'journal_id': new_journal.id,
+ 'period_id': period.id,
+ })
+ obj_acc_move_line.create(cr, uid, move)
+ offset += limit
+ ids = obj_acc_move_line.search(cr, uid, [('journal_id','=',new_journal.id),
+ ('period_id.fiscalyear_id','=',new_fyear.id)])
+ context['fy_closing'] = True
+
+ if ids:
+ obj_acc_move_line.reconcile(cr, uid, ids, context=context)
+ new_period = data[0]['period_id']
+ ids = obj_acc_journal_period.search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)])
+ if not ids:
+ ids = [obj_acc_journal_period.create(cr, uid, {
+ 'name': (new_journal.name or '')+':'+(period.code or ''),
+ 'journal_id': new_journal.id,
+ 'period_id': period.id
+ })]
+ cr.execute('UPDATE account_fiscalyear ' \
+ 'SET end_journal_period_id = %s ' \
+ 'WHERE id = %s', (ids[0], old_fyear.id))
+ return {}
+
+account_fiscalyear_close()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_fiscalyear_close_view.xml b/addons/account/wizard/account_fiscalyear_close_view.xml
new file mode 100644
index 00000000000..e8db5193275
--- /dev/null
+++ b/addons/account/wizard/account_fiscalyear_close_view.xml
@@ -0,0 +1,47 @@
+
+
+
+
+ account.fiscalyear.close.form
+ account.fiscalyear.close
+ form
+
+
+
+
+
+
+ Generate Fiscal Year Opening Entries
+ account.fiscalyear.close
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
diff --git a/addons/account/wizard/account_general_journal.py b/addons/account/wizard/account_general_journal.py
new file mode 100644
index 00000000000..56ad7375acf
--- /dev/null
+++ b/addons/account/wizard/account_general_journal.py
@@ -0,0 +1,60 @@
+# -*- 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 osv, fields
+from tools.translate import _
+
+class account_general_journal(osv.osv_memory):
+ _name = 'account.general.journal'
+ _description = 'Account General Journal'
+
+ _columns = {
+ 'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
+ 'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
+ }
+
+ def check_data(self, cr, uid, ids, context={}):
+ obj_jperiod = self.pool.get('account.journal.period')
+ datas = {}
+ datas['ids'] = []
+ datas['model'] = 'account.journal.period'
+ datas['form'] = self.read(cr, uid, ids)[0]
+ period_id = datas['form']['period_id']
+ journal_id = datas['form']['journal_id']
+
+ if type(period_id)==type([]):
+ ids_final = []
+ for journal in journal_id:
+ for period in period_id:
+ ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context)
+ if ids_journal_period:
+ ids_final.append(ids_journal_period)
+ if not ids_final:
+ raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'account.general.journal',
+ 'datas': datas,
+ }
+
+account_general_journal()
+
+#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_general_journal_view.xml b/addons/account/wizard/account_general_journal_view.xml
new file mode 100644
index 00000000000..425efbaf847
--- /dev/null
+++ b/addons/account/wizard/account_general_journal_view.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+ Account Genral Journal
+ account.general.journal
+ form
+
+
+
+
+
+
+ Account General Journal
+ ir.actions.act_window
+ account.general.journal
+ form
+ 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
index cc69311b2f7..1942fd56e60 100644
--- a/addons/account/wizard/account_invoice_refund.py
+++ b/addons/account/wizard/account_invoice_refund.py
@@ -18,13 +18,10 @@
# 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."""
diff --git a/addons/account/wizard/wizard_journal_select.py b/addons/account/wizard/account_journal_select.py
similarity index 50%
rename from addons/account/wizard/wizard_journal_select.py
rename to addons/account/wizard/account_journal_select.py
index 123a07fb627..f13958ed90f 100644
--- a/addons/account/wizard/wizard_journal_select.py
+++ b/addons/account/wizard/account_journal_select.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,37 +15,37 @@
# 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
-import pooler
+from osv import fields, osv
-def _action_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')
+class account_journal_select(osv.osv_memory):
+ """
+ Account Journal Select
+ """
+ _name = "account.journal.select"
+ _description = "Account Journal Select"
- result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_select')
- id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
- result = act_obj.read(cr, uid, [id])[0]
+ def action_open_window(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ if context is None:
+ context = {}
- cr.execute('select journal_id,period_id from account_journal_period where id=%s', (data['id'],))
- journal_id,period_id = cr.fetchone()
+ result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_select')
+ id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
+ result = act_obj.read(cr, uid, [id])[0]
+ cr.execute('select journal_id, period_id from account_journal_period where id=%s', (context['active_id'],))
+ journal_id, period_id = cr.fetchone()
- result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)])
- result['context'] = str({'journal_id': journal_id, 'period_id': period_id})
- return result
+ result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)])
+ result['context'] = str({'journal_id': journal_id, 'period_id': period_id})
+ return result
-class wiz_journal(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-wiz_journal('account.move.journal.select')
+account_journal_select()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_journal_select_view.xml b/addons/account/wizard/account_journal_select_view.xml
new file mode 100644
index 00000000000..71a0d591768
--- /dev/null
+++ b/addons/account/wizard/account_journal_select_view.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ Open Journal Button
+ account.journal.select
+ form
+
+
+
+
+
+
+ Open Journal
+ account.journal.select
+ form
+ form
+
+ new
+
+
+
+ tree_but_open
+ account.journal.period
+ Open Journal
+
+
+
+
+
diff --git a/addons/account/wizard/account_move_line_reconcile_select.py b/addons/account/wizard/account_move_line_reconcile_select.py
index db0ddb10108..d089db01f5e 100644
--- a/addons/account/wizard/account_move_line_reconcile_select.py
+++ b/addons/account/wizard/account_move_line_reconcile_select.py
@@ -18,11 +18,8 @@
# 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"
@@ -41,17 +38,16 @@ class account_move_line_reconcile_select(osv.osv_memory):
@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'
- }
+ data = self.read(cr, uid, ids, context=context)[0]
+ 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()
diff --git a/addons/account/wizard/account_move_line_reconcile_select_view.xml b/addons/account/wizard/account_move_line_reconcile_select_view.xml
index f7fcccddc4c..ae7f9567748 100644
--- a/addons/account/wizard/account_move_line_reconcile_select_view.xml
+++ b/addons/account/wizard/account_move_line_reconcile_select_view.xml
@@ -15,7 +15,7 @@
@@ -23,7 +23,7 @@
- Reconcile entries
+ Reconcile Entries
account.move.line.reconcile.select
form
tree,form
diff --git a/addons/account/wizard/account_move_line_unreconcile_select.py b/addons/account/wizard/account_move_line_unreconcile_select.py
index 07fd0017742..1c44e8548bd 100644
--- a/addons/account/wizard/account_move_line_unreconcile_select.py
+++ b/addons/account/wizard/account_move_line_unreconcile_select.py
@@ -30,20 +30,19 @@ class account_move_line_unreconcile_select(osv.osv_memory):
_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'
- }
+ data = self.read(cr, uid, ids, context=context)[0]
+ 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()
diff --git a/addons/account/wizard/account_move_line_unreconcile_select_view.xml b/addons/account/wizard/account_move_line_unreconcile_select_view.xml
index 06c0a0d1e0e..7d10c02f010 100644
--- a/addons/account/wizard/account_move_line_unreconcile_select_view.xml
+++ b/addons/account/wizard/account_move_line_unreconcile_select_view.xml
@@ -15,7 +15,7 @@
@@ -23,7 +23,7 @@
- Unreconcile entries
+ Unreconcile Entries
account.move.line.unreconcile.select
form
tree,form
diff --git a/addons/account/wizard/account_open_closed_fiscalyear.py b/addons/account/wizard/account_open_closed_fiscalyear.py
new file mode 100644
index 00000000000..b4f0f12b4b8
--- /dev/null
+++ b/addons/account/wizard/account_open_closed_fiscalyear.py
@@ -0,0 +1,55 @@
+# -*- 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 account_open_closed_fiscalyear(osv.osv_memory):
+
+ _name = "account.open.closed.fiscalyear"
+ _description = "Choose Fiscal Year"
+ _columns = {
+ 'fyear_id': fields.many2one('account.fiscalyear', \
+ 'Fiscal Year to Open', required=True, help='Select Fiscal Year which you want to remove entries for its End of year entries journal'),
+ }
+
+ def remove_entries(self, cr, uid, ids, context={}):
+ data = self.read(cr, uid, ids, [])[0]
+ data_fyear = self.pool.get('account.fiscalyear').browse(cr, uid, data['fyear_id'])
+ if not data_fyear.end_journal_period_id:
+ raise osv.except_osv(_('Error'), _('No journal for ending writing has been defined for the fiscal year'))
+ period_journal = data_fyear.end_journal_period_id
+ ids_move = self.pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
+ if ids_move:
+ cr.execute('delete from account_move where id =ANY(%s)',(ids_move,))
+ #cr.execute('UPDATE account_journal_period ' \
+ # 'SET state = %s ' \
+ # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
+ # ('draft',data_fyear))
+ #cr.execute('UPDATE account_period SET state = %s ' \
+ # 'WHERE fiscalyear_id = %s', ('draft',data_fyear))
+ #cr.execute('UPDATE account_fiscalyear ' \
+ # 'SET state = %s, end_journal_period_id = null '\
+ # 'WHERE id = %s', ('draft',data_fyear))
+ return {}
+
+account_open_closed_fiscalyear()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_open_closed_fiscalyear_view.xml b/addons/account/wizard/account_open_closed_fiscalyear_view.xml
new file mode 100644
index 00000000000..c5269939e0c
--- /dev/null
+++ b/addons/account/wizard/account_open_closed_fiscalyear_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ account.open.closed.fiscalyear.form
+ account.open.closed.fiscalyear
+ form
+
+
+
+
+
+
+ Cancel Opening Entries
+ account.open.closed.fiscalyear
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_pay_invoice.py b/addons/account/wizard/account_pay_invoice.py
new file mode 100644
index 00000000000..0b71055409f
--- /dev/null
+++ b/addons/account/wizard/account_pay_invoice.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 .
+#
+##############################################################################
+import time
+
+from osv import fields, osv
+from tools.translate import _
+import decimal_precision as dp
+
+class account_invoice_pay_writeoff(osv.osv_memory):
+ """
+ Opens the write off amount pay form.
+ """
+ _name = "account.invoice.pay.writeoff"
+ _description = "Pay Invoice "
+ _columns = {
+ 'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', required=True),
+ 'writeoff_journal_id': fields.many2one('account.journal', 'Write-Off journal', required=True),
+ 'comment': fields.char('Comment', size=64, required=True),
+ 'analytic_id': fields.many2one('account.analytic.account','Analytic Account'),
+ }
+ _defaults = {
+ 'comment': 'Write-Off',
+ }
+
+ def pay_and_reconcile_writeoff(self, cr, uid, ids, context=None):
+ data = self.read(cr, uid, ids,context=context)[0]
+ context.update({'write_off':data})
+ self.pool.get('account.invoice.pay').pay_and_reconcile(cr, uid, ids, context=context)
+ return {}
+
+account_invoice_pay_writeoff()
+
+class account_invoice_pay(osv.osv_memory):
+ """
+ Generate pay invoice wizard, user can make partial or full payment for invoice.
+ """
+ _name = "account.invoice.pay"
+ _description = "Pay Invoice "
+ _columns = {
+ 'amount': fields.float('Amount paid', required=True, digits_compute = dp.get_precision('Account')),
+ 'name': fields.char('Entry Name', size=64, required=True),
+ 'date': fields.date('Date payment', required=True),
+ 'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
+ 'period_id': fields.many2one('account.period', 'Period', required=True),
+ }
+
+ def view_init(self, cr, uid, ids, context=None):
+ invoice = self.pool.get('account.invoice').browse(cr, uid, context['active_id'], context=context)
+ if invoice.state in ['draft', 'proforma2', 'cancel']:
+ raise osv.except_osv(_('Error !'), _('Can not pay draft/proforma/cancel invoice.'))
+ pass
+
+ def _get_period(self, cr, uid, context=None):
+ 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 _get_amount(self, cr, uid, context=None):
+ return self.pool.get('account.invoice').browse(cr, uid, context['active_id'], context=context).residual
+
+ _defaults = {
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'period_id': _get_period,
+ 'amount': _get_amount,
+ }
+
+ def wo_check(self, cr, uid, ids, context=None):
+ cur_obj = self.pool.get('res.currency')
+ mod_obj = self.pool.get('ir.model.data')
+ if context is None:
+ context = {}
+ data = self.read(cr, uid, ids,context=context)[0]
+ invoice = self.pool.get('account.invoice').browse(cr, uid, context['active_id'], context)
+ journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context)
+
+ # Here we need that:
+ # The invoice total amount in company's currency <> paid amount in company currency
+ # (according to the correct day rate, invoicing rate and payment rate are may be different)
+ # => Ask to a write-off of the difference. This could happen even if both amount are equal,
+ # because if the currency rate
+ # Get the amount in company currency for the invoice (according to move lines)
+ inv_amount_company_currency = 0
+ for aml in invoice.move_id.line_id:
+ if aml.account_id.id == invoice.account_id.id or aml.account_id.type in ('receivable', 'payable'):
+ inv_amount_company_currency += aml.debit
+ inv_amount_company_currency -= aml.credit
+ inv_amount_company_currency = abs(inv_amount_company_currency)
+
+ # Get the current amount paid in company currency
+ if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
+ ctx = {'date':data['date']}
+ amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['amount'], round=True, context=ctx)
+ else:
+ amount_paid = data['amount']
+ # Get the old payment if there are some
+ if invoice.payment_ids:
+ debit=credit=0.0
+ for payment in invoice.payment_ids:
+ debit+=payment.debit
+ credit+=payment.credit
+ amount_paid+=abs(debit-credit)
+
+ # Test if there is a difference according to currency rouding setting
+ if self.pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id,
+ (amount_paid - inv_amount_company_currency)):
+ return self.pay_and_reconcile(cr, uid, ids, context=context)
+ else:
+ model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_invoice_pay_writeoff')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ return {
+ 'name': _('Information addendum'),
+ 'context': context,
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'account.invoice.pay.writeoff',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+ def pay_and_reconcile(self, cr, uid, ids, context=None):
+ cur_obj = self.pool.get('res.currency')
+ if context is None:
+ context = {}
+ data = self.read(cr, uid, ids,context=context)[0]
+ writeoff_account_id = False
+ writeoff_journal_id = False
+ comment = False
+
+ if 'write_off' in context and context['write_off'] :
+ writeoff_account_id = context['write_off']['writeoff_acc_id']
+ writeoff_journal_id = context['write_off']['writeoff_journal_id']
+ comment = context['write_off']['comment']
+
+ amount = data['amount']
+
+ invoice = self.pool.get('account.invoice').browse(cr, uid, context['active_id'], context)
+ journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context)
+ # Compute the amount in company's currency, with the journal currency (which is equal to payment currency)
+ # when it is needed : If payment currency (according to selected journal.currency) is <> from company currency
+ if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
+ ctx = {'date':data['date']}
+ amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
+ currency_id = journal.currency.id
+ # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
+ context.update({'amount_currency':data['amount'],'currency_id':currency_id})
+
+ if invoice.company_id.currency_id.id<>invoice.currency_id.id:
+ ctx = {'date':data['date']}
+ amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx)
+ currency_id = invoice.currency_id.id
+ # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
+ context.update({'amount_currency':data['amount'],'currency_id':currency_id})
+
+ # Take the choosen date
+ if comment:
+ context.update({'date_p':data['date'],'comment':comment})
+ else:
+ context.update({'date_p':data['date'],'comment':False})
+
+ acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
+ if not acc_id:
+ raise osv.except_osv(_('Error !'), _('Your journal must have a default credit and debit account.'))
+ self.pool.get('account.invoice').pay_and_reconcile(cr, uid, [context['active_id']],
+ amount, acc_id, data['period_id'], data['journal_id'], writeoff_account_id,
+ data['period_id'], writeoff_journal_id, context, data['name'])
+ return {}
+
+account_invoice_pay()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_pay_invoice_view.xml b/addons/account/wizard/account_pay_invoice_view.xml
new file mode 100644
index 00000000000..0a8e64d299f
--- /dev/null
+++ b/addons/account/wizard/account_pay_invoice_view.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ account.invoice.pay.form
+ account.invoice.pay
+ form
+
+
+
+
+
+
+
+
+
+ account.invoice.pay.writeoff.form
+ account.invoice.pay.writeoff
+ form
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py
index f4c54263f9a..6e71b079dc0 100644
--- a/addons/account/wizard/account_period_close.py
+++ b/addons/account/wizard/account_period_close.py
@@ -21,7 +21,6 @@
from osv import fields, osv
from tools.translate import _
-import tools
class account_period_close(osv.osv_memory):
"""
@@ -30,7 +29,7 @@ class account_period_close(osv.osv_memory):
_name = "account.period.close"
_description = "period close"
_columns = {
- 'sure': fields.boolean('Check this box', required=False),
+ 'sure': fields.boolean('Check this box'),
}
def data_save(self, cr, uid, ids, context={}):
@@ -47,8 +46,8 @@ class account_period_close(osv.osv_memory):
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 {}
+ return {}
account_period_close()
-# 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/account/wizard/account_print_journal.py b/addons/account/wizard/account_print_journal.py
new file mode 100644
index 00000000000..89de9a643f9
--- /dev/null
+++ b/addons/account/wizard/account_print_journal.py
@@ -0,0 +1,66 @@
+# -*- 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 osv, fields
+from tools.translate import _
+
+class account_print_journal(osv.osv_memory):
+ _name = 'account.print.journal'
+ _description = 'Account Print Journal'
+
+ _columns = {
+ 'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
+ 'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
+ 'sort_selection': fields.selection([('date','By date'),
+ ('ref','Reference Number'),],
+ 'Entries Sorted By', required=True),
+ }
+
+ _defaults = {
+ 'sort_selection': lambda *a: 'date',
+ }
+
+ def check_data(self, cr, uid, ids, context={}):
+ obj_jperiod = self.pool.get('account.journal.period')
+ datas = {}
+ datas['ids'] = []
+ datas['model'] = 'account.journal.period'
+ datas['form'] = self.read(cr, uid, ids)[0]
+ period_id = datas['form']['period_id']
+ journal_id = datas['form']['journal_id']
+
+ if type(period_id)==type([]):
+ ids_final = []
+ for journal in journal_id:
+ for period in period_id:
+ ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context)
+ if ids_journal_period:
+ ids_final.append(ids_journal_period)
+ if not ids_final:
+ raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'account.journal.period.print',
+ 'datas': datas,
+ }
+
+account_print_journal()
+
+#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_print_journal_view.xml b/addons/account/wizard/account_print_journal_view.xml
new file mode 100644
index 00000000000..078db421b19
--- /dev/null
+++ b/addons/account/wizard/account_print_journal_view.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+ Account Print Journal
+ account.print.journal
+ form
+
+
+
+
+
+
+ Account Print Journal
+ ir.actions.act_window
+ account.print.journal
+ form
+ form
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_state_open.py b/addons/account/wizard/account_state_open.py
new file mode 100644
index 00000000000..4703ea18c61
--- /dev/null
+++ b/addons/account/wizard/account_state_open.py
@@ -0,0 +1,44 @@
+# -*- 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 osv, fields
+
+import netsvc
+from tools.translate import _
+
+class account_state_open(osv.osv_memory):
+ _name = 'account.state.open'
+ _description = 'Account State Open'
+
+ def change_inv_state(self, cr, uid, ids, context=None):
+ obj_invoice = self.pool.get('account.invoice')
+ if context is None:
+ context = {}
+ if 'active_ids' in context:
+ data_inv = obj_invoice.browse(cr, uid, context['active_ids'][0], context=context)
+ if data_inv.reconciled:
+ raise osv.except_osv(_('Warning'), _('Invoice is already reconciled'))
+ wf_service = netsvc.LocalService("workflow")
+ res = wf_service.trg_validate(uid, 'account.invoice', context['active_ids'][0], 'open_test', cr)
+ return {}
+
+account_state_open()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_state_open_view.xml b/addons/account/wizard/account_state_open_view.xml
new file mode 100644
index 00000000000..3ed71949b2a
--- /dev/null
+++ b/addons/account/wizard/account_state_open_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+ Account State Open
+ account.state.open
+ form
+
+
+
+
+
+
+ Account State Open
+ ir.actions.act_window
+ account.state.open
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account/wizard/account_statement_from_invoice.py b/addons/account/wizard/account_statement_from_invoice.py
new file mode 100644
index 00000000000..097d11c1b83
--- /dev/null
+++ b/addons/account/wizard/account_statement_from_invoice.py
@@ -0,0 +1,163 @@
+# -*- 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
+from tools.translate import _
+
+class account_statement_from_invoice_lines(osv.osv_memory):
+ """
+ Generate Entries by Statement from Invoices
+ """
+ _name = "account.statement.from.invoice.lines"
+ _description = "Entries by Statement from Invoices"
+ _columns = {
+ 'line_ids': fields.many2many('account.move.line', 'account_move_line_relation', 'move_id', 'line_id', 'Invoices'),
+ }
+
+ def populate_statement(self, cr, uid, ids, context=None):
+
+ line_obj = self.pool.get('account.move.line')
+ statement_obj = self.pool.get('account.bank.statement')
+ statement_line_obj = self.pool.get('account.bank.statement.line')
+ currency_obj = self.pool.get('res.currency')
+ statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
+
+ data = self.read(cr, uid, ids,context=context)[0]
+ line_ids = data['line_ids']
+ line_date = time.strftime('%Y-%m-%d')
+
+ if not line_ids:
+ return {}
+ statement_id = 'statement_id' in context and context['statement_id']
+ statement = statement_obj.browse(cr, uid, statement_id, context=context)
+ # for each selected move lines
+ for line in line_obj.browse(cr, uid, line_ids, context=context):
+ ctx = context.copy()
+ # take the date for computation of currency => use payment date
+ # if line.date_maturity:
+ # ctx['date'] = line.date_maturity
+ # else:
+ ctx['date'] = line_date
+ amount = 0.0
+ if line.amount_currency:
+ amount = currency_obj.compute(cr, uid, line.currency_id.id,
+ statement.currency.id, line.amount_currency, context=ctx)
+ else:
+ if line.debit > 0:
+ amount=line.debit
+ elif line.credit > 0:
+ amount=-line.credit
+ reconcile_id = statement_reconcile_obj.create(cr, uid, {
+ 'line_ids': [(6, 0, [line.id])]
+ }, context=context)
+ if line.journal_id.type == 'sale':
+ type = 'customer'
+ elif line.journal_id.type == 'purchase':
+ type = 'supplier'
+ else:
+ type = 'general'
+ statement_line_obj.create(cr, uid, {
+ 'name': line.name or '?',
+ 'amount': amount,
+ 'type': type,
+ 'partner_id': line.partner_id.id,
+ 'account_id': line.account_id.id,
+ 'statement_id': statement_id,
+ 'ref': line.ref,
+ 'reconcile_id': reconcile_id,
+ 'date': time.strftime('%Y-%m-%d'), #time.strftime('%Y-%m-%d'), #line.date_maturity or,
+ }, context=context)
+ return {}
+
+account_statement_from_invoice_lines()
+
+class account_statement_from_invoice(osv.osv_memory):
+ """
+ Generate Entries by Statement from Invoices
+ """
+ _name = "account.statement.from.invoice"
+ _description = "Entries by Statement from Invoices"
+ _columns = {
+ 'date': fields.date('Date payment',required=True),
+ 'journal_ids': fields.many2many('account.journal','account_journal_relation','account_id','journal_id','Journal'),
+ 'line_ids': fields.many2many('account.move.line','account_move_line_relation','move_id','line_id','Invoices'),
+ }
+ _defaults = {
+ 'date':lambda *a: time.strftime('%Y-%m-%d'),
+ }
+
+ def search_invoices(self, cr, uid, ids, context=None):
+
+ line_obj = self.pool.get('account.move.line')
+ statement_obj = self.pool.get('account.bank.statement')
+ journal_obj = self.pool.get('account.journal')
+ mod_obj = self.pool.get('ir.model.data')
+ statement_id = 'statement_id' in context and context['statement_id']
+
+ data = self.read(cr, uid, ids,context=context)[0]
+ statement = statement_obj.browse(cr, uid, statement_id, context=context)
+ args_move_line = []
+ repeated_move_line_ids = []
+ # Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again)
+ for st_line in statement.line_ids:
+ args_move_line = []
+ args_move_line.append(('name','=', st_line.name))
+ args_move_line.append(('ref','=',st_line.ref))
+ if st_line.partner_id:
+ args_move_line.append(('partner_id','=',st_line.partner_id.id))
+ args_move_line.append(('account_id','=',st_line.account_id.id))
+
+ move_line_id = line_obj.search(cr, uid, args_move_line,context=context)
+ if move_line_id:
+ repeated_move_line_ids += move_line_id
+
+ journal_ids = data['journal_ids']
+ if journal_ids == []:
+ journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context)
+
+ args = [
+ ('reconcile_id', '=', False),
+ ('journal_id', 'in', journal_ids),
+ ('account_id.reconcile', '=', True)]
+
+ if repeated_move_line_ids:
+ args.append(('id','not in',repeated_move_line_ids))
+
+ line_ids = line_obj.search(cr, uid, args,
+ #order='date DESC, id DESC', #doesn't work
+ context=context)
+ model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_account_statement_from_invoice_lines')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ return {
+ 'domain': "[('id','in', ["+','.join([str(x) for x in line_ids])+"])]",
+ 'name': _('Import Entries'),
+ 'context': context,
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'account.statement.from.invoice.lines',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+account_statement_from_invoice()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/wizard/account_statement_from_invoice_view.xml b/addons/account/wizard/account_statement_from_invoice_view.xml
new file mode 100644
index 00000000000..6f17279888c
--- /dev/null
+++ b/addons/account/wizard/account_statement_from_invoice_view.xml
@@ -0,0 +1,61 @@
+
+
+
+
+ account.statement.from.invoice.form
+ account.statement.from.invoice
+ form
+
+
+
+
+
+
+ Import Invoices in Statement
+ account.statement.from.invoice
+ form
+ tree,form
+
+ new
+
+
+
+ account.statement.from.invoice.lines.form
+ account.statement.from.invoice.lines
+ form
+
+
+
+
+
+ Import Entries
+ account.statement.from.invoice.lines
+ form
+ tree,form
+
+ new
+
+
+
+
+
diff --git a/addons/account/wizard/account_validate_account_move.py b/addons/account/wizard/account_validate_account_move.py
new file mode 100644
index 00000000000..e3d9e494da6
--- /dev/null
+++ b/addons/account/wizard/account_validate_account_move.py
@@ -0,0 +1,67 @@
+# -*- 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 validate_account_move(osv.osv_memory):
+ _name = "validate.account.move"
+ _description = "Validate Account Move"
+ _columns = {
+ 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
+ 'period_id': fields.many2one('account.period', 'Period', required=True, domain=[('state','<>','done')]),
+ }
+
+ def validate_move(self, cr, uid, ids, context=None):
+ obj_move = self.pool.get('account.move')
+ if context is None:
+ context = {}
+ data = self.read(cr, uid, ids)[0]
+ ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','=',data['journal_id']),('period_id','=',data['period_id'])])
+ if not ids_move:
+ raise osv.except_osv(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
+ obj_move.button_validate(cr, uid, ids_move, context)
+ return {}
+
+validate_account_move()
+
+class validate_account_move_lines(osv.osv_memory):
+ _name = "validate.account.move.lines"
+ _description = "Validate Account Move Lines"
+
+ def validate_move_lines(self, cr, uid, ids, context=None):
+ obj_move_line = self.pool.get('account.move.line')
+ obj_move = self.pool.get('account.move')
+ move_ids = []
+ if context is None:
+ context = {}
+ data_line = obj_move_line.browse(cr, uid, context['active_ids'], context)
+ for line in data_line:
+ if line.move_id.state=='draft':
+ move_ids.append(line.move_id.id)
+ move_ids = list(set(move_ids))
+ if not move_ids:
+ raise osv.except_osv(_('Warning'), _('Selected Entry Lines does not have any account move enties in draft state'))
+ obj_move.button_validate(cr, uid, move_ids, context)
+ return {}
+validate_account_move_lines()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/account/wizard/account_validate_move_view.xml b/addons/account/wizard/account_validate_move_view.xml
new file mode 100644
index 00000000000..dd116ca478c
--- /dev/null
+++ b/addons/account/wizard/account_validate_move_view.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+ Validate Account Move
+ validate.account.move
+ form
+
+
+
+
+
+
+ Open Journal
+ validate.account.move
+ form
+ form
+
+ new
+
+
+
+
+
+
+ Validate Ledger Postings
+ validate.account.move.lines
+ form
+
+
+
+
+
+
+ Validate Ledger Postings
+ ir.actions.act_window
+ validate.account.move.lines
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+ Validate Ledger Postings
+ client_action_multi
+
+ action
+ account.move.line
+
+
+
+
diff --git a/addons/account/wizard/account_vat.py b/addons/account/wizard/account_vat.py
new file mode 100755
index 00000000000..7e641628daf
--- /dev/null
+++ b/addons/account/wizard/account_vat.py
@@ -0,0 +1,64 @@
+# -*- 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 osv, fields
+
+class account_vat_declaration(osv.osv_memory):
+ _name = 'account.vat.declaration'
+ _description = 'Account Vat Declaration'
+
+ _columns = {
+ 'based_on': fields.selection([('invoices','Invoices'),
+ ('payments','Payments'),],
+ 'Based On', required=True),
+ 'company_id': fields.many2one('res.company', 'Company', required=True),
+ 'periods': fields.many2many('account.period', 'vat_period_rel', 'vat_id', 'period_id', 'Periods', help="All periods if empty"),
+ }
+
+ def _get_company(self, cr, uid, ids, context={}):
+ user_obj = self.pool.get('res.users')
+ company_obj = self.pool.get('res.company')
+ user = user_obj.browse(cr, uid, uid, context=context)
+ if user.company_id:
+ return user.company_id.id
+ else:
+ return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
+
+ _defaults = {
+ 'based_on': lambda *a: 'invoices',
+ 'company_id': _get_company
+ }
+
+ def create_vat(self, cr, uid, ids, context={}):
+ if context is None:
+ context = {}
+ datas = {'ids': context.get('active_ids', [])}
+ datas['model'] = 'account.tax.code'
+ datas['form'] = self.read(cr, uid, ids)[0]
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'account.vat.declaration',
+ 'datas': datas,
+ }
+
+account_vat_declaration()
+
+#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_vat_view.xml b/addons/account/wizard/account_vat_view.xml
new file mode 100644
index 00000000000..edd6eaf7874
--- /dev/null
+++ b/addons/account/wizard/account_vat_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+ Account Vat Declaration
+ account.vat.declaration
+ form
+
+
+
+
+
+
+ Account Vat Declaration
+ ir.actions.act_window
+ account.vat.declaration
+ form
+ form
+ new
+
+
+
+
+
+
diff --git a/addons/account/wizard/wizard_central_journal.py b/addons/account/wizard/wizard_central_journal.py
deleted file mode 100644
index 32fb02f3230..00000000000
--- a/addons/account/wizard/wizard_central_journal.py
+++ /dev/null
@@ -1,72 +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
-from tools.translate import _
-
-form = '''
-'''
-
-fields = {
- 'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True},
- 'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
-}
-
-
-def _check_data(self, cr, uid, data, *args):
- period_id = data['form']['period_id'][0][2]
- journal_id=data['form']['journal_id'][0][2]
-
- if type(period_id)==type([]):
-
- ids_final = []
-
- for journal in journal_id:
- for period in period_id:
- ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
-
- if ids_journal_period:
- ids_final.append(ids_journal_period)
-
- if not ids_final:
- raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
- return data['form']
-
-
-class wizard_print_journal(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-ok'))},
- },
- 'print': {
- 'actions': [_check_data],
- 'result': {'type':'print', 'report':'account.central.journal.wiz', 'state':'end'},
- },
- }
-wizard_print_journal('account.central.journal.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_change_currency.py b/addons/account/wizard/wizard_change_currency.py
deleted file mode 100644
index 45b23e49022..00000000000
--- a/addons/account/wizard/wizard_change_currency.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env python
-# -*- encoding: 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_change_currency(wizard.interface):
- '''
- OpenERP Wizard
- '''
- form = '''
- '''
-
- message = '''
- '''
-
- fields = {
- 'currency_id': {'string': 'New Currency', 'type': 'many2one', 'relation': 'res.currency', 'required':True},
- }
-
- def _get_defaults(self, cr, user, data, context):
- #TODO : initlize required data
-
- return data['form']
-
- def _change_currency(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
-
- inv_obj = pool.get('account.invoice')
- inv_line_obj = pool.get('account.invoice.line')
- curr_obj = pool.get('res.currency')
-
- invoice_ids = data['ids']
- new_currency = data['form']['currency_id']
-
- for invoice in inv_obj.browse(cr, uid, invoice_ids, context=context):
- if invoice.currency_id.id == new_currency:
- continue
-
- for line in invoice.invoice_line:
- rate = curr_obj.browse(cr, uid, new_currency).rate
- new_price = 0
- if invoice.company_id.currency_id.id == invoice.currency_id.id:
- new_price = line.price_unit * rate
-
- if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
- old_rate = invoice.currency_id.rate
- new_price = line.price_unit / old_rate
-
- if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
- old_rate = invoice.currency_id.rate
- new_price = (line.price_unit / old_rate ) * rate
-
- inv_line_obj.write(cr, uid, [line.id], {'price_unit':new_price})
- inv_obj.write(cr, uid, [invoice.id], {'currency_id':new_currency})
- return {}
-
- def _check_what_next(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- inv_obj = pool.get('account.invoice')
- if inv_obj.browse(cr, uid, data['id']).state != 'draft':
- return 'message'
-
- return 'change'
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'choice', 'next_state': _check_what_next},
- },
- 'change': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('next', 'Change Currency', 'gtk-go-forward'))},
- },
- 'next': {
- 'actions': [_change_currency],
- 'result': {'type': 'state', 'state': 'end'},
- },
- 'message': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': message, 'fields': {}, 'state': [('end', 'Ok', 'gtk-cancel')]},
- },
- }
-wizard_change_currency('account.invoice.currency_change')
diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py
deleted file mode 100644
index cbf4b8d0529..00000000000
--- a/addons/account/wizard/wizard_fiscalyear_close.py
+++ /dev/null
@@ -1,228 +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')]},
- 'journal_id': {'string':'Opening Entries Journal', 'type':'many2one', 'relation': 'account.journal','required':True},
- 'period_id': {'string':'Opening Entries Period', 'type':'many2one', 'relation': 'account.period','required':True, 'domain':"[('fiscalyear_id','=',fy2_id)]"},
- 'fy2_id': {'string':'New Fiscal Year', 'type':'many2one', 'relation': 'account.fiscalyear', 'domain':[('state','=','draft')], 'required':True},
- 'report_name': {'string':'Name of new entries', 'type':'char', 'size': 64, 'required':True},
- 'sure': {'string':'Check this box', 'type':'boolean'},
-}
-
-def _data_load(self, cr, uid, data, context):
- data['form']['report_name'] = _('End of Fiscal Year Entry')
- return data['form']
-
-def _data_save(self, cr, uid, data, context):
- if not data['form']['sure']:
- raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !'))
- pool = pooler.get_pool(cr.dbname)
-
- fy_id = data['form']['fy_id']
- period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)])
- periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])])
-
- period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context)
- new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context)
- old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context)
-
- new_journal = data['form']['journal_id']
- new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context)
-
- if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
- raise wizard.except_wizard(_('UserError'),
- _('The journal must have default credit and debit account'))
- if not new_journal.centralisation:
- raise wizard.except_wizard(_('UserError'),
- _('The journal must have centralised counterpart'))
-
- move_ids = pool.get('account.move.line').search(cr, uid, [
- ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)])
- if move_ids:
- raise wizard.except_wizard(_('UserError'),
- _('The opening journal must not have any entry in the new fiscal year !'))
- query = "SELECT id FROM account_fiscalyear WHERE date_stop < '" + str(new_fyear.date_start) + "'"
- cr.execute(query)
- result = cr.dictfetchall()
- fy_ids = ','.join([str(x['id']) for x in result])
- query_line = pool.get('account.move.line')._query_get(cr, uid,
- obj='account_move_line', context={'fiscalyear': fy_ids})
- cr.execute('select id from account_account WHERE active')
- ids = map(lambda x: x[0], cr.fetchall())
- for account in pool.get('account.account').browse(cr, uid, ids,
- context={'fiscalyear': fy_id}):
-
- accnt_type_data = account.user_type
- if not accnt_type_data:
- continue
- if accnt_type_data.close_method=='none' or account.type == 'view':
- continue
- if accnt_type_data.close_method=='balance':
- if abs(account.balance)>0.0001:
- pool.get('account.move.line').create(cr, uid, {
- 'debit': account.balance>0 and account.balance,
- 'credit': account.balance<0 and -account.balance,
- 'name': data['form']['report_name'],
- 'date': period.date_start,
- 'journal_id': new_journal.id,
- 'period_id': period.id,
- 'account_id': account.id
- }, {'journal_id': new_journal.id, 'period_id':period.id})
- if accnt_type_data.close_method == 'unreconciled':
- offset = 0
- limit = 100
- while True:
- cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
- 'amount_currency, currency_id, blocked, partner_id, ' \
- 'date_maturity, date_created ' \
- 'FROM account_move_line ' \
- 'WHERE account_id = %s ' \
- 'AND ' + query_line + ' ' \
- 'AND reconcile_id is NULL ' \
- 'ORDER BY id ' \
- 'LIMIT %s OFFSET %s', (account.id, limit, offset))
- result = cr.dictfetchall()
- if not result:
- break
- for move in result:
- move.pop('id')
- move.update({
- 'date': period.date_start,
- 'journal_id': new_journal.id,
- 'period_id': period.id,
- })
- pool.get('account.move.line').create(cr, uid, move, {
- 'journal_id': new_journal.id,
- 'period_id': period.id,
- })
- offset += limit
-
- #We have also to consider all move_lines that were reconciled
- #on another fiscal year, and report them too
- offset = 0
- limit = 100
- while True:
- #TODO: this query could be improved in order to work if there is more than 2 open FY
- # a.period_id IN ('+fy2_period_set+') is the problematic clause
- cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \
- 'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \
- 'b.date_maturity, b.date_created ' \
- 'FROM account_move_line a, account_move_line b ' \
- 'WHERE b.account_id = %s ' \
- 'AND b.reconcile_id is NOT NULL ' \
- 'AND a.reconcile_id = b.reconcile_id ' \
- 'AND b.period_id =ANY(%s)'\
- 'AND a.period_id =ANY(%s)' \
- 'ORDER BY id ' \
- 'LIMIT %s OFFSET %s', (account.id,period_ids,periods_fy2,limit, offset))
- result = cr.dictfetchall()
- if not result:
- break
- for move in result:
- move.pop('id')
- move.update({
- 'date': period.date_start,
- 'journal_id': new_journal.id,
- 'period_id': period.id,
- })
- pool.get('account.move.line').create(cr, uid, move, {
- 'journal_id': new_journal.id,
- 'period_id': period.id,
- })
- offset += limit
- if accnt_type_data.close_method=='detail':
- offset = 0
- limit = 100
- while True:
- cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
- 'amount_currency, currency_id, blocked, partner_id, ' \
- 'date_maturity, date_created ' \
- 'FROM account_move_line ' \
- 'WHERE account_id = %s ' \
- 'AND ' + query_line + ' ' \
- 'ORDER BY id ' \
- 'LIMIT %s OFFSET %s', (account.id, limit, offset))
-
- result = cr.dictfetchall()
- if not result:
- break
- for move in result:
- move.pop('id')
- move.update({
- 'date': period.date_start,
- 'journal_id': new_journal.id,
- 'period_id': period.id,
- })
- pool.get('account.move.line').create(cr, uid, move)
- offset += limit
- ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id),
- ('period_id.fiscalyear_id','=',new_fyear.id)])
- context['fy_closing'] = True
-
- if ids:
- pool.get('account.move.line').reconcile(cr, uid, ids, context=context)
- new_period = data['form']['period_id']
- ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)])
- if not ids:
- ids = [pool.get('account.journal.period').create(cr, uid, {
- 'name': (new_journal.name or '')+':'+(period.code or ''),
- 'journal_id': new_journal.id,
- 'period_id': period.id
- })]
- cr.execute('UPDATE account_fiscalyear ' \
- 'SET end_journal_period_id = %s ' \
- 'WHERE id = %s', (ids[0], old_fyear.id))
- return {}
-
-class wiz_journal_close(wizard.interface):
- states = {
- 'init': {
- 'actions': [_data_load],
- 'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel', 'gtk-cancel'),('close','Create', 'gtk-ok')]}
- },
- 'close': {
- 'actions': [_data_save],
- 'result': {'type': 'state', 'state':'end'}
- }
- }
-wiz_journal_close('account.fiscalyear.close')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_general_journal.py b/addons/account/wizard/wizard_general_journal.py
deleted file mode 100644
index 26935aa80d6..00000000000
--- a/addons/account/wizard/wizard_general_journal.py
+++ /dev/null
@@ -1,70 +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
-from tools.translate import _
-
-form = '''
-'''
-
-fields = {
- 'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True},
- 'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
-}
-
-def _check_data(self, cr, uid, data, *args):
- period_id = data['form']['period_id'][0][2]
- journal_id=data['form']['journal_id'][0][2]
-
- if type(period_id)==type([]):
-
- ids_final = []
-
- for journal in journal_id:
- for period in period_id:
- ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
-
- if ids_journal_period:
- ids_final.append(ids_journal_period)
-
- if not ids_final:
- raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
- return data['form']
-
-class wizard_print_journal(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-ok'))},
- },
- 'print': {
- 'actions': [_check_data],
- 'result': {'type':'print', 'report':'account.general.journal.wiz', 'state':'end'},
- },
- }
-wizard_print_journal('account.general.journal.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_open_closed_fiscalyear.py b/addons/account/wizard/wizard_open_closed_fiscalyear.py
deleted file mode 100644
index 18ac86c8107..00000000000
--- a/addons/account/wizard/wizard_open_closed_fiscalyear.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-from osv import fields, osv
-from tools.translate import _
-
-form = """
-
-"""
-
-fields = {
- 'fyear_id': {'string': 'Fiscal Year to Open', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
-}
-
-def _remove_entries(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- data_fyear = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear_id'])
- if not data_fyear.end_journal_period_id:
- raise wizard.except_wizard(_('Error'), _('No journal for ending writing has been defined for the fiscal year'))
- period_journal = data_fyear.end_journal_period_id
- ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
- if ids_move:
- cr.execute('delete from account_move where id =ANY(%s)',(ids_move,))
- #cr.execute('UPDATE account_journal_period ' \
- # 'SET state = %s ' \
- # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
- # ('draft',data_fyear))
- #cr.execute('UPDATE account_period SET state = %s ' \
- # 'WHERE fiscalyear_id = %s', ('draft',data_fyear))
- #cr.execute('UPDATE account_fiscalyear ' \
- # 'SET state = %s, end_journal_period_id = null '\
- # 'WHERE id = %s', ('draft',data_fyear))
- return {}
-
-class open_closed_fiscal(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result': {
- 'type': 'form',
- 'arch': form,
- 'fields': fields,
- 'state':[('end','Cancel', 'gtk-cancel'),('open','Open', 'gtk-ok')]
- }
- },
- 'open': {
- 'actions': [],
- 'result': {
- 'type':'action',
- 'action':_remove_entries,
- 'state':'end'
- },
- },
- }
-open_closed_fiscal("account.open_closed_fiscalyear")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py
deleted file mode 100644
index f534a72a77f..00000000000
--- a/addons/account/wizard/wizard_pay_invoice.py
+++ /dev/null
@@ -1,188 +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
-import time
-from tools.translate import _
-import tools
-import decimal_precision as dp
-
-
-pay_form = '''
-'''
-
-pay_fields = {
- 'amount': {'string': 'Amount paid', 'type':'float', 'required':True, 'digits': (16,dp.get_precision('Account'))},
- 'name': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
- 'date': {'string': 'Payment date', 'type':'date', 'required':True, 'default':lambda *args: time.strftime('%Y-%m-%d')},
- 'journal_id': {'string': 'Journal/Payment Mode', 'type': 'many2one', 'relation':'account.journal', 'required':True, 'domain':[('type','=','cash')]},
- 'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
-}
-
-def _pay_and_reconcile(self, cr, uid, data, context):
- form = data['form']
- period_id = form.get('period_id', False)
- journal_id = form.get('journal_id', False)
- writeoff_account_id = form.get('writeoff_acc_id', False)
- writeoff_journal_id = form.get('writeoff_journal_id', False)
- pool = pooler.get_pool(cr.dbname)
- cur_obj = pool.get('res.currency')
- amount = form['amount']
- context['analytic_id'] = form.get('analytic_id', False)
-
- invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
- journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
- # Compute the amount in company's currency, with the journal currency (which is equal to payment currency)
- # when it is needed : If payment currency (according to selected journal.currency) is <> from company currency
- if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
- ctx = {'date':data['form']['date']}
- amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
- currency_id = journal.currency.id
- # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
- context.update({'amount_currency':form['amount'],'currency_id':currency_id})
-
- if invoice.company_id.currency_id.id<>invoice.currency_id.id:
- ctx = {'date':data['form']['date']}
- amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx)
- currency_id = invoice.currency_id.id
- # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
- context.update({'amount_currency':form['amount'],'currency_id':currency_id})
-
- # Take the choosen date
- if form.has_key('comment'):
- context.update({'date_p':form['date'],'comment':form['comment']})
- else:
- context.update({'date_p':form['date'],'comment':False})
-
- acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
- if not acc_id:
- raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.'))
- pool.get('account.invoice').pay_and_reconcile(cr, uid, [data['id']],
- amount, acc_id, period_id, journal_id, writeoff_account_id,
- period_id, writeoff_journal_id, context, data['form']['name'])
- return {}
-
-def _wo_check(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
- journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
- cur_obj = pool.get('res.currency')
- # Here we need that:
- # The invoice total amount in company's currency <> paid amount in company currency
- # (according to the correct day rate, invoicing rate and payment rate are may be different)
- # => Ask to a write-off of the difference. This could happen even if both amount are equal,
- # because if the currency rate
- # Get the amount in company currency for the invoice (according to move lines)
- inv_amount_company_currency = 0
- for aml in invoice.move_id.line_id:
- if aml.account_id.id == invoice.account_id.id or aml.account_id.type in ('receivable', 'payable'):
- inv_amount_company_currency += aml.debit
- inv_amount_company_currency -= aml.credit
- inv_amount_company_currency = abs(inv_amount_company_currency)
-
- # Get the current amount paid in company currency
- if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
- ctx = {'date':data['form']['date']}
- amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['form']['amount'], round=True, context=ctx)
- else:
- amount_paid = data['form']['amount']
- # Get the old payment if there are some
- if invoice.payment_ids:
- debit=credit=0.0
- for payment in invoice.payment_ids:
- debit+=payment.debit
- credit+=payment.credit
- amount_paid+=abs(debit-credit)
-
- # Test if there is a difference according to currency rouding setting
- if pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id,
- (amount_paid - inv_amount_company_currency)):
- return 'reconcile'
- return 'addendum'
-
-_transaction_add_form = '''
-'''
-
-_transaction_add_fields = {
- 'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
- 'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
- 'comment': {'string': 'Comment', 'type':'char', 'size': 64 , 'required':True},
- 'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
-}
-
-def _get_value_addendum(self, cr, uid, data, context={}):
- return {'comment': _('Write-Off')}
-
-def _get_period(self, cr, uid, data, context={}):
- pool = pooler.get_pool(cr.dbname)
- ids = pool.get('account.period').find(cr, uid, context=context)
- period_id = False
- if len(ids):
- period_id = ids[0]
- invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
- if invoice.state in ['draft', 'proforma2', 'cancel']:
- raise wizard.except_wizard(_('Error !'), _('Can not pay draft/proforma/cancel invoice.'))
- return {
- 'period_id': period_id,
- 'amount': invoice.residual,
- 'date': time.strftime('%Y-%m-%d')
- }
-
-class wizard_pay_invoice(wizard.interface):
- states = {
- 'init': {
- 'actions': [_get_period],
- 'result': {'type':'form', 'arch':pay_form, 'fields':pay_fields, 'state':[('end','Cancel'),('reconcile','Partial Payment'),('writeoff_check','Full Payment')]}
- },
- 'writeoff_check': {
- 'actions': [],
- 'result' : {'type': 'choice', 'next_state': _wo_check }
- },
- 'addendum': {
- 'actions': [_get_value_addendum],
- 'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Pay and reconcile')]}
- },
- 'reconcile': {
- 'actions': [_pay_and_reconcile],
- 'result': {'type':'state', 'state':'end'}
- }
- }
-wizard_pay_invoice('account.invoice.pay')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_print_journal.py b/addons/account/wizard/wizard_print_journal.py
deleted file mode 100644
index 8cd95608256..00000000000
--- a/addons/account/wizard/wizard_print_journal.py
+++ /dev/null
@@ -1,79 +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
-from tools.translate import _
-
-form = '''
-'''
-
-fields = {
- 'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True},
- 'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True},
- 'sort_selection':{
- 'string':"Entries Sorted By",
- 'type':'selection',
- 'selection':[('date','By date'),('ref','Reference Number')],
- 'required':True,
- 'default': lambda *a: 'date',
- },
-
-}
-
-def _check_data(self, cr, uid, data, *args):
- period_id = data['form']['period_id'][0][2]
- journal_id=data['form']['journal_id'][0][2]
-
- if type(period_id)==type([]):
-
- ids_final = []
-
- for journal in journal_id:
- for period in period_id:
- ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)])
-
- if ids_journal_period:
- ids_final.append(ids_journal_period)
-
- if not ids_final:
- raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
- return data['form']
-
-class wizard_print_journal(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-ok'))},
- },
- 'print': {
- 'actions': [_check_data],
- 'result': {'type':'print', 'report':'account.journal.period.print.wiz', 'state':'end'},
- },
- }
-wizard_print_journal('account.print.journal.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_state_open.py b/addons/account/wizard/wizard_state_open.py
deleted file mode 100644
index 9720f48e25e..00000000000
--- a/addons/account/wizard/wizard_state_open.py
+++ /dev/null
@@ -1,58 +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 netsvc
-from tools.translate import _
-
-form = '''
-'''
-
-fields = {
-}
-
-def _change_inv_state(self, cr, uid, data, context):
- pool_obj = pooler.get_pool(cr.dbname)
- data_inv = pool_obj.get('account.invoice').browse(cr, uid, data['ids'][0])
- if data_inv.reconciled:
- raise wizard.except_wizard(_('Warning'), _('Invoice is already reconciled'))
- wf_service = netsvc.LocalService("workflow")
- res = wf_service.trg_validate(uid, 'account.invoice', data['ids'][0], 'open_test', cr)
- return {}
-
-class wiz_state_open(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','No','gtk-no'),('yes','Yes','gtk-yes')]}
- },
- 'yes': {
- 'actions': [_change_inv_state],
- 'result': {'type':'state', 'state':'end'}
- }
- }
-wiz_state_open('account.wizard_paid_open')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/wizard_statement_from_invoice.py b/addons/account/wizard/wizard_statement_from_invoice.py
deleted file mode 100644
index 6e9f912380f..00000000000
--- a/addons/account/wizard/wizard_statement_from_invoice.py
+++ /dev/null
@@ -1,195 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2008 Camptocamp SA All Rights Reserved. (JGG)
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-##############################################################################
-
-import wizard
-import pooler
-from tools.misc import UpdateableStr
-import time
-
-FORM = UpdateableStr()
-
-FIELDS = {
- 'lines': {'string': 'Invoices', 'type': 'many2many',
- 'relation': 'account.move.line'},
-
-}
-
-START_FIELD = {
- 'date': {'string': 'Date payment', 'type': 'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
- 'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'domain': '[("type","in",["sale","purchase","cash"])]', 'help': 'This field allows you to choose the accounting journals you want for filtering the invoices. If you left this field empty, it will search on all sale, purchase and cash journals.'},
-}
-
-START_FORM = '''
-'''
-
-def _search_invoices(obj, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- line_obj = pool.get('account.move.line')
- statement_obj = pool.get('account.bank.statement')
- journal_obj = pool.get('account.journal')
-
- statement = statement_obj.browse(cr, uid, data['id'], context=context)
- args_move_line = []
- repeated_move_line_ids = []
- # Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again)
- for st_line in statement.line_ids:
- args_move_line = []
- args_move_line.append(('name','=', st_line.name))
- args_move_line.append(('ref','=',st_line.ref))
- if st_line.partner_id:
- args_move_line.append(('partner_id','=',st_line.partner_id.id))
- args_move_line.append(('account_id','=',st_line.account_id.id))
-
- move_line_id = line_obj.search(cr, uid, args_move_line,context=context)
- if move_line_id:
- repeated_move_line_ids += move_line_id
-
- journal_ids = data['form']['journal_id'][0][2]
-
- if journal_ids == []:
- journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context)
-
- args = [
- ('reconcile_id', '=', False),
- ('journal_id', 'in', journal_ids),
- ('account_id.reconcile', '=', True)]
-
- if repeated_move_line_ids:
- args.append(('id','not in',repeated_move_line_ids))
-
- line_ids = line_obj.search(cr, uid, args,
- #order='date DESC, id DESC', #doesn't work
- context=context)
-
- FORM.string = '''
-''' % (','.join([str(x) for x in line_ids]))
- return {}
-
-def _populate_statement(obj, cursor, user, data, context):
- line_ids = data['form']['lines'][0][2]
- line_date=data['form']['date']
- if not line_ids:
- return {}
-
- pool = pooler.get_pool(cursor.dbname)
- line_obj = pool.get('account.move.line')
- statement_obj = pool.get('account.bank.statement')
- statement_line_obj = pool.get('account.bank.statement.line')
- currency_obj = pool.get('res.currency')
- statement_reconcile_obj = pool.get('account.bank.statement.reconcile')
-
- statement = statement_obj.browse(cursor, user, data['id'], context=context)
- # for each selected move lines
- for line in line_obj.browse(cursor, user, line_ids, context=context):
- ctx = context.copy()
- # take the date for computation of currency => use payment date
- # if line.date_maturity:
- # ctx['date'] = line.date_maturity
- # else:
- ctx['date'] = line_date
- amount = 0.0
- if line.amount_currency:
- amount = currency_obj.compute(cursor, user, line.currency_id.id,
- statement.currency.id, line.amount_currency, context=ctx)
- else:
- if line.debit > 0:
- amount=line.debit
- elif line.credit > 0:
- amount=-line.credit
- reconcile_id = statement_reconcile_obj.create(cursor, user, {
- 'line_ids': [(6, 0, [line.id])]
- }, context=context)
- if line.journal_id.type == 'sale':
- type = 'customer'
- elif line.journal_id.type == 'purchase':
- type = 'supplier'
- else:
- type = 'general'
-
- statement_line_obj.create(cursor, user, {
- 'name': line.name or '?',
- 'amount': amount,
- 'type': type,
- 'partner_id': line.partner_id.id,
- 'account_id': line.account_id.id,
- 'statement_id': statement.id,
- 'ref': line.ref,
- 'reconcile_id': reconcile_id,
- 'date':line_date, #time.strftime('%Y-%m-%d'), #line.date_maturity or,
- }, context=context)
- return {}
-
-
-class PopulateStatementFromInv(wizard.interface):
- """
- Populate the current statement with selected invoices
- """
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': START_FORM,
- 'fields':START_FIELD,
- 'state': [
- ('end', '_Cancel'),
- ('go', '_Go', '', True),
- ]
- },
- },
- 'go': {
- 'actions': [_search_invoices],
- 'result': {
- 'type': 'form',
- 'arch': FORM,
- 'fields': FIELDS,
- 'state': [
- ('end', '_Cancel','', True, 'gtk-cancel'),
- ('finish', 'O_k','', True, 'gtk-ok')
- ]
- },
- },
-
- 'finish': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': _populate_statement,
- 'state': 'end'
- },
- },
- }
-PopulateStatementFromInv('populate_statement_from_inv')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/wizard_validate_account_move.py b/addons/account/wizard/wizard_validate_account_move.py
deleted file mode 100644
index 1b56431b4b9..00000000000
--- a/addons/account/wizard/wizard_validate_account_move.py
+++ /dev/null
@@ -1,89 +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 = '''
-'''
-
-_journal_fields = {
- 'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
- 'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True, 'domain':"[('state','<>','done')]"},
-}
-
-def _validate_move(self, cr, uid, data, context={}):
- pool = pooler.get_pool(cr.dbname)
- move_obj = pool.get('account.move')
- ids_move = move_obj.search(cr,uid,[('state','=','draft'),('journal_id','=',data['form']['journal_id']),('period_id','=',data['form']['period_id'])])
- if not ids_move:
- raise wizard.except_wizard(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
- res = move_obj.button_validate(cr, uid, ids_move, context)
- return {}
-
-class validate_account_move(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('validate','Validate', 'gtk-ok')]}
- },
- 'validate': {
- 'actions': [_validate_move],
- 'result': {'type': 'state', 'state':'end'}
- },
- }
-validate_account_move('account.move.validate')
-
-def _validate_move_lines(self, cr, uid, data, context={}):
- move_ids = []
- pool = pooler.get_pool(cr.dbname)
- move_line_obj = pool.get('account.move.line')
- move_obj = pool.get('account.move')
- data_line = move_line_obj.browse(cr,uid,data['ids'],context)
- for line in data_line:
- if line.move_id.state=='draft':
- move_ids.append(line.move_id.id)
- move_ids = list(set(move_ids))
- if not move_ids:
- raise wizard.except_wizard(_('Warning'), _('Selected Entry Lines does not have any account move enties in draft state'))
- res = move_obj.button_validate(cr, uid, move_ids, context)
- return {}
-
-class validate_account_move_lines(wizard.interface):
- states = {
- 'init': {
- 'actions': [_validate_move_lines],
- 'result': {'type': 'state', 'state':'end'}
- },
- }
-validate_account_move_lines('account.move_line.validate')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_vat.py b/addons/account/wizard/wizard_vat.py
deleted file mode 100755
index 6c14402c701..00000000000
--- a/addons/account/wizard/wizard_vat.py
+++ /dev/null
@@ -1,90 +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
-
-dates_form = '''
-'''
-
-dates_fields = {
- 'company_id': {'string': 'Company', 'type': 'many2one',
- 'relation': 'res.company', 'required': True},
- 'based_on':{'string':'Base on', 'type':'selection', 'selection':[
- ('invoices','Invoices'),
- ('payments','Payments'),
- ], 'required':True, 'default': lambda *a: 'invoices'},
- 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
-
-}
-
-
-class wizard_report(wizard.interface):
-
- def _get_defaults(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- period_obj = pool.get('account.period')
-
- user = pool.get('res.users').browse(cr, uid, uid, context=context)
- if user.company_id:
- company_id = user.company_id.id
- else:
- company_id = pool.get('res.company').search(cr, uid,
- [('parent_id', '=', False)])[0]
- data['form']['company_id'] = company_id
-
- return data['form']
-
- states = {
- 'init': {
- 'actions': [_get_defaults],
- 'result': {
- 'type': 'form',
- 'arch': dates_form,
- 'fields': dates_fields,
- 'state': [
- ('end', 'Cancel', 'gtk-cancel'),
- ('report', 'Print VAT Decl.', 'gtk-ok')
- ]
- }
- },
- 'report': {
- 'actions': [],
- 'result': {
- 'type': 'print',
- 'report': 'account.vat.declaration',
- 'state':'end'
- }
- }
- }
-
-wizard_report('account.vat.declaration')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_analytic_analysis/__terp__.py b/addons/account_analytic_analysis/__openerp__.py
similarity index 100%
rename from addons/account_analytic_analysis/__terp__.py
rename to addons/account_analytic_analysis/__openerp__.py
diff --git a/addons/account_analytic_default/__terp__.py b/addons/account_analytic_default/__openerp__.py
similarity index 100%
rename from addons/account_analytic_default/__terp__.py
rename to addons/account_analytic_default/__openerp__.py
diff --git a/addons/account_analytic_plans/__terp__.py b/addons/account_analytic_plans/__openerp__.py
similarity index 100%
rename from addons/account_analytic_plans/__terp__.py
rename to addons/account_analytic_plans/__openerp__.py
diff --git a/addons/account_anglo_saxon/__terp__.py b/addons/account_anglo_saxon/__openerp__.py
similarity index 100%
rename from addons/account_anglo_saxon/__terp__.py
rename to addons/account_anglo_saxon/__openerp__.py
diff --git a/addons/account_budget/__terp__.py b/addons/account_budget/__openerp__.py
similarity index 100%
rename from addons/account_budget/__terp__.py
rename to addons/account_budget/__openerp__.py
diff --git a/addons/account_chart/__terp__.py b/addons/account_chart/__openerp__.py
similarity index 100%
rename from addons/account_chart/__terp__.py
rename to addons/account_chart/__openerp__.py
diff --git a/addons/account_date_check/__terp__.py b/addons/account_date_check/__openerp__.py
similarity index 100%
rename from addons/account_date_check/__terp__.py
rename to addons/account_date_check/__openerp__.py
diff --git a/addons/account_followup/__terp__.py b/addons/account_followup/__openerp__.py
similarity index 100%
rename from addons/account_followup/__terp__.py
rename to addons/account_followup/__openerp__.py
diff --git a/addons/account_invoice_layout/__terp__.py b/addons/account_invoice_layout/__openerp__.py
similarity index 100%
rename from addons/account_invoice_layout/__terp__.py
rename to addons/account_invoice_layout/__openerp__.py
diff --git a/addons/account_payment/__terp__.py b/addons/account_payment/__openerp__.py
similarity index 100%
rename from addons/account_payment/__terp__.py
rename to addons/account_payment/__openerp__.py
diff --git a/addons/account_report/__terp__.py b/addons/account_report/__openerp__.py
similarity index 100%
rename from addons/account_report/__terp__.py
rename to addons/account_report/__openerp__.py
diff --git a/addons/account_reporting/__terp__.py b/addons/account_reporting/__openerp__.py
similarity index 100%
rename from addons/account_reporting/__terp__.py
rename to addons/account_reporting/__openerp__.py
diff --git a/addons/account_tax_include/__terp__.py b/addons/account_tax_include/__openerp__.py
similarity index 100%
rename from addons/account_tax_include/__terp__.py
rename to addons/account_tax_include/__openerp__.py
diff --git a/addons/account_voucher/__terp__.py b/addons/account_voucher/__openerp__.py
similarity index 100%
rename from addons/account_voucher/__terp__.py
rename to addons/account_voucher/__openerp__.py
diff --git a/addons/analytic/__terp__.py b/addons/analytic/__openerp__.py
similarity index 100%
rename from addons/analytic/__terp__.py
rename to addons/analytic/__openerp__.py
diff --git a/addons/analytic_journal_billing_rate/__terp__.py b/addons/analytic_journal_billing_rate/__openerp__.py
similarity index 100%
rename from addons/analytic_journal_billing_rate/__terp__.py
rename to addons/analytic_journal_billing_rate/__openerp__.py
diff --git a/addons/analytic_user_function/__terp__.py b/addons/analytic_user_function/__openerp__.py
similarity index 100%
rename from addons/analytic_user_function/__terp__.py
rename to addons/analytic_user_function/__openerp__.py
diff --git a/addons/event/__terp__.py b/addons/event/__openerp__.py
similarity index 100%
rename from addons/event/__terp__.py
rename to addons/event/__openerp__.py
diff --git a/addons/event_project/__terp__.py b/addons/event_project/__openerp__.py
similarity index 100%
rename from addons/event_project/__terp__.py
rename to addons/event_project/__openerp__.py
diff --git a/addons/hr/__terp__.py b/addons/hr/__openerp__.py
similarity index 88%
rename from addons/hr/__terp__.py
rename to addons/hr/__openerp__.py
index 4063b327545..d6477640582 100644
--- a/addons/hr/__terp__.py
+++ b/addons/hr/__openerp__.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 .
#
##############################################################################
@@ -28,11 +28,9 @@
"website" : "http://www.openerp.com",
"description": """
Module for human resource management. You can manage:
- * Employees and hierarchies
- * Work hours sheets
- * Attendances and sign in/out system
-
- Different reports are also provided, mainly for attendance statistics.
+ * Employees and hierarchies : You can define your employee with User and display hierarchies
+ * HR Departments
+ * HR Jobs
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
@@ -47,7 +45,7 @@
'hr_installer.xml',
'hr_data.xml'
],
- 'demo_xml': ['hr_demo.xml',
+ 'demo_xml': ['hr_demo.xml',
'hr_department_demo.xml'],
'installable': True,
'active': False,
diff --git a/addons/hr/hr.py b/addons/hr/hr.py
index d2b4d2ec011..bdaca6e2ace 100755
--- a/addons/hr/hr.py
+++ b/addons/hr/hr.py
@@ -18,7 +18,6 @@
# along with this program. If not, see .
#
##############################################################################
-
from osv import fields, osv
from tools.translate import _
@@ -82,6 +81,7 @@ class hr_job(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr.job', context=c),
'state': lambda *args: 'open'
}
+
hr_job()
class hr_employee(osv.osv):
@@ -104,7 +104,6 @@ class hr_employee(osv.osv):
'work_phone': fields.related('address_id', 'phone', type='char', string='Work Phone', readonly=True),
'work_email': fields.related('address_id', 'email', type='char', size=240, string='Work E-mail', readonly=True),
'work_location': fields.char('Office Location', size=32),
-
'notes': fields.text('Notes'),
'parent_id': fields.many2one('hr.employee', 'Manager', select=True),
'category_id' : fields.many2one('hr.employee.category', 'Category'),
@@ -112,7 +111,6 @@ class hr_employee(osv.osv):
'resource_id': fields.many2one('resource.resource','Resource',ondelete='cascade'),
'coach_id':fields.many2one('res.users','Coach'),
'job_id':fields.many2one('hr.job', 'Job'),
-
}
_defaults = {
'active' : lambda *a: True,
@@ -134,5 +132,4 @@ class hr_employee(osv.osv):
hr_employee()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr/hr_department_demo.xml b/addons/hr/hr_department_demo.xml
index c7ea68f1dc3..bc1649bbef5 100644
--- a/addons/hr/hr_department_demo.xml
+++ b/addons/hr/hr_department_demo.xml
@@ -1,63 +1,61 @@
-
+
Management
+
Administration
-
+
Technical department
-
+
IT
-
+
Marketing
-
+
Sales
-
+
Sales Europe
-
+
Sales America
-
-
-
-
+
diff --git a/addons/hr/installer.py b/addons/hr/installer.py
index ab3e46c9bbf..bc3dd7d0b71 100644
--- a/addons/hr/installer.py
+++ b/addons/hr/installer.py
@@ -52,4 +52,7 @@ class hr_installer(osv.osv_memory):
'hr_holidays': True,
'hr_expense': True,
}
+
hr_installer()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_attendance/__terp__.py b/addons/hr_attendance/__openerp__.py
similarity index 87%
rename from addons/hr_attendance/__terp__.py
rename to addons/hr_attendance/__openerp__.py
index 7ea1b0b33ff..c59ba3dcbdb 100644
--- a/addons/hr_attendance/__terp__.py
+++ b/addons/hr_attendance/__openerp__.py
@@ -37,7 +37,11 @@
'hr_attendance_view.xml',
'hr_attendance_wizard.xml',
'hr_attendance_report.xml',
- 'security/ir.model.access.csv'
+ 'security/ir.model.access.csv',
+ 'wizard/hr_attendance_bymonth_view.xml',
+ 'wizard/hr_attendance_byweek_view.xml',
+ 'wizard/hr_attendance_error_view.xml',
+ 'wizard/hr_attendance_sign_in_out_view.xml',
],
'demo_xml': ['hr_attendance_demo.xml'],
'installable': True,
diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py
index cca69186f0c..27458ac2e85 100644
--- a/addons/hr_attendance/hr_attendance.py
+++ b/addons/hr_attendance/hr_attendance.py
@@ -37,7 +37,7 @@ class hr_action_reason(osv.osv):
}
hr_action_reason()
-def _employee_get(obj,cr,uid,context={}):
+def _employee_get(obj, cr, uid, context=None):
ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
if ids:
return ids[0]
@@ -90,7 +90,7 @@ class hr_employee(osv.osv):
_inherit = "hr.employee"
_description = "Employee"
- def _state(self, cr, uid, ids, name, args, context={}):
+ def _state(self, cr, uid, ids, name, args, context=None):
result = {}
for id in ids:
result[id] = 'absent'
@@ -125,27 +125,27 @@ class hr_employee(osv.osv):
#Special case when button calls this method :type=context
if isinstance(type,dict):
type = type.get('type','action')
-
+
if type == 'sign_in':
warning_sign = "Sign In"
elif type == 'sign_out':
- warning_sign = "Sign Out"
-
+ warning_sign = "Sign Out"
+
for emp in self.read(cr, uid, ids, ['id'], context=context):
if not self._action_check(cr, uid, emp['id'], dt, context):
raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,))
-
+
res = {'action' : type, 'employee_id' : emp['id']}
if dt:
res['name'] = dt
-
+
id = self.pool.get('hr.attendance').create(cr, uid, res, context=context)
-
+
if type != 'action':
return id
return True
-
+
hr_employee()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_attendance/hr_attendance_wizard.xml b/addons/hr_attendance/hr_attendance_wizard.xml
index a1ea01ea764..717495b654e 100644
--- a/addons/hr_attendance/hr_attendance_wizard.xml
+++ b/addons/hr_attendance/hr_attendance_wizard.xml
@@ -2,22 +2,22 @@
-
-
+
+
+
-
+
-
-
+
diff --git a/addons/hr_attendance/wizard/__init__.py b/addons/hr_attendance/wizard/__init__.py
index a216c879285..a414c9a8798 100644
--- a/addons/hr_attendance/wizard/__init__.py
+++ b/addons/hr_attendance/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,13 +15,13 @@
# 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 sign_in_out
-import print_attendance_error
-from print_byweek import wiz_byweek
-from print_bymonth import wiz_bymonth
+import hr_attendance_sign_in_out
+import hr_attendance_error
+import hr_attendance_byweek
+import hr_attendance_bymonth
-# 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/hr_attendance/wizard/hr_attendance_bymonth.py b/addons/hr_attendance/wizard/hr_attendance_bymonth.py
new file mode 100644
index 00000000000..2b2c33cf5eb
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_bymonth.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 .
+#
+##############################################################################
+import time
+
+from osv import osv, fields
+
+class hr_attendance_bymonth(osv.osv_memory):
+ _name = 'hr.attendance.month'
+ _description = 'Print Monthly Attendance Report'
+ _columns = {
+ 'month': fields.selection([(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')],
+ 'Month', required=True),
+ 'year': fields.integer('Year', required=True)
+ }
+ _defaults = {
+ 'month': lambda * a: time.gmtime()[1],
+ 'year': lambda * a: time.gmtime()[0],
+ }
+
+ def print_report(self, cr, uid, ids, context=None):
+ datas = {
+ 'ids': [],
+ 'model': 'hr.employee',
+ 'form': self.read(cr, uid, ids)[0]
+ }
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'hr.attendance.bymonth',
+ 'datas': datas,
+ }
+
+hr_attendance_bymonth()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_bymonth_view.xml b/addons/hr_attendance/wizard/hr_attendance_bymonth_view.xml
new file mode 100644
index 00000000000..89272706eee
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_bymonth_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ Attendance Report Monthly
+ hr.attendance.month
+ form
+
+
+
+
+
+
+ Print Timesheet by month
+ ir.actions.act_window
+ hr.attendance.month
+ form
+ form
+ new
+
+
+
+
+
+ Print Timesheet by month
+ client_print_multi
+
+ action
+ hr.employee
+
+
+
+
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/print_byweek.py b/addons/hr_attendance/wizard/hr_attendance_byweek.py
similarity index 51%
rename from addons/hr_attendance/wizard/print_byweek.py
rename to addons/hr_attendance/wizard/hr_attendance_byweek.py
index d859e81aea5..30c63d69f2b 100644
--- a/addons/hr_attendance/wizard/print_byweek.py
+++ b/addons/hr_attendance/wizard/hr_attendance_byweek.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,39 +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
import time
-_date_form = '''
-'''
+from osv import osv, fields
-_date_fields = {
- 'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
- 'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}
-}
+class hr_attendance_byweek(osv.osv_memory):
+ _name = 'hr.attendance.week'
+ _description = 'Print Week Attendance Report'
+ _columns = {
+ 'init_date': fields.date('Starting Date', required=True),
+ 'end_date': fields.date('Ending Date', required=True)
+ }
+ _defaults = {
+ 'init_date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'end_date': lambda *a: time.strftime('%Y-%m-%d'),
+ }
-class wiz_byweek(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('end','Cancel', 'gtk-cancel'), ('print','Print', 'gtk-ok')]}
- },
- 'print': {
- 'actions': [],
- 'result': {'type': 'print', 'report': 'hr.attendance.allweeks', 'state':'end'}
- }
- }
-wiz_byweek('hr.attendance.print_week')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ def print_report(self, cr, uid, ids, context=None):
+ datas = {
+ 'ids': [],
+ 'model': 'hr.employee',
+ 'form': self.read(cr, uid, ids)[0]
+ }
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'hr.attendance.allweeks',
+ 'datas': datas,
+ }
+hr_attendance_byweek()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_byweek_view.xml b/addons/hr_attendance/wizard/hr_attendance_byweek_view.xml
new file mode 100644
index 00000000000..618217a1a66
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_byweek_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ Attendance Report Week
+ hr.attendance.week
+ form
+
+
+
+
+
+
+ Print Timesheet by week
+ ir.actions.act_window
+ hr.attendance.week
+ form
+ form
+ new
+
+
+
+
+
+ Print Timesheet by week
+ client_print_multi
+
+ action
+ hr.employee
+
+
+
+
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_error.py b/addons/hr_attendance/wizard/hr_attendance_error.py
new file mode 100644
index 00000000000..c14ddcd9032
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_error.py
@@ -0,0 +1,70 @@
+# -*- 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 osv, fields
+from tools.translate import _
+
+class hr_attendance_error(osv.osv_memory):
+
+ _name = 'hr.attendance.error'
+ _description = 'Print Error Attendance Report'
+ _columns = {
+ 'init_date': fields.date('Starting Date', required=True),
+ 'end_date': fields.date('Ending Date', required=True),
+ 'max_delay': fields.integer('Max. Delay (Min)', required=True)
+
+ }
+ _defaults = {
+ 'init_date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'end_date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'max_delay': 120,
+ }
+
+ def print_report(self, cr, uid, ids, context=None):
+ emp_ids = []
+ data_error = self.read(cr, uid, ids)[0]
+ date_from = data_error['init_date']
+ date_to = data_error['end_date']
+ cr.execute("select id from hr_attendance where employee_id =ANY(%s) and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action =ANY(%s) order by name" ,(context['active_ids'], date_to, date_from, ['sign_in','sign_out']))
+ attendance_ids = [x[0] for x in cr.fetchall()]
+ if not attendance_ids:
+ raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
+ attendance_records = self.pool.get('hr.attendance').browse(cr, uid, attendance_ids)
+
+ for rec in attendance_records:
+ if rec.employee_id.id not in emp_ids:
+ emp_ids.append(rec.employee_id.id)
+ data_error['emp_ids'] = emp_ids
+ datas = {
+ 'ids': [],
+ 'model': 'hr.employee',
+ 'form': data_error
+ }
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'hr.attendance.error',
+ 'datas': datas,
+ }
+
+hr_attendance_error()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_error_view.xml b/addons/hr_attendance/wizard/hr_attendance_error_view.xml
new file mode 100644
index 00000000000..16769f66df0
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_error_view.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+ Attendance Report Error
+ hr.attendance.error
+ form
+
+
+
+
+
+
+ Print Attendance Error Report
+ ir.actions.act_window
+ hr.attendance.error
+ form
+ form
+ new
+
+
+
+
+
+ Print Attendance Error Report
+ client_print_multi
+
+ action
+ hr.employee
+
+
+
+
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
new file mode 100644
index 00000000000..9ad27298159
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
@@ -0,0 +1,185 @@
+# -*- 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 netsvc
+from osv import osv, fields
+from tools.translate import _
+
+class hr_si_so_ask(osv.osv_memory):
+ _name = 'hr.sign.in.out.ask'
+ _description = 'Ask for Sign In Out'
+ _columns = {
+ 'name': fields.char('Employees name', size=32, required=True, readonly=True),
+ 'last_time': fields.datetime('Your last sign out', required=True),
+ 'emp_id': fields.char('Empoyee ID', size=32, required=True, readonly=True),
+ }
+ def _get_empname(self, cr, uid, context=None):
+ service = netsvc.LocalService('object_proxy')
+ emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)])
+ if emp_id:
+ employee = service.execute(cr.dbname, uid, 'hr.employee', 'read', emp_id)[0]
+ return employee['name']
+ return ''
+
+ def _get_empid(self, cr, uid, context=None):
+ service = netsvc.LocalService('object_proxy')
+ emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)])
+ if emp_id:
+ return emp_id[0]
+ return False
+
+ _defaults = {
+ 'name': _get_empname,
+ 'emp_id': _get_empid,
+ }
+
+ def sign_in(self, cr, uid, ids, context=None):
+ data = self.read(cr, uid, ids, [])[0]
+ return self.pool.get('hr.sign.in.out').sign_in(cr, uid, data, context)
+
+ def sign_out(self, cr, uid, ids, context=None):
+ data = self.read(cr, uid, ids, [])[0]
+ return self.pool.get('hr.sign.in.out').sign_out(cr, uid, data, context)
+
+hr_si_so_ask()
+
+class hr_sign_in_out(osv.osv_memory):
+
+ _name = 'hr.sign.in.out'
+ _description = 'Sign In Sign Out'
+
+ _columns = {
+ 'name': fields.char('Employees name', size=32, required=True, readonly=True),
+ 'state': fields.char('Current state', size=32, required=True, readonly=True),
+ 'emp_id': fields.char('Empoyee ID', size=32, required=True, readonly=True),
+ }
+
+ def _get_empid(self, cr, uid, context=None):
+ service = netsvc.LocalService('object_proxy')
+ emp_id = service.execute(cr.dbname, uid, 'hr.employee', 'search', [('user_id', '=', uid)])
+ if emp_id:
+ employee = service.execute(cr.dbname, uid, 'hr.employee', 'read', emp_id)[0]
+ return {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]}
+ return {}
+
+ def default_get(self, cr, uid, fields_list, context=None):
+ res = super(hr_sign_in_out, self).default_get(cr, uid, fields_list, context=context)
+ res_emp = self._get_empid(cr, uid, context=context)
+ res.update(res_emp)
+ return res
+
+ def si_check(self, cr, uid, ids, context=None):
+ service = netsvc.LocalService('object_proxy')
+ obj_model = self.pool.get('ir.model.data')
+ data = self.read(cr, uid, ids, [])[0]
+ emp_id = data['emp_id']
+ att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id)], limit=1, order='name desc')
+ last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id)
+ if last_att:
+ last_att = last_att[0]
+ cond = not last_att or last_att['action'] == 'sign_out'
+ if cond:
+ return self.sign_in(cr, uid, data, context)
+ else:
+ model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_attendance_so_ask')], context=context)
+ resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ return {
+ 'name': _('Sign in / Sign out'),
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'hr.sign.in.out.ask',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+ def so_check(self, cr, uid, ids, context=None):
+ service = netsvc.LocalService('object_proxy')
+ obj_model = self.pool.get('ir.model.data')
+ data = self.read(cr, uid, ids, [])[0]
+ emp_id = data['emp_id']
+ att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id),('action','!=','action')], limit=1, order='name desc')
+ last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id)
+ if last_att:
+ last_att = last_att[0]
+ if not att_id and not last_att:
+ model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_attendance_message')], context=context)
+ resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ return {
+ 'name': _('Sign in / Sign out'),
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'hr.sign.in.out',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+ cond = last_att and last_att['action'] == 'sign_in'
+ if cond:
+ return self.sign_out(cr, uid, data, context)
+ else:
+ model_data_ids = self.pool.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_attendance_si_ask')], context=context)
+ resource_id = self.pool.get('ir.model.data').read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ return {
+ 'name': _('Sign in / Sign out'),
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'hr.sign.in.out.ask',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+ def sign_in(self, cr, uid, data, context=None):
+ service = netsvc.LocalService('object_proxy')
+ emp_id = data['emp_id']
+ if 'last_time' in data:
+ if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
+ raise osv.except_osv(_('UserError'), _('The sign-out date must be in the past'))
+ service.execute(cr.dbname, uid, 'hr.attendance', 'create', {
+ 'name': data['last_time'],
+ 'action': 'sign_out',
+ 'employee_id': emp_id
+ })
+ try:
+ success = service.execute(cr.dbname, uid, 'hr.employee', 'attendance_action_change', [emp_id], 'sign_in')
+ except:
+ raise osv.except_osv(_('UserError'), _('A sign-in must be right after a sign-out !'))
+ return {} # To do: Return Success message
+
+ def sign_out(self, cr, uid, data, context=None):
+ service = netsvc.LocalService('object_proxy')
+ emp_id = data['emp_id']
+ if 'last_time' in data:
+ if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
+ raise osv.except_osv(_('UserError'), _('The Sign-in date must be in the past'))
+ service.execute(cr.dbname, uid, 'hr.attendance', 'create', {'name':data['last_time'], 'action':'sign_in', 'employee_id':emp_id})
+ try:
+ success = service.execute(cr.dbname, uid, 'hr.employee', 'attendance_action_change', [emp_id], 'sign_out')
+ except:
+ raise osv.except_osv(_('UserError'), _('A sign-out must be right after a sign-in !'))
+ return {} # To do: Return Success message
+
+hr_sign_in_out()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
new file mode 100644
index 00000000000..62cffa720a9
--- /dev/null
+++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
@@ -0,0 +1,91 @@
+
+
+
+
+ hr.sign.in.out.form
+ hr.sign.in.out
+ form
+
+
+
+
+
+
+ hr.sign.in.out.form
+ hr.sign.in.out
+ form
+
+
+
+
+
+
+ Sign in / Sign out
+ hr.sign.in.out
+ form
+ tree,form
+
+ new
+
+
+
+
+
+ hr.sign.in.out.ask.form
+ hr.sign.in.out.ask
+ form
+
+
+
+
+
+
+ hr.sign.in.out.ask.form
+ hr.sign.in.out.ask
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/hr_attendance/wizard/print_attendance_error.py b/addons/hr_attendance/wizard/print_attendance_error.py
deleted file mode 100644
index c7c9ab18068..00000000000
--- a/addons/hr_attendance/wizard/print_attendance_error.py
+++ /dev/null
@@ -1,76 +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 time
-import pooler
-from tools.translate import _
-
-_date_form = '''
-'''
-
-_date_fields = {
- 'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
- 'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
- 'max_delay': {'string':'Max. Delay (Min)', 'type':'integer', 'default':lambda *a: 120, 'required':True},
-}
-
-def _check_data(self, cr, uid, data, *args):
- date_from = data['form']['init_date']
- date_to = data['form']['end_date']
- cr.execute("select id from hr_attendance where employee_id =ANY(%s) and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action =ANY(%s) order by name" ,(data['ids'], date_to, date_from, ['sign_in','sign_out']))
- attendance_ids = [x[0] for x in cr.fetchall()]
- if not attendance_ids:
- raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!'))
-
- attendance_records = pooler.get_pool(cr.dbname).get('hr.attendance').browse(cr,uid,attendance_ids)
- emp_ids = []
- for rec in attendance_records:
- if rec.employee_id.id not in emp_ids:
- emp_ids.append(rec.employee_id.id)
-
- data['form']['emp_ids'] = emp_ids
-
- return data['form']
-
-
-class wiz_attendance(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('end','Cancel', 'gtk-cancel'),('print','Print', 'gtk-ok') ]}
- },
- 'print': {
- 'actions': [_check_data],
- 'result': {'type': 'print', 'report': 'hr.attendance.error', 'state':'end'}
- }
- }
-wiz_attendance('hr.attendance.report')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/hr_attendance/wizard/print_bymonth.py b/addons/hr_attendance/wizard/print_bymonth.py
deleted file mode 100644
index ae2d5df937b..00000000000
--- a/addons/hr_attendance/wizard/print_bymonth.py
+++ /dev/null
@@ -1,63 +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 time
-
-_date_form = '''
-'''
-
-_date_fields = {
- 'month' : {
- 'string' : 'Month',
- 'type' : 'selection',
- 'selection' : [(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')],
- 'required':True,
- 'default' : lambda * a: time.gmtime()[1]
- },
- 'year' : {
- 'string' : 'Year',
- 'type' : 'integer',
- 'required':True,
- 'default' : lambda * a: time.gmtime()[0]
- },
-}
-
-class wiz_bymonth(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[ ('end', 'Cancel', 'gtk-cancel'),('print', 'Print', 'gtk-ok')] }
- },
- 'print': {
- 'actions': [],
- 'result': {'type': 'print', 'report': 'hr.attendance.bymonth', 'state': 'end' }
- }
- }
-wiz_bymonth('hr.attendance.print_month')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/hr_attendance/wizard/sign_in_out.py b/addons/hr_attendance/wizard/sign_in_out.py
deleted file mode 100644
index 8e022a3c44f..00000000000
--- a/addons/hr_attendance/wizard/sign_in_out.py
+++ /dev/null
@@ -1,197 +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 time
-from tools.translate import _
-
-si_so_form ='''
-'''
-
-si_so_fields = {
- 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True},
- 'state' : {'string' : "Current state", 'type' : 'char', 'required' : True, 'readonly': True},
-}
-
-si_form = '''
-'''
-
-si_fields = {
- 'success' : {'string' : "Sign in's status", 'type' : 'char', 'required' : True, 'readonly' : True},
-}
-
-so_form = '''
-'''
-
-so_ask_fields = {
- 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True},
- 'last_time' : {'string' : "Your last sign out", 'type' : 'datetime', 'required' : True},
-}
-
-def _si_check(self, cr, uid, data, context):
- states = {True : 'si', False: 'si_ask_so'}
- service = netsvc.LocalService('object_proxy')
- emp_id = data['form']['emp_id']
- att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id)], limit=1, order='name desc')
- last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id)
- if last_att:
- last_att = last_att[0]
- cond = not last_att or last_att['action'] == 'sign_out'
- return states[cond]
-
-si_ask_form ='''
-'''
-
-si_ask_fields = {
- 'name' : {'string' : "Employee's name", 'type':'char', 'required':True, 'readonly':True},
- 'last_time' : {'string' : "Your last sign in", 'type' : 'datetime', 'required' : True},
-}
-
-so_wo_si_form = '''
-'''
-
-def _so_check(self, cr, uid, data, context):
- states = {True : 'so', False: 'so_ask_si'}
- service = netsvc.LocalService('object_proxy')
- emp_id = data['form']['emp_id']
- att_id = service.execute(cr.dbname, uid, 'hr.attendance', 'search', [('employee_id', '=', emp_id),('action','!=','action')], limit=1, order='name desc')
- last_att = service.execute(cr.dbname, uid, 'hr.attendance', 'read', att_id)
- if last_att:
- last_att = last_att[0]
-
- if not att_id and not last_att:
- return 'so_wo_si'
- cond = last_att and last_att['action'] == 'sign_in'
- return states[cond]
-
-class wiz_si_so(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [_get_empid],
- 'result' : {'type' : 'form', 'arch' : si_so_form, 'fields' : si_so_fields,
- 'state' : [('end', 'Cancel', 'gtk-cancel'),
- ('si_test', 'Sign in', 'gtk-go-back'),
- ('so_test', 'Sign out', 'gtk-go-forward')]
- }
- },
- 'si_test' : {
- 'actions' : [],
- 'result' : {'type' : 'choice', 'next_state': _si_check}
- },
- 'si_ask_so' : {
- 'actions' : [],
- 'result' : {'type' : 'form', 'arch' : so_ask_form, 'fields' : so_ask_fields, 'state' : [('end', 'Cancel'),('si', 'Sign in') ] }
- },
- 'si' : {
- 'actions' : [_sign_in],
- 'result' : {'type' : 'state', 'state':'end'}
- },
- 'so_test' : {
- 'actions' : [],
- 'result' : {'type' : 'choice', 'next_state': _so_check }
- },
- 'so_ask_si' : {
- 'actions' : [],
- 'result' : {'type' : 'form', 'arch' : si_ask_form, 'fields' : si_ask_fields, 'state' : [('end', 'Cancel'),('so', 'Sign out')] }
- },
- 'so' : {
- 'actions' : [_sign_out],
- 'result' : {'type' : 'state', 'state':'end'}
- },
- 'so_wo_si' : {
- 'actions' : [],
- 'result' : {'type' : 'form', 'arch' : so_wo_si_form, 'fields' : {}, 'state' : [('end', 'Ok')] }
- },
- }
-wiz_si_so('hr.si_so')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/hr_contract/__terp__.py b/addons/hr_contract/__openerp__.py
similarity index 100%
rename from addons/hr_contract/__terp__.py
rename to addons/hr_contract/__openerp__.py
diff --git a/addons/hr_contract/hr_contract.py b/addons/hr_contract/hr_contract.py
index b90f9dd1a89..b8a310cc7bd 100644
--- a/addons/hr_contract/hr_contract.py
+++ b/addons/hr_contract/hr_contract.py
@@ -18,23 +18,22 @@
# along with this program. If not, see .
#
##############################################################################
-
+import time
from osv import fields, osv
-import time
class hr_employee(osv.osv):
_name = "hr.employee"
_description = "Employee"
_inherit = "hr.employee"
_columns = {
- 'manager' : fields.boolean('Manager'),
- 'medic_exam' : fields.date('Medical Examination Date'),
- 'place_of_birth' : fields.char('Place of Birth', size=30),
- 'children' : fields.integer('Number of Children'),
- 'vehicle' : fields.integer('Company Vehicle'),
- 'vehicle_distance' : fields.integer('Home-Work Distance', help="In kilometers"),
- 'contract_ids' : fields.one2many('hr.contract', 'employee_id', 'Contracts'),
+ 'manager': fields.boolean('Manager'),
+ 'medic_exam': fields.date('Medical Examination Date'),
+ 'place_of_birth': fields.char('Place of Birth', size=30),
+ 'children': fields.integer('Number of Children'),
+ 'vehicle': fields.integer('Company Vehicle'),
+ 'vehicle_distance': fields.integer('Home-Work Distance', help="In kilometers"),
+ 'contract_ids': fields.one2many('hr.contract', 'employee_id', 'Contracts'),
}
hr_employee()
@@ -43,7 +42,7 @@ class hr_contract_wage_type_period(osv.osv):
_name='hr.contract.wage.type.period'
_description='Wage Period'
_columns = {
- 'name' : fields.char('Period Name', size=50, required=True, select=True),
+ 'name': fields.char('Period Name', size=50, required=True, select=True),
'factor_days': fields.float('Hours in the period', digits=(12,4), required=True, help='This field is used by the timesheet system to compute the price of an hour of work wased on the contract of the employee')
}
_defaults = {
@@ -72,7 +71,7 @@ class hr_contract_type(osv.osv):
_name = 'hr.contract.type'
_description = 'Contract Type'
_columns = {
- 'name' : fields.char('Contract Type', size=30, required=True),
+ 'name': fields.char('Contract Type', size=32, required=True),
}
hr_contract_type()
@@ -80,7 +79,7 @@ class hr_contract(osv.osv):
_name = 'hr.contract'
_description = 'Contract'
_columns = {
- 'name': fields.char('Contract Reference', size=30, required=True),
+ 'name': fields.char('Contract Reference', size=32, required=True),
'employee_id': fields.many2one('hr.employee', "Employee", required=True),
'department_id': fields.related('employee_id','department_id', string="Department", readonly=True),
'type_id': fields.many2one('hr.contract.type', "Contract Type"),
@@ -100,6 +99,4 @@ class hr_contract(osv.osv):
}
hr_contract()
-
-# 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/hr_contract/hr_contract_view.xml b/addons/hr_contract/hr_contract_view.xml
index 35c86cb206b..7578d66e98b 100644
--- a/addons/hr_contract/hr_contract_view.xml
+++ b/addons/hr_contract/hr_contract_view.xml
@@ -229,5 +229,10 @@
+
+
+
+
+
diff --git a/addons/hr_evaluation/__terp__.py b/addons/hr_evaluation/__openerp__.py
similarity index 100%
rename from addons/hr_evaluation/__terp__.py
rename to addons/hr_evaluation/__openerp__.py
diff --git a/addons/hr_evaluation/hr_evaluation_view.xml b/addons/hr_evaluation/hr_evaluation_view.xml
index da245c4645b..bf6e45376e7 100644
--- a/addons/hr_evaluation/hr_evaluation_view.xml
+++ b/addons/hr_evaluation/hr_evaluation_view.xml
@@ -338,9 +338,12 @@
id="menu_open_hr_evaluation_interview_requests"
action="action_hr_evaluation_interview_tree"/>
-
+
+
+
+
diff --git a/addons/hr_expense/__terp__.py b/addons/hr_expense/__openerp__.py
similarity index 100%
rename from addons/hr_expense/__terp__.py
rename to addons/hr_expense/__openerp__.py
diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py
index d4747758682..11348ccd1f3 100644
--- a/addons/hr_expense/hr_expense.py
+++ b/addons/hr_expense/hr_expense.py
@@ -19,20 +19,20 @@
#
##############################################################################
-from mx import DateTime
import time
from osv import fields, osv
from tools.translate import _
-def _employee_get(obj,cr,uid,context={}):
+def _employee_get(obj, cr, uid, context=None):
ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
if ids:
return ids[0]
return False
class hr_expense_expense(osv.osv):
- def copy(self, cr, uid, id, default=None, context={}):
+
+ def copy(self, cr, uid, id, default=None, context=None):
if not default: default = {}
default.update( {'invoice_id':False,'date_confirm':False,'date_valid':False,'user_valid':False})
return super(hr_expense_expense, self).copy(cr, uid, id, default, context)
@@ -50,7 +50,7 @@ class hr_expense_expense(osv.osv):
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
_name = "hr.expense.expense"
- _description = "Expense"
+ _description = "HR Expense"
_columns = {
'name': fields.char('Expense Sheet', size=128, required=True),
'id': fields.integer('Sheet ID', readonly=True),
@@ -84,9 +84,9 @@ class hr_expense_expense(osv.osv):
'date' : lambda *a: time.strftime('%Y-%m-%d'),
'state': lambda *a: 'draft',
'employee_id' : _employee_get,
- 'user_id' : lambda cr,uid,id,c={}: id,
+ 'user_id' : lambda cr, uid, id, c={}: id,
'currency_id': _get_currency,
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
+ 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
def expense_confirm(self, cr, uid, ids, *args):
#for exp in self.browse(cr, uid, ids):
@@ -182,10 +182,10 @@ class product_product(osv.osv):
product_product()
-
class hr_expense_line(osv.osv):
_name = "hr.expense.line"
_description = "Expense Line"
+
def _amount(self, cr, uid, ids, field_name, arg, context):
if not len(ids):
return {}
@@ -212,8 +212,11 @@ class hr_expense_line(osv.osv):
'date_value' : lambda *a: time.strftime('%Y-%m-%d'),
}
_order = "sequence"
- def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context={}):
- v={}
+
+ def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None):
+ if context is None:
+ context = {}
+ v = {}
if product_id:
product=self.pool.get('product.product').browse(cr,uid,product_id, context=context)
v['name']=product.name
@@ -227,9 +230,8 @@ class hr_expense_line(osv.osv):
v['unit_amount']=amount_unit
if not uom_id:
v['uom_id']=product.uom_id.id
- return {'value':v}
+ return {'value': v}
hr_expense_line()
-# 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/hr_holidays/__terp__.py b/addons/hr_holidays/__openerp__.py
similarity index 96%
rename from addons/hr_holidays/__terp__.py
rename to addons/hr_holidays/__openerp__.py
index bdd902923eb..f5a57313348 100644
--- a/addons/hr_holidays/__terp__.py
+++ b/addons/hr_holidays/__openerp__.py
@@ -55,6 +55,8 @@
'hr_holidays_view.xml',
'hr_holidays_wizard.xml',
'hr_holidays_report.xml',
+ 'wizard/hr_holidays_summary_department_view.xml',
+ 'wizard/hr_holidays_summary_employees_view.xml',
#'process/hr_holidays_process.xml'
],
'demo_xml': [],
diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index 4265400df8c..cd0d86457d9 100755
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -50,8 +50,11 @@ class hr_holidays_status(osv.osv):
return res
def _user_left_days(self, cr, uid, ids, name, args, context={}):
- res = {}
return_false = False
+ employee_id = False
+ res = {}
+ for id in ids:
+ res[id] = {}.fromkeys(name, 0)
if context and context.has_key('employee_id'):
if not context['employee_id']:
return_false = True
diff --git a/addons/hr_holidays/hr_holidays_wizard.xml b/addons/hr_holidays/hr_holidays_wizard.xml
index a747571c943..a32e3027bba 100644
--- a/addons/hr_holidays/hr_holidays_wizard.xml
+++ b/addons/hr_holidays/hr_holidays_wizard.xml
@@ -11,22 +11,22 @@
name="Holidays"
parent="hr.menu_hr_reporting"
sequence="3" />
-
- -->
+
-
+ keyword="client_print_multi" id="wizard_holidays_summary" />-->
diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py
index c61e8f733b4..77dde5b4575 100644
--- a/addons/hr_holidays/report/holidays_summary_report.py
+++ b/addons/hr_holidays/report/holidays_summary_report.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 .
#
##############################################################################
@@ -39,8 +39,8 @@ def strToDate(dt):
dt_date=datetime.date(int(dt[0:4]),int(dt[5:7]),int(dt[8:10]))
return dt_date
else:
- return
-
+ return
+
def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
display={}
@@ -48,11 +48,11 @@ def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
count=0
p_id=pooler.get_pool(cr.dbname).get('hr.holidays').search(cr,uid,[('employee_id','in',[empid,False]), ('type', '=', 'remove')])
ids_date = pooler.get_pool(cr.dbname).get('hr.holidays').read(cr,uid,p_id,['date_from','date_to','holiday_status_id','state'])
-
+
for index in range(1,61):
diff=index-1
current=som+datetime.timedelta(diff)
-
+
for item in ids_date:
if current >= strToDate(item['date_from']) and current <= strToDate(item['date_to']):
if item['state'] in holiday_type:
@@ -210,19 +210,18 @@ class report_custom(report_rml):
row_id=1
if data['model']=='hr.employee':
-
- for id in data['form']['emp'][0][2]:
+ for id in data['form']['emp']:
items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr,uid,id,['id','name'])
emp_xml += emp_create_xml(self,cr,uid,0,holiday_type,row_id,items['id'],items['name'],som, eom)
row_id = row_id +1
-
+
elif data['model']=='ir.ui.menu':
- for id in data['form']['depts'][0][2]:
+ for id in data['form']['depts']:
dept = pooler.get_pool(cr.dbname).get('hr.department').browse(cr, uid, id, context.copy())
depts.append(dept)
- dept_ids = tuple(data['form']['depts'][0][2])
-
+ dept_ids = tuple(data['form']['depts'])
+
cr.execute("""select dept_user.user_id \
from hr_department_user_rel dept_user \
where dept_user.department_id = %s\
@@ -258,7 +257,7 @@ class report_custom(report_rml):
%s
''' % (months_xml,date_xml, emp_xml)
-
+
return xml
report_custom('report.holidays.summary', 'hr.holidays', '', 'addons/hr_holidays/report/holidays_summary.xsl')
diff --git a/addons/hr_holidays/wizard/__init__.py b/addons/hr_holidays/wizard/__init__.py
index 310328a15c1..19228a07fac 100644
--- a/addons/hr_holidays/wizard/__init__.py
+++ b/addons/hr_holidays/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,11 +15,12 @@
# 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 holidays_summary
-import holidays_summary_employees
+import hr_holidays_summary_department
+import hr_holidays_summary_employees
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_holidays/wizard/holidays_summary.py b/addons/hr_holidays/wizard/holidays_summary.py
deleted file mode 100644
index 0b6a05247f0..00000000000
--- a/addons/hr_holidays/wizard/holidays_summary.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
-#
-# 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 datetime
-import time
-import pooler
-
-form='''
-'''
-
-zero_form='''
-'''
-
-zero_fields={
-}
-
-class wizard_report(wizard.interface):
- def _check(self, cr, uid, data, context):
- data['form']['date_from']=time.strftime('%Y-%m-%d')
- data['form']['holiday_type']='Validated'
-
- return data['form']
-
- def _checkdepts(self, cr, uid, data, context):
-
- if len(data['form']['depts'][0][2])==0:
- return 'notify'
- else:
- return 'report'
-
- fields={
- 'date_from':{
- 'string':'From',
- 'type':'date',
- 'required':True,
- },
- 'depts': {
- 'string': 'Department(s)',
- 'type': 'many2many',
- 'relation': 'hr.department'
- },
- 'holiday_type':{
- 'string':"Select Holiday Type",
- 'required':True,
- 'type':'selection',
- 'selection':[('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')]
- },
- }
-
- states={
- 'init':{
- 'actions':[_check],
- 'result':{'type':'form', 'arch':form, 'fields':fields, 'state':[('end', 'Cancel', 'gtk-cancel'), ('checkdept', 'Print', 'gtk-print')]}
- },
- 'checkdept': {
- 'actions': [],
- 'result': {'type':'choice','next_state':_checkdepts}
- },
- 'notify': {
- 'actions': [],
- 'result': {'type':'form','arch':zero_form,'fields':zero_fields,'state':[('end','Ok', 'gtk-ok')]}
- },
- 'report':{
- 'actions':[],
- 'result':{'type':'print', 'report':'holidays.summary', 'state':'end'}
- }
- }
-wizard_report('hr.holidays.summary')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/hr_holidays/wizard/holidays_summary_employees.py b/addons/hr_holidays/wizard/holidays_summary_employees.py
deleted file mode 100644
index bdc5664abfb..00000000000
--- a/addons/hr_holidays/wizard/holidays_summary_employees.py
+++ /dev/null
@@ -1,87 +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 datetime
-import time
-import pooler
-
-
-form='''
-'''
-
-zero_form='''
-'''
-
-zero_fields={
-}
-
-class wizard_report(wizard.interface):
- def _check(self, cr, uid, data, context):
- data['form']['date_from']=time.strftime('%Y-%m-%d')
- data['form']['holiday_type']='Validated'
- data['form']['emp'] = data['ids']
- return data['form']
-
- def _checkemps(self, cr, uid, data, context):
-
- if len(data['form']['emp'][0][2])==0:
- return 'notify'
- else:
- return 'report'
-
- fields={
- 'date_from':{
- 'string':'From',
- 'type':'date',
- 'required':True,
- },
- 'holiday_type':{'string':"Select Holiday Type",'type':'selection','selection':[('Validated','Validated'),('Confirmed','Confirmed'),('both','Both')]},
- 'emp': {'string': 'Employee(s)', 'type': 'many2many', 'relation': 'hr.employee'},
- }
-
- states={
- 'init':{
- 'actions':[_check],
- 'result':{'type':'form', 'arch':form, 'fields':fields, 'state':[('end', 'Cancel','gtk-cancel'), ('checkemp', 'Print', 'gtk-print')]}
- },
- 'checkemp': {
- 'actions': [],
- 'result': {'type':'choice','next_state':_checkemps}
- },
- 'notify': {
- 'actions': [],
- 'result': {'type':'form','arch':zero_form,'fields':zero_fields,'state':[('end','Ok', 'gtk-ok')]}
- },
- 'report':{
- 'actions':[],
- 'result':{'type':'print', 'report':'holidays.summary', 'state':'end'}
- }
- }
-wizard_report('hr.holidays.summary.employee')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_department.py b/addons/hr_holidays/wizard/hr_holidays_summary_department.py
new file mode 100644
index 00000000000..5e35bbdb916
--- /dev/null
+++ b/addons/hr_holidays/wizard/hr_holidays_summary_department.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
+#
+# 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 osv, fields
+from tools.translate import _
+
+class hr_holidays_summary_dept(osv.osv_memory):
+ _name = 'hr.holidays.summary.dept'
+ _description = 'HR Holidays Summary Report By Department'
+ _columns = {
+ 'date_from': fields.date('From', required=True),
+ 'depts': fields.many2many('hr.department', 'summary_dept_rel', 'sum_id', 'dept_id', 'Department(s)'),
+ 'holiday_type': fields.selection([('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')], 'Select Holiday Type', required=True)
+ }
+
+ _defaults = {
+ 'date_from': time.strftime('%Y-%m-%d'),
+ 'holiday_type': 'Validated'
+ }
+
+ def print_report(self, cr, uid, ids, context=None):
+ data = self.read(cr, uid, ids, [])[0]
+ if not data['depts']:
+ raise osv.except_osv(_('Error'), _('You have to select at least 1 Department. And try again'))
+ datas = {
+ 'ids': [],
+ 'model': 'ir.ui.menu',
+ 'form': data
+ }
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'holidays.summary',
+ 'datas': datas,
+ }
+
+hr_holidays_summary_dept()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_department_view.xml b/addons/hr_holidays/wizard/hr_holidays_summary_department_view.xml
new file mode 100644
index 00000000000..fabc11d6021
--- /dev/null
+++ b/addons/hr_holidays/wizard/hr_holidays_summary_department_view.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+ hr.holidays.summary.dept.form
+ hr.holidays.summary.dept
+ form
+
+
+
+
+
+
+ Holidays by Departement
+ ir.actions.act_window
+ hr.holidays.summary.dept
+ form
+ form
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_employees.py b/addons/hr_holidays/wizard/hr_holidays_summary_employees.py
new file mode 100644
index 00000000000..1452c864c7f
--- /dev/null
+++ b/addons/hr_holidays/wizard/hr_holidays_summary_employees.py
@@ -0,0 +1,56 @@
+# -*- 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 osv, fields
+from tools.translate import _
+
+class hr_holidays_summary_employee(osv.osv_memory):
+ _name = 'hr.holidays.summary.employee'
+ _description = 'HR Holidays Summary Report By Employee'
+ _columns = {
+ 'date_from': fields.date('From', required=True),
+ 'emp': fields.many2many('hr.employee', 'summary_emp_rel', 'sum_id', 'emp_id', 'Employee(s)'),
+ 'holiday_type': fields.selection([('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')], 'Select Holiday Type', required=True)
+ }
+
+ _defaults = {
+ 'date_from': time.strftime('%Y-%m-%d'),
+ 'holiday_type': 'Validated',
+ }
+
+ def print_report(self, cr, uid, ids, context=None):
+ data = self.read(cr, uid, ids, [])[0]
+ data['emp'] = context['active_ids']
+ datas = {
+ 'ids': [],
+ 'model': 'hr.employee',
+ 'form': data
+ }
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'holidays.summary',
+ 'datas': datas,
+ }
+
+hr_holidays_summary_employee()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_employees_view.xml b/addons/hr_holidays/wizard/hr_holidays_summary_employees_view.xml
new file mode 100644
index 00000000000..0957083a136
--- /dev/null
+++ b/addons/hr_holidays/wizard/hr_holidays_summary_employees_view.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+ hr.holidays.summary.employee.form
+ hr.holidays.summary.employee
+ form
+
+
+
+
+
+
+ Employee's Holidays
+ ir.actions.act_window
+ hr.holidays.summary.employee
+ form
+ form
+ new
+
+
+
+
+
+ Employee's Holidays
+ client_print_multi
+
+ action
+ hr.employee
+
+
+
+
\ No newline at end of file
diff --git a/addons/hr_recruitment/__terp__.py b/addons/hr_recruitment/__openerp__.py
similarity index 100%
rename from addons/hr_recruitment/__terp__.py
rename to addons/hr_recruitment/__openerp__.py
diff --git a/addons/hr_timesheet/__terp__.py b/addons/hr_timesheet/__openerp__.py
similarity index 100%
rename from addons/hr_timesheet/__terp__.py
rename to addons/hr_timesheet/__openerp__.py
diff --git a/addons/hr_timesheet/hr_timesheet_wizard.xml b/addons/hr_timesheet/hr_timesheet_wizard.xml
index b5f270fe0e8..8d84a261ba6 100644
--- a/addons/hr_timesheet/hr_timesheet_wizard.xml
+++ b/addons/hr_timesheet/hr_timesheet_wizard.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/addons/hr_timesheet_invoice/__terp__.py b/addons/hr_timesheet_invoice/__openerp__.py
similarity index 100%
rename from addons/hr_timesheet_invoice/__terp__.py
rename to addons/hr_timesheet_invoice/__openerp__.py
diff --git a/addons/hr_timesheet_sheet/__terp__.py b/addons/hr_timesheet_sheet/__openerp__.py
similarity index 100%
rename from addons/hr_timesheet_sheet/__terp__.py
rename to addons/hr_timesheet_sheet/__openerp__.py
diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
index 11ca09f5735..81b86fecfa6 100644
--- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
+++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
@@ -332,5 +332,8 @@
+
+
+
diff --git a/addons/membership/__terp__.py b/addons/membership/__openerp__.py
similarity index 100%
rename from addons/membership/__terp__.py
rename to addons/membership/__openerp__.py
diff --git a/addons/olap/wizard/olap_load_column.py b/addons/olap/wizard/olap_load_column.py
old mode 100755
new mode 100644
diff --git a/addons/olap/wizard/olap_query_logs_clear.py b/addons/olap/wizard/olap_query_logs_clear.py
old mode 100755
new mode 100644
diff --git a/addons/project/__terp__.py b/addons/project/__openerp__.py
similarity index 97%
rename from addons/project/__terp__.py
rename to addons/project/__openerp__.py
index 65e3c58fb5e..3c7e80d4c11 100644
--- a/addons/project/__terp__.py
+++ b/addons/project/__openerp__.py
@@ -33,6 +33,7 @@ works done on tasks, eso. It is able to render planning, order tasks, eso.
"init_xml" : [],
"update_xml": [
"security/project_security.xml",
+ "wizard/project_task_delegate_view.xml",
"security/ir.model.access.csv",
"project_data.xml",
"project_wizard.xml",
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 1d87596eb61..cc1567afdcb 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -247,7 +247,7 @@
attrs="{'readonly':[('state','!=','draft')]}"
on_change="onchange_planned(planned_hours, effective_hours)"/>
-
+
@@ -270,7 +270,7 @@
-
+
@@ -349,7 +349,7 @@
-
+
diff --git a/addons/project/project_wizard.xml b/addons/project/project_wizard.xml
index 934fa57ee9c..25001605210 100644
--- a/addons/project/project_wizard.xml
+++ b/addons/project/project_wizard.xml
@@ -2,7 +2,7 @@
-
+
-
-
-
-
+
diff --git a/addons/project_gtd/wizard/project_gtd_daily.py b/addons/project_gtd/wizard/project_gtd_daily.py
index 68b2a0d8ce3..bacc1af85d9 100644
--- a/addons/project_gtd/wizard/project_gtd_daily.py
+++ b/addons/project_gtd/wizard/project_gtd_daily.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,32 +15,28 @@
# 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
-import netsvc
-import time
-import pooler
-from osv import osv
+from osv import osv, fields
from tools.translate import _
-class wiz_timebox_open(wizard.interface):
- def _open_timebox(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- ids = pool.get('project.gtd.timebox').search(cr, uid, [])
+class project_timebox_open(osv.osv_memory):
+
+ _name = 'project.timebox.open'
+ _description = 'Project Timebox Open'
+
+ def open_tb(self, cr, uid, data, context=None):
+ ids = self.pool.get('project.gtd.timebox').search(cr, uid, [])
if not len(ids):
- raise wizard.except_wizard(_('Error !'), _('No timebox of the type "%s" defined !') % (tbtype,))
- view_type = 'form,tree'
+ raise osv.except_osv(_('Error !'), _('No timebox of the type defined !'))
if len(ids) >= 1:
domain = "[('id','in',["+','.join(map(str, ids))+"])]"
value = {
'domain': domain,
'name': 'My Daily Timebox',
'view_type': 'form',
- 'view_mode': view_type,
+ 'view_mode': 'form,tree',
'res_model': 'project.gtd.timebox',
'view_id': False,
'type': 'ir.actions.act_window'
@@ -50,13 +46,6 @@ class wiz_timebox_open(wizard.interface):
value['context'] = {'record_id':ids[0]}
return value
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type':'action', 'action':_open_timebox, 'state':'end'}
- }
- }
-wiz_timebox_open('project.gtd.timebox.daily')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+project_timebox_open()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_gtd/wizard/project_gtd_daily_view.xml b/addons/project_gtd/wizard/project_gtd_daily_view.xml
new file mode 100644
index 00000000000..5b3e7d3d9e1
--- /dev/null
+++ b/addons/project_gtd/wizard/project_gtd_daily_view.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+ My Daily Timebox
+ project.timebox.open
+ form
+
+
+
+
+
+
+ My Daily Timebox
+ ir.actions.act_window
+ project.timebox.open
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+ My Daily Timebox
+ client_action_multi
+
+ action
+ project.gtd.timebox
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/project_gtd/wizard/project_gtd_empty.py b/addons/project_gtd/wizard/project_gtd_empty.py
index a2ebe2e8dba..4eb4de12c12 100644
--- a/addons/project_gtd/wizard/project_gtd_empty.py
+++ b/addons/project_gtd/wizard/project_gtd_empty.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,46 +15,52 @@
# 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
-import netsvc
-import time
-import pooler
-from osv import osv
+from osv import osv, fields
from tools.translate import _
-class wiz_timebox_empty(wizard.interface):
- def _empty(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- ids = pool.get('project.gtd.timebox').search(cr, uid, [])
- if not len(ids):
- raise wizard.except_wizard(_('Error !'), _('No timebox child of this one !'))
- tids = pool.get('project.task').search(cr, uid, [('timebox_id','=',data['id'])])
+class project_timebox_empty(osv.osv_memory):
+
+ _name = 'project.timebox.empty'
+ _description = 'Project Timebox Empty'
+ _columns = {
+ 'name': fields.char('Name', size=32)
+ }
+
+ def view_init(self, cr , uid , fields_list, context=None):
+ if context is None:
+ context = {}
+ self._empty(cr, uid, context=context)
+ pass
+
+ def _empty(self, cr, uid, context=None):
close = []
up = []
- for task in pool.get('project.task').browse(cr, uid, tids, context):
- if (task.state in ('cancel','done')) or (task.user_id.id<>uid):
+ obj_tb = self.pool.get('project.gtd.timebox')
+ obj_task = self.pool.get('project.task')
+
+ if context is None:
+ context = {}
+ if not 'active_id' in context:
+ return {}
+
+ ids = obj_tb.search(cr, uid, [], context=context)
+ if not len(ids):
+ raise osv.except_osv(_('Error !'), _('No timebox child of this one !'))
+ tids = obj_task.search(cr, uid, [('timebox_id', '=', context['active_id'])])
+ for task in obj_task.browse(cr, uid, tids, context):
+ if (task.state in ('cancel','done')) or (task.user_id.id <> uid):
close.append(task.id)
else:
up.append(task.id)
if up:
- pool.get('project.task').write(cr, uid, up, {'timebox_id':ids[0]})
+ obj_task.write(cr, uid, up, {'timebox_id':ids[0]})
if close:
- pool.get('project.task').write(cr, uid, close, {'timebox_id':False})
+ obj_task.write(cr, uid, close, {'timebox_id':False})
return {}
- states = {
- 'init' : {
- 'actions' : [_empty],
- 'result' : {'type':'state', 'state':'end'}
- }
- }
-wiz_timebox_empty('project.gtd.timebox.empty')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+project_timebox_empty()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_gtd/wizard/project_gtd_empty_view.xml b/addons/project_gtd/wizard/project_gtd_empty_view.xml
new file mode 100644
index 00000000000..ef71ae72978
--- /dev/null
+++ b/addons/project_gtd/wizard/project_gtd_empty_view.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Empty Timebox
+ project.timebox.empty
+ form
+
+
+
+
+
+
+ Empty Timebox
+ ir.actions.act_window
+ project.timebox.empty
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+ Empty Timebox
+ client_action_multi
+
+ action
+ project.gtd.timebox
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/project_gtd/wizard/project_gtd_fill.py b/addons/project_gtd/wizard/project_gtd_fill.py
index ca3964d34c5..8b39dac16ae 100644
--- a/addons/project_gtd/wizard/project_gtd_fill.py
+++ b/addons/project_gtd/wizard/project_gtd_fill.py
@@ -19,59 +19,43 @@
#
##############################################################################
+from osv import osv, fields
-import wizard
-import pooler
-from osv import osv
+class project_timebox_fill(osv.osv_memory):
-_gtd_field = {
- 'task_ids': {'relation':'project.task', 'type':'many2many', 'string':'Tasks selection'},
- 'timebox_to_id': {'relation':'project.gtd.timebox', 'type':'many2one', 'string':'Set to Timebox'},
- 'timebox_id': {'relation':'project.gtd.timebox', 'type':'many2one', 'string':'Get from Timebox'}
-}
+ _name = 'project.timebox.fill.plan'
+ _description = 'Project Timebox Fill'
+ _columns = {
+ 'timebox_id': fields.many2one('project.gtd.timebox', 'Get from Timebox', required=True),
+ 'timebox_to_id': fields.many2one('project.gtd.timebox', 'Set to Timebox', required=True),
+ 'task_ids': fields.many2many('project.task', 'project_task_rel', 'task_id', 'fill_id', 'Tasks selection')
+ }
-_gtd_arch = """
-
-"""
+ def _get_from_tb(self, cr, uid, context=None):
+ ids = self.pool.get('project.gtd.timebox').search(cr, uid, [], context=context)
+ return ids and ids[0] or False
-class wiz_timebox_fill(wizard.interface):
- def _fill(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- ids = pool.get('project.gtd.timebox').search(cr, uid, [], context=context)
- return {
- 'timebox_id': ids and ids[0] or False,
- 'timebox_to_id': data['id']
- }
+ def _get_to_tb(self, cr, uid, context=None):
+ if 'active_id' in context:
+ return context['active_id']
+ return False
- def _process(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- ids = data['form']['task_ids']
- pool.get('project.task').write(cr, uid, ids[0][2], {'timebox_id':data['form']['timebox_to_id']})
+ _defaults = {
+ 'timebox_id': _get_from_tb,
+ 'timebox_to_id': _get_to_tb,
+ }
+
+ def process(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+ if not ids:
+ return {}
+ data = self.read(cr, uid, ids, [])
+ if not data[0]['task_ids']:
+ return {}
+ self.pool.get('project.task').write(cr, uid, data[0]['task_ids'], {'timebox_id':data[0]['timebox_to_id']})
return {}
- states = {
- 'init' : {
- 'actions' : [_fill],
- 'result' : {
- 'type':'form',
- 'arch':_gtd_arch,
- 'fields':_gtd_field,
- 'state':[
- ('end','Cancel', 'gtk-cancel'),
- ('process','Add to Timebox')
- ]
- }
- },
- 'process' : {
- 'actions' : [_process],
- 'result' : {'type':'state', 'state':'end'}
- }
- }
-wiz_timebox_fill('project.gtd.timebox.fill')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+project_timebox_fill()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_gtd/wizard/project_gtd_fill_view.xml b/addons/project_gtd/wizard/project_gtd_fill_view.xml
new file mode 100644
index 00000000000..1c3d221c6ac
--- /dev/null
+++ b/addons/project_gtd/wizard/project_gtd_fill_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ Plannify Timebox
+ project.timebox.fill.plan
+ form
+
+
+
+
+
+
+ Plannify Timebox
+ ir.actions.act_window
+ project.timebox.fill.plan
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+ Plannify Timebox
+ client_action_multi
+
+ action
+ project.gtd.timebox
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/project_issue/__init__.py b/addons/project_issue/__init__.py
index 4ee524bb479..c51b756f4ca 100644
--- a/addons/project_issue/__init__.py
+++ b/addons/project_issue/__init__.py
@@ -20,7 +20,6 @@
#
##############################################################################
-
import project_issue
import report
import wizard
diff --git a/addons/project_issue/__terp__.py b/addons/project_issue/__openerp__.py
similarity index 93%
rename from addons/project_issue/__terp__.py
rename to addons/project_issue/__openerp__.py
index 03ec9e22285..2bf67d47191 100644
--- a/addons/project_issue/__terp__.py
+++ b/addons/project_issue/__openerp__.py
@@ -39,10 +39,8 @@
'project_issue_data.xml'
],
'update_xml': [
- 'project_issue_wizard.xml',
'project_issue_view.xml',
- 'project_issue_menu.xml',
- 'project_feature_menu.xml',
+ 'project_issue_menu.xml',
'report/project_issue_report_view.xml',
'security/project_issue_security.xml',
'security/ir.model.access.csv',
diff --git a/addons/project_issue/project_feature_menu.xml b/addons/project_issue/project_feature_menu.xml
deleted file mode 100644
index 1c757a73909..00000000000
--- a/addons/project_issue/project_feature_menu.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index 1fb1c353bab..3f35913ae75 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -23,11 +23,11 @@ import base64
import os
import re
import time
-import time
-import tools
-from crm import crm
import mx.DateTime
from datetime import datetime, timedelta
+
+import tools
+from crm import crm
from osv import fields,osv,orm
from osv.orm import except_orm
from tools.translate import _
@@ -58,9 +58,9 @@ class project_issue(osv.osv):
@param ids: List of Openday’s IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
- """
- cal_obj = self.pool.get('resource.calendar')
- res_obj = self.pool.get('resource.resource')
+ """
+ cal_obj = self.pool.get('resource.calendar')
+ res_obj = self.pool.get('resource.resource')
res = {}
for issue in self.browse(cr, uid, ids , context):
@@ -88,7 +88,7 @@ class project_issue(osv.osv):
duration = float(ans.days)
if issue.section_id.resource_calendar_id:
- duration = float(ans.days) * 24
+ duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr,
uid,
issue.section_id.resource_calendar_id and issue.section_id.resource_calendar_id.id or False,
@@ -100,9 +100,9 @@ class project_issue(osv.osv):
date_until = mx.DateTime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
for in_time, out_time in new_dates:
if in_time.date not in no_days:
- no_days.append(in_time.date)
+ no_days.append(in_time.date)
if out_time > date_until:
- break
+ break
duration = len(no_days)
res[issue.id][field] = abs(int(duration))
return res
@@ -140,6 +140,60 @@ class project_issue(osv.osv):
return user.context_project_id
return False
+ def convert_issue_task(self, cr, uid, ids, context=None):
+ case_obj = self.pool.get('project.issue')
+ data_obj = self.pool.get('ir.model.data')
+ task_obj = self.pool.get('project.task')
+
+ if context is None:
+ context = {}
+
+# for case in case_obj.browse(cr, uid, ids, context=context):
+# if case.state != 'open':
+# raise osv.except_osv(_('Warning !'),
+# _('Issues or Feature Requests should be in \'Open\' state before converting into Task.'))
+
+ result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
+ res = data_obj.read(cr, uid, result, ['res_id'])
+ id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
+ id3 = data_obj._get_id(cr, uid, 'project', 'view_task_tree2')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+ if id3:
+ id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+
+ for bug in case_obj.browse(cr, uid, ids, context=context):
+ new_task_id = task_obj.create(cr, uid, {
+ 'name': bug.name,
+ 'partner_id': bug.partner_id.id,
+ 'description':bug.description,
+ 'date': bug.date,
+ 'project_id':bug.project_id.id,
+ 'priority':bug.priority,
+ 'user_id':bug.user_id.id,
+ 'planned_hours': 0.0,
+ })
+
+ new_task = task_obj.browse(cr, uid, new_task_id)
+
+ vals = {
+ 'task_id': new_task_id,
+ }
+ case_obj.write(cr, uid, [bug.id], vals)
+
+ return {
+ 'name': _('Tasks'),
+ 'view_type': 'form',
+ 'view_mode': 'form,tree',
+ 'res_model': 'project.task',
+ 'res_id': int(new_task_id),
+ 'view_id': False,
+ 'views': [(id2,'form'),(id3,'tree'),(False,'calendar'),(False,'graph')],
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': res['res_id'],
+ 'nodestroy': True
+ }
+
def _convert(self, cr, uid, ids, xml_id, context=None):
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)
diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml
index b9c0573ea57..343005d25d7 100644
--- a/addons/project_issue/project_issue_view.xml
+++ b/addons/project_issue/project_issue_view.xml
@@ -54,8 +54,8 @@
@@ -220,6 +220,21 @@
/>
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/project_issue/project_issue_wizard.xml b/addons/project_issue/project_issue_wizard.xml
deleted file mode 100644
index 16e54da49d7..00000000000
--- a/addons/project_issue/project_issue_wizard.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/addons/project_issue/wizard/__init__.py b/addons/project_issue/wizard/__init__.py
deleted file mode 100644
index 3ae599d66c3..00000000000
--- a/addons/project_issue/wizard/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL (). All Rights Reserved
-# $Id$
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-
-import project_issue_wizard
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_issue/wizard/project_issue_wizard.py b/addons/project_issue/wizard/project_issue_wizard.py
deleted file mode 100644
index 4aef1529619..00000000000
--- a/addons/project_issue/wizard/project_issue_wizard.py
+++ /dev/null
@@ -1,98 +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 .
-#
-##############################################################################
-
-from mx.DateTime import now
-
-import wizard
-import netsvc
-import ir
-import pooler
-from tools.translate import _
-
-class issue2task(wizard.interface):
-
- def _check_state(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- case_obj = pool.get('project.issue')
- for case in case_obj.browse(cr, uid, data['ids']):
- if case.state != 'open':
- raise wizard.except_wizard(_('Warning !'),
- _('Issues or Feature Requests should be in \'Open\' state before converting into Task.'))
- return {}
-
- def _makeTask(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- data_obj = pool.get('ir.model.data')
- result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
- res = data_obj.read(cr, uid, result, ['res_id'])
-
-
- id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
- id3 = data_obj._get_id(cr, uid, 'project', 'view_task_tree2')
- if id2:
- id2 = data_obj.browse(cr, uid, id2, context=context).res_id
- if id3:
- id3 = data_obj.browse(cr, uid, id3, context=context).res_id
-
- bug_case_obj = pool.get('project.issue')
- task_obj = pool.get('project.task')
- for bug in bug_case_obj.browse(cr, uid, data['ids']):
- new_task_id = task_obj.create(cr, uid, {
- 'name': bug.name,
- 'partner_id': bug.partner_id.id,
- 'description':bug.description,
- 'date': bug.date,
- 'project_id':bug.project_id.id,
- 'priority':bug.priority,
- 'user_id':bug.user_id.id,
- 'planned_hours': 0.0,
- })
-
- new_task = task_obj.browse(cr, uid, new_task_id)
-
- vals = {
- 'task_id': new_task_id,
- }
-
- bug_case_obj.write(cr, uid, [bug.id], vals)
-
- value = {
- 'name': _('Tasks'),
- 'view_type': 'form',
- 'view_mode': 'form,tree',
- 'res_model': 'project.task',
- 'res_id': int(new_task_id),
- 'view_id': False,
- 'views': [(id2,'form'),(id3,'tree'),(False,'calendar'),(False,'graph')],
- 'type': 'ir.actions.act_window',
- 'search_view_id': res['res_id']
- }
- return value
-
- states = {
- 'init': {
- 'actions': [_check_state],
- 'result': {'type': 'action', 'action': _makeTask, 'state':'end' }
- }
- }
-
-issue2task('project.issue.task_set')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_long_term/__terp__.py b/addons/project_long_term/__openerp__.py
similarity index 92%
rename from addons/project_long_term/__terp__.py
rename to addons/project_long_term/__openerp__.py
index 25529f5b245..99bce80caca 100644
--- a/addons/project_long_term/__terp__.py
+++ b/addons/project_long_term/__openerp__.py
@@ -41,8 +41,12 @@
"update_xml": [
"security/ir.model.access.csv",
"project_long_term_wizard.xml" ,
+ "wizard/project_schedule_tasks_view.xml",
"project_long_term_view.xml",
- "project_long_term_workflow.xml"
+ "project_long_term_workflow.xml",
+ "wizard/project_compute_phases_view.xml",
+ "wizard/project_compute_tasks_view.xml",
+
],
'installable': True,
'active': False,
diff --git a/addons/project_long_term/project_long_term_view.xml b/addons/project_long_term/project_long_term_view.xml
index 4e3b746aa2a..0be0f88a576 100644
--- a/addons/project_long_term/project_long_term_view.xml
+++ b/addons/project_long_term/project_long_term_view.xml
@@ -135,7 +135,7 @@
-
+
diff --git a/addons/project_long_term/project_long_term_wizard.xml b/addons/project_long_term/project_long_term_wizard.xml
index 0904bbb4429..98dfabb323e 100644
--- a/addons/project_long_term/project_long_term_wizard.xml
+++ b/addons/project_long_term/project_long_term_wizard.xml
@@ -2,25 +2,25 @@
-
-
-
+
+
+
-
-
-
diff --git a/addons/project_long_term/wizard/__init__.py b/addons/project_long_term/wizard/__init__.py
index 06880dbe6e2..fb8a29449f7 100644
--- a/addons/project_long_term/wizard/__init__.py
+++ b/addons/project_long_term/wizard/__init__.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-s
##############################################################################
#
# OpenERP, Open Source Management Solution
@@ -19,9 +19,9 @@
#
##############################################################################
-import compute_phases_date
-import compute_tasks_date
-import schedule_tasks
+import project_compute_phases
+import project_compute_tasks
+import project_schedule_tasks
import working_calendar
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_long_term/wizard/compute_phases_date.py b/addons/project_long_term/wizard/project_compute_phases.py
similarity index 77%
rename from addons/project_long_term/wizard/compute_phases_date.py
rename to addons/project_long_term/wizard/project_compute_phases.py
index 61f3bb42251..ddf8ba315c0 100644
--- a/addons/project_long_term/wizard/compute_phases_date.py
+++ b/addons/project_long_term/wizard/project_compute_phases.py
@@ -22,26 +22,32 @@ import datetime
from resource.faces import *
from new import classobj
-import wizard
-import pooler
from tools.translate import _
+from osv import fields, osv
import working_calendar as wkcal
-compute_form = """
-"""
+ 'project_id': fields.many2one('project.project', 'Project')
+ }
-compute_fields = {
- 'project_id': {'string':'Project', 'type':'many2one', 'relation':'project.project', 'help': 'If you do not specify project then it will take All projects with state=draft, open, pending'},
+ _defaults = {
+ 'target_project': 'all'
+ }
-}
+ def check_selection(self, cr, uid, ids, context=None):
+ data_select = self.read(cr, uid, ids, ['target_project'])[0]
+ return self.compute_date(cr, uid, ids, context=context)
-class wizard_compute_phases(wizard.interface):
- def _phase_schedule(self, cr, uid, phase, start_date, calendar_id=False, context={}):
+ def _phase_schedule(self, cr, uid, phase, start_date, calendar_id=False, context=None):
"""Schedule phase with the start date till all the next phases are completed.
@@ -49,11 +55,13 @@ class wizard_compute_phases(wizard.interface):
calendar_id -- working calendar of the project
"""
- pool = pooler.get_pool(cr.dbname)
- phase_obj = pool.get('project.phase')
- resource_obj = pool.get('resource.resource')
- uom_obj = pool.get('product.uom')
+ phase_obj = self.pool.get('project.phase')
+ resource_obj = self.pool.get('resource.resource')
+ uom_obj = self.pool.get('product.uom')
phase_resource_obj = False
+
+ if context is None:
+ context = {}
if phase:
leaves = []
time_efficiency = 1.0
@@ -117,15 +125,20 @@ class wizard_compute_phases(wizard.interface):
else:
continue
- def _compute_date(self, cr, uid, data, context={}):
+ def compute_date(self, cr, uid, ids, context=None):
"""
Compute the phases for scheduling.
"""
- pool = pooler.get_pool(cr.dbname)
- project_obj = pool.get('project.project')
- phase_obj = pool.get('project.phase')
- if data['form']['project_id']: # If project mentioned find its phases
- project_id = project_obj.browse(cr, uid, data['form']['project_id'], context=context)
+
+ if context is None:
+ context = {}
+ project_obj = self.pool.get('project.project')
+ phase_obj = self.pool.get('project.phase')
+ data = self.read(cr, uid, ids, [], context=context)[0]
+ if not data['project_id'] and data['target_project'] == 'one':
+ raise osv.except_osv(_('Error!'), _('Please Specify Project to be schedule'))
+ if data['project_id']: # If project mentioned find its phases
+ project_id = project_obj.browse(cr, uid, data['project_id'], context=context)
phase_ids = phase_obj.search(cr, uid, [('project_id', '=', project_id.id),
('state', 'in', ['draft', 'open', 'pending']),
('previous_phase_ids', '=', False)
@@ -143,37 +156,24 @@ class wizard_compute_phases(wizard.interface):
start_dt = datetime.datetime.strftime((datetime.datetime.strptime(start_date, "%Y-%m-%d")), "%Y-%m-%d %H:%M")
calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False
self._phase_schedule(cr, uid, phase, start_dt, calendar_id, context=context)
- return {}
+ return self._open_phases_list(cr, uid, data, context=context)
- def _open_phases_list(self, cr, uid, data, context):
+ def _open_phases_list(self, cr, uid, data, context=None):
"""
Return the scheduled phases list.
"""
- pool = pooler.get_pool(cr.dbname)
- mod_obj = pool.get('ir.model.data')
- act_obj = pool.get('ir.actions.act_window')
+ if context is None:
+ context = {}
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'project_long_term', 'act_project_phase')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id], context=context)[0]
result['domain'] = [('state', 'not in', ['cancelled','done'])]
- if data['form']['project_id']:
- result['domain'] = [('project_id', '=', data['form']['project_id']),
+ if data['project_id']:
+ result['domain'] = [('project_id', '=', data['project_id']),
('state', 'not in', ['cancelled','done'])]
return result
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': compute_form, 'fields': compute_fields, 'state':[
- ('end', 'Cancel', 'gtk-cancel'),
- ('compute', 'Compute', 'gtk-ok', True)
-
- ]},
- },
- 'compute': {
- 'actions': [_compute_date],
- 'result': {'type': 'action', 'action': _open_phases_list, 'state': 'end'},
- },
- }
-wizard_compute_phases('wizard.compute.phases')
+project_compute_phases()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_long_term/wizard/project_compute_phases_view.xml b/addons/project_long_term/wizard/project_compute_phases_view.xml
new file mode 100644
index 00000000000..900112ba409
--- /dev/null
+++ b/addons/project_long_term/wizard/project_compute_phases_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ Compute Scheduling of Phases
+ project.compute.phases
+ form
+
+
+
+
+
+
+ Compute Phase Scheduling
+ ir.actions.act_window
+ project.compute.phases
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/project_long_term/wizard/compute_tasks_date.py b/addons/project_long_term/wizard/project_compute_tasks.py
similarity index 81%
rename from addons/project_long_term/wizard/compute_tasks_date.py
rename to addons/project_long_term/wizard/project_compute_tasks.py
index 77e7bbd6512..90d2b428580 100644
--- a/addons/project_long_term/wizard/compute_tasks_date.py
+++ b/addons/project_long_term/wizard/project_compute_tasks.py
@@ -23,38 +23,32 @@ from resource.faces import *
from new import classobj
import operator
+from tools.translate import _
+from osv import osv, fields
+
import working_calendar as wkcal
-import wizard
-import pooler
-from tools.translate import _
+class project_compute_tasks(osv.osv_memory):
+ _name = 'project.compute.tasks'
+ _description = 'Project Compute Tasks'
+ _columns = {
+ 'project_id': fields.many2one('project.project', 'Project', required=True)
+ }
-compute_form = """
-"""
-
-success_msg = """
-"""
-
-compute_fields = {
- 'project_id': {'string':'Project', 'type':'many2one', 'relation':'project.project', 'required':True},
-}
-
-class wizard_compute_tasks(wizard.interface):
-
- def _compute_date(self, cr, uid, data, context):
+ def compute_date(self, cr, uid, ids, context=None):
"""
Schedule the tasks according to resource available and priority.
"""
- pool = pooler.get_pool(cr.dbname)
- project_obj = pool.get('project.project')
- task_pool = pool.get('project.task')
- resource_obj = pool.get('resource.resource')
- user_obj = pool.get('res.users')
- project_id = data['form']['project_id']
+ project_obj = self.pool.get('project.project')
+ task_pool = self.pool.get('project.task')
+ resource_obj = self.pool.get('resource.resource')
+ user_obj = self.pool.get('res.users')
+
+ if context is None:
+ context = {}
+
+ data = self.read(cr, uid, ids, [])[0]
+ project_id = data['project_id']
project = project_obj.browse(cr, uid, project_id, context=context)
task_ids = task_pool.search(cr, uid, [('project_id', '=', project_id),
('state', 'in', ['draft', 'open', 'pending'])
@@ -106,7 +100,7 @@ class wizard_compute_tasks(wizard.interface):
try:
resource = reduce(operator.or_, resources)
except:
- raise wizard.except_wizard(_('Error'), _('Project must have members assigned !'))
+ raise osv.except_osv(_('Error'), _('Project must have members assigned !'))
minimum_time_unit = 1
if calendar_id: # If project has calendar
working_days = wkcal.compute_working_calendar(cr, uid, calendar_id)
@@ -142,20 +136,7 @@ class wizard_compute_tasks(wizard.interface):
'user_id': user_id[0]},
context=ctx)
loop_no +=1
- return {}
+ return {} #improve me => Task Scheduling completed successfully => give this msg at end of wizard
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': compute_form, 'fields': compute_fields, 'state': [
- ('end', 'Cancel', 'gtk-cancel'),
- ('compute', 'Compute', 'gtk-ok', True)
- ]},
- },
- 'compute': {
- 'actions': [_compute_date],
- 'result': {'type': 'form','arch': success_msg,'fields': {}, 'state': [('end', 'Ok')]},
- }
- }
-wizard_compute_tasks('wizard.compute.tasks')
+project_compute_tasks()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_long_term/wizard/project_compute_tasks_view.xml b/addons/project_long_term/wizard/project_compute_tasks_view.xml
new file mode 100644
index 00000000000..3b03f20fe1e
--- /dev/null
+++ b/addons/project_long_term/wizard/project_compute_tasks_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+ Compute Task Scheduling
+ project.compute.tasks
+ form
+
+
+
+
+
+
+ Compute Task Scheduling
+ ir.actions.act_window
+ project.compute.tasks
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/project_long_term/wizard/schedule_tasks.py b/addons/project_long_term/wizard/project_schedule_tasks.py
similarity index 82%
rename from addons/project_long_term/wizard/schedule_tasks.py
rename to addons/project_long_term/wizard/project_schedule_tasks.py
index 4a170859032..2d0071547be 100644
--- a/addons/project_long_term/wizard/schedule_tasks.py
+++ b/addons/project_long_term/wizard/project_schedule_tasks.py
@@ -23,24 +23,36 @@ from resource.faces import *
from new import classobj
import operator
+from tools.translate import _
+from osv import osv, fields
+
import working_calendar as wkcal
-import wizard
-import pooler
-from tools.translate import _
+class project_schedule_task(osv.osv_memory):
-success_msg = """
-"""
+ _name = "project.schedule.tasks"
+ _description = 'project.schedule.tasks'
+ _columns = {
+ 'msg': fields.char('Message', size=64)
+ }
+ _defaults = {
+ 'msg': 'Task Scheduling Completed Successfully'
+ }
-class wizard_schedule_task(wizard.interface):
+ def default_get(self, cr, uid, fields_list, context=None):
+ res = super(project_schedule_task, self).default_get(cr, uid, fields_list, context)
+ self.compute_date(cr, uid, context=context)
+ return res
- def _create_resources(self, cr, uid, phase, context={}):
+ def create_resources(self, cr, uid, phase, context=None):
"""
Return a list of Resource Class objects for the resources allocated to the phase.
"""
resource_objs = []
+
+ if context is None:
+ context = {}
+
for resource in phase.resource_ids:
res = resource.resource_id
leaves = []
@@ -57,15 +69,21 @@ class wizard_schedule_task(wizard.interface):
}))
return resource_objs
- def _compute_date(self, cr, uid, data, context={}):
+ def compute_date(self, cr, uid, context=None):
"""
Schedule the tasks according to resource available and priority.
"""
- pool = pooler.get_pool(cr.dbname)
- phase_obj = pool.get('project.phase')
- task_obj = pool.get('project.task')
- user_obj = pool.get('res.users')
- phase = phase_obj.browse(cr, uid, data['id'], context=context)
+
+ phase_obj = self.pool.get('project.phase')
+ task_obj = self.pool.get('project.task')
+ user_obj = self.pool.get('res.users')
+
+ if context is None:
+ context = {}
+
+ if not 'active_id' in context:
+ return {}
+ phase = phase_obj.browse(cr, uid, context['active_id'], context=context)
task_ids = map(lambda x : x.id, (filter(lambda x : x.state in ['open', 'draft', 'pending'] , phase.task_ids)))
if task_ids:
task_ids.sort()
@@ -78,7 +96,7 @@ class wizard_schedule_task(wizard.interface):
start_date = phase.project_id.date_start
date_start = datetime.datetime.strftime(datetime.datetime.strptime(start_date, "%Y-%m-%d"), "%Y-%m-%d %H:%M")
calendar_id = phase.project_id.resource_calendar_id.id
- resources = self._create_resources(cr, uid, phase)
+ resources = self.create_resources(cr, uid, phase)
priority_dict = {'0': 1000, '1': 800, '2': 500, '3': 300, '4': 100}
# Create dynamic no of tasks with the resource specified
def create_tasks(j, eff, priorty=500, obj=False):
@@ -101,7 +119,7 @@ class wizard_schedule_task(wizard.interface):
try:
resource = reduce(operator.or_, resources)
except:
- raise wizard.except_wizard(_('Error'), _('Phase must have resources assigned !'))
+ raise osv.except_osv(_('Error'), _('Phase must have resources assigned !'))
minimum_time_unit = 1
if calendar_id: # If project has working calendar
working_days = wkcal.compute_working_calendar(cr, uid, calendar_id)
@@ -136,11 +154,6 @@ class wizard_schedule_task(wizard.interface):
context=ctx)
loop_no +=1
return {}
- states = {
- 'init': {
- 'actions': [_compute_date],
- 'result': {'type':'form','arch':success_msg,'fields':{}, 'state':[('end', 'Ok', 'gtk-ok', True)]},
- }
- }
-wizard_schedule_task('phase.schedule.tasks')
+
+project_schedule_task()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_long_term/wizard/project_schedule_tasks_view.xml b/addons/project_long_term/wizard/project_schedule_tasks_view.xml
new file mode 100644
index 00000000000..1011f366aa5
--- /dev/null
+++ b/addons/project_long_term/wizard/project_schedule_tasks_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+ Schedule Tasks
+ project.schedule.tasks
+ form
+
+
+
+
+
+
+ Schedule Tasks
+ ir.actions.act_window
+ project.schedule.tasks
+ form
+ form
+
+ {'record_id' : active_id}
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/project_messages/__init__.py b/addons/project_messages/__init__.py
index de63635487f..49b83129fe3 100644
--- a/addons/project_messages/__init__.py
+++ b/addons/project_messages/__init__.py
@@ -19,6 +19,6 @@
#
##############################################################################
-import messages
+import project_messages
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_messages/__terp__.py b/addons/project_messages/__openerp__.py
similarity index 100%
rename from addons/project_messages/__terp__.py
rename to addons/project_messages/__openerp__.py
diff --git a/addons/project_messages/messages.py b/addons/project_messages/project_messages.py
similarity index 92%
rename from addons/project_messages/messages.py
rename to addons/project_messages/project_messages.py
index 422bdb3675c..ab7f96b71d4 100644
--- a/addons/project_messages/messages.py
+++ b/addons/project_messages/project_messages.py
@@ -22,7 +22,8 @@ from osv import fields, osv
import netsvc
class messages(osv.osv):
- """Message from one user to another within a project
+ """
+ Message from one user to another within a project
"""
_name = 'project.messages'
logger = netsvc.Logger()
@@ -40,7 +41,7 @@ class messages(osv.osv):
'to_id':None,
}
- def broadcast(self, cr, uid, project_id, message):
+ def broadcast(self, cr, uid, project_id, message, context=None):
""" Send a message to all the users of a project.
The sender of the message is the current user.
@@ -55,6 +56,7 @@ class messages(osv.osv):
'project_id':project_id,
'message':message
}, context=context)
+
messages()
class project_with_message(osv.osv):
@@ -66,3 +68,5 @@ class project_with_message(osv.osv):
domain="[('to_id','in',[uid,False])]"),
}
project_with_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_mrp/__init__.py b/addons/project_mrp/__init__.py
index 2d56968e7bd..b310d99d87d 100644
--- a/addons/project_mrp/__init__.py
+++ b/addons/project_mrp/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,10 +15,10 @@
# 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 mrp
-import project
+import project_mrp
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_mrp/__terp__.py b/addons/project_mrp/__openerp__.py
similarity index 81%
rename from addons/project_mrp/__terp__.py
rename to addons/project_mrp/__openerp__.py
index 7b09931c06b..8fe1717e631 100644
--- a/addons/project_mrp/__terp__.py
+++ b/addons/project_mrp/__openerp__.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,23 +25,23 @@
'version': '1.0',
'category': 'Generic Modules/Projects & Services',
'description': """
-This module creates a link between procurement orders
+This module creates a link between procurement orders
containing "service" lines and project management tasks.
-When installed, this module will automatically create a new task
-for each procurement order line, when the corresponding product
-meets the following characteristics:
+When installed, this module will automatically create a new task
+for each procurement order line, when the corresponding product
+meets the following characteristics:
* Type = Service
* Procurement method (Order fulfillment) = MTO (make to order)
- * Supply/Procurement method = Produce
+ * Supply/Procurement method = Produce
-The new task is created outside of any existing project, but
+The new task is created outside of any existing project, but
can be added to a project manually.
When the project task is completed or cancelled, the workflow of the corresponding
-procurement line is updated accordingly.
+procurement line is updated accordingly.
-This module is useful to be able to invoice services based on tasks
+This module is useful to be able to invoice services based on tasks
automatically created via sale orders.
""",
@@ -49,7 +49,7 @@ automatically created via sale orders.
'website': 'http://www.openerp.com',
'depends': ['project', 'mrp', 'sale', 'mrp_jit'],
'init_xml': [],
- 'update_xml': ['project_workflow.xml', 'process/project_mrp_process.xml'],
+ 'update_xml': ['project_mrp_workflow.xml', 'process/project_mrp_process.xml'],
'demo_xml': [],
'installable': True,
'active': False,
diff --git a/addons/project_mrp/project.py b/addons/project_mrp/project_mrp.py
similarity index 99%
rename from addons/project_mrp/project.py
rename to addons/project_mrp/project_mrp.py
index 4a304362ec2..8029327022d 100644
--- a/addons/project_mrp/project.py
+++ b/addons/project_mrp/project_mrp.py
@@ -28,6 +28,7 @@ class project_task(osv.osv):
_columns = {
'procurement_id': fields.many2one('mrp.procurement', 'Procurement', ondelete='set null')
}
+
def do_close(self, cr, uid, ids, *args):
res = super(project_task, self).do_close(cr, uid, ids, *args)
tasks = self.browse(cr, uid, ids)
@@ -45,6 +46,7 @@ class project_task(osv.osv):
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', task.procurement_id.id, 'subflow.cancel', cr)
return True
-project_task()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+project_task()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_mrp/project_workflow.xml b/addons/project_mrp/project_mrp_workflow.xml
similarity index 100%
rename from addons/project_mrp/project_workflow.xml
rename to addons/project_mrp/project_mrp_workflow.xml
diff --git a/addons/project_planning/__terp__.py b/addons/project_planning/__openerp__.py
similarity index 100%
rename from addons/project_planning/__terp__.py
rename to addons/project_planning/__openerp__.py
diff --git a/addons/project_retro_planning/__terp__.py b/addons/project_retro_planning/__openerp__.py
similarity index 100%
rename from addons/project_retro_planning/__terp__.py
rename to addons/project_retro_planning/__openerp__.py
diff --git a/addons/project_timesheet/__init__.py b/addons/project_timesheet/__init__.py
index 9dd42114b9c..4d23d3c1a90 100644
--- a/addons/project_timesheet/__init__.py
+++ b/addons/project_timesheet/__init__.py
@@ -20,5 +20,6 @@
##############################################################################
import project_timesheet
import report
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_timesheet/__terp__.py b/addons/project_timesheet/__openerp__.py
similarity index 100%
rename from addons/project_timesheet/__terp__.py
rename to addons/project_timesheet/__openerp__.py
diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py
index a6743b10330..3ab09a390cc 100644
--- a/addons/project_timesheet/project_timesheet.py
+++ b/addons/project_timesheet/project_timesheet.py
@@ -18,14 +18,14 @@
# along with this program. If not, see .
#
##############################################################################
-from osv import fields, osv
import time
import datetime
+
+from osv import fields, osv
import pooler
import tools
from tools.translate import _
-
class project_work(osv.osv):
_inherit = "project.task.work"
_description = "Task Work"
@@ -178,12 +178,14 @@ task()
class project_project(osv.osv):
_inherit = "project.project"
+
def name_get(self, cr, user, ids, context=None):
result = []
for project in self.browse(cr, user, ids, context):
name = "[%s] %s" % (project.category_id and project.category_id.code or '?', project.name)
result.append((project.id, name))
return result
+
project_project()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_timesheet/report/task_report.py b/addons/project_timesheet/report/task_report.py
index fb6331dda0b..c8ef453666f 100644
--- a/addons/project_timesheet/report/task_report.py
+++ b/addons/project_timesheet/report/task_report.py
@@ -18,9 +18,9 @@
# along with this program. If not, see .
#
##############################################################################
+import mx.DateTime
from osv import fields,osv
-import mx.DateTime
import tools
#class task_report(osv.osv):
diff --git a/addons/scrum/scrum.py b/addons/scrum/scrum.py
index 55ff36ae1ba..915332f7f7d 100644
--- a/addons/scrum/scrum.py
+++ b/addons/scrum/scrum.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 .
#
##############################################################################
@@ -75,7 +75,7 @@ class scrum_sprint(osv.osv):
res.setdefault(sprint.id, 0.0)
for bl in sprint.backlog_ids:
res[sprint.id] += bl.expected_hours
- return res
+ return res
def button_cancel(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'cancel'}, context=context)
return True
@@ -120,7 +120,7 @@ class scrum_sprint(osv.osv):
v['scrum_master_id']= proj.user_id and proj.user_id.id or False
v['date_stop'] = (DateTime.now() + DateTime.RelativeDateTime(days=int(proj.sprint_size or 14))).strftime('%Y-%m-%d')
return {'value':v}
-
+
scrum_sprint()
class scrum_product_backlog(osv.osv):
@@ -167,6 +167,8 @@ class scrum_product_backlog(osv.osv):
def button_cancel(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'cancel'}, context=context)
+ for backlog in self.browse(cr, uid, ids, context=context):
+ self.pool.get('project.task').write(cr, uid, [i.id for i in backlog.tasks_id], {'state': 'cancelled'})
return True
def button_draft(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'draft'}, context=context)
@@ -195,10 +197,12 @@ class scrum_product_backlog(osv.osv):
'effective_hours': fields.function(_calc_effective, method=True, string='Effective hours'),
'planned_hours': fields.function(_calc_planned, method=True, string='Planned Hours'),
'expected_hours': fields.float('Expected Hours'),
+ 'date':fields.datetime("Created Date"),
}
_defaults = {
'state': lambda *a: 'draft',
- 'active': lambda *a: 1
+ 'active': lambda *a: 1,
+ 'user_id': lambda self,cr,uid,context: uid,
}
_order = "sequence"
scrum_product_backlog()
@@ -234,10 +238,12 @@ class scrum_meeting(osv.osv):
'name' : fields.char('Meeting Name', size=64, required=True),
'date': fields.date('Meeting Date', required=True),
'sprint_id': fields.many2one('scrum.sprint', 'Sprint', required=True),
+ 'project_id': fields.many2one('project.project', 'Project'),
'question_yesterday': fields.text('Tasks since yesterday'),
'question_today': fields.text('Tasks for today'),
'question_blocks': fields.text('Blocks encountered'),
'question_backlog': fields.text('Backlog Accurate'),
+ 'task_ids': fields.many2many('project.task', 'meeting_task_rel', 'metting_id', 'task_id', 'Tasks')
}
#
# TODO: Find the right sprint thanks to users and date
diff --git a/addons/scrum/scrum_view.xml b/addons/scrum/scrum_view.xml
index 07e839bd71c..8824f9dad62 100644
--- a/addons/scrum/scrum_view.xml
+++ b/addons/scrum/scrum_view.xml
@@ -45,10 +45,11 @@
-
+
+
@@ -65,6 +66,7 @@
+
@@ -81,13 +83,14 @@
-
+
-
+
+
@@ -110,10 +113,17 @@
-
-
+
+
+
+
+
+
+
+
+
@@ -320,12 +334,13 @@
-
+
+
diff --git a/addons/scrum/scrum_wizard.xml b/addons/scrum/scrum_wizard.xml
index cb8d4a8bed2..171d30ba37f 100644
--- a/addons/scrum/scrum_wizard.xml
+++ b/addons/scrum/scrum_wizard.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/addons/scrum/wizard/assign_backlog_to_sprint.py b/addons/scrum/wizard/assign_backlog_to_sprint.py
index d9805f374e9..fe36344976c 100644
--- a/addons/scrum/wizard/assign_backlog_to_sprint.py
+++ b/addons/scrum/wizard/assign_backlog_to_sprint.py
@@ -41,8 +41,8 @@ bts_form = """
bts_fields = {
'sprint_id' : {'string':'Sprint Name', 'type':'many2one', 'relation':'scrum.sprint', 'required':True},
- 'state_open' : {'string':'Set Open', 'type':'boolean'},
- 'convert_to_task' : {'string':'Convert To Task', 'type':'boolean'}
+ 'state_open' : {'string':'Set Open', 'type':'boolean', 'default': lambda *a: True},
+ 'convert_to_task' : {'string':'Convert To Task', 'type':'boolean', 'default': lambda *a: True}
}
def _assign_sprint(self, cr, uid, data, context):
diff --git a/addons/scrum/wizard/backlog_to_task.py b/addons/scrum/wizard/backlog_to_task.py
index 631fed686b8..2602b108fda 100644
--- a/addons/scrum/wizard/backlog_to_task.py
+++ b/addons/scrum/wizard/backlog_to_task.py
@@ -51,6 +51,7 @@ def _do_create(self, cr, uid, data, context={}):
'user_id': data['form']['user_id'] or False,
'planned_hours': backlog.planned_hours,
'remaining_hours':backlog.expected_hours,
+ 'sequence':backlog.sequence,
}))
value = {
'domain': "[('product_backlog_id','in',["+','.join(map(str,data['ids']))+"])]",