[MERGE] Merge with trunk-dev-addons3 (Addons3) Branch

bzr revid: mra@tinyerp.com-20100416144537-94gr4k15tl3svwrk
This commit is contained in:
mra (Open ERP)
2010-04-16 20:15:37 +05:30
175 changed files with 3572 additions and 2886 deletions
@@ -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',
+23 -3
View File
@@ -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()
+2 -2
View File
@@ -203,7 +203,7 @@
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-apply"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<button name="%(action_account_state_open)d" type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
</group>
</group>
</page>
@@ -295,7 +295,7 @@
<button name="invoice_open" states="draft,proforma2" string="Create" icon="gtk-execute"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<button name='%(action_account_state_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
</group>
</group>
</page>
+14 -5
View File
@@ -24,25 +24,33 @@
<report id="account_move_line_list" model="account.tax.code" name="account.tax.code.entries" rml="account/report/account_tax_code.rml" string="All Entries"/>
<report auto="False" id="account_vat_declaration" menu="False" model="account.tax.code" name="account.vat.declaration" rml="account/report/tax_report.rml" string="Taxes Report"/>
<report
auto="False"
id="account_vat_declaration"
menu="False"
model="account.tax.code"
name="account.vat.declaration"
rml="account/report/tax_report.rml"
string="Taxes Report"/>
<menuitem
id="menu_tax_report"
name="Taxes"
parent="account.menu_finance_generic_reporting" sequence="3"/>
<wizard
<!-- <wizard
id="wizard_vat_declaration"
menu="False"
model="account.tax.code"
name="account.vat.declaration"
string="Print Taxes Report"/>
<menuitem
string="Print Taxes Report"/> -->
<!-- <menuitem
icon="STOCK_PRINT"
action="wizard_vat_declaration"
id="menu_wizard_vat_declaration"
parent="menu_tax_report"
type="wizard"/>
type="wizard"/> -->
<record id="action_tax_code_tree" model="ir.actions.act_window">
@@ -66,6 +74,7 @@
rml="account/report/compare_account_balance.rml"
auto="False"
menu="False"/>
<report id="account_account_balance_landscape"
string="Account balance"
model="account.account"
+4 -19
View File
@@ -340,8 +340,9 @@
<field name="currency"/>
<field name="period_id" select="2"/>
<group colspan="2" col="3">
<button name="%(wizard_populate_statement_from_inv)d"
string="Import Invoice" type="action" attrs="{'invisible':[('state','=','confirm')]}" icon="gtk-open"/>
<!-- <button name="%(action_view_account_statement_from_invoice)d"-->
<!-- string="Import Invoice" type="action" attrs="{'invisible':[('state','=','confirm')]}" icon="gtk-open"/>-->
<button name="button_import_invoice" string="Import Invoice" attrs="{'invisible':[('state','=','confirm')]}" type="object" icon="gtk-apply"/>
</group>
<newline/>
<field name="balance_start"/>
@@ -652,23 +653,7 @@
</record>
<menuitem action="action_tax_form" id="menu_action_tax_form" parent="next_id_27"/>
<!--
Entries Journal lines
-->
<wizard id="action_move_journal_line_form_select" menu="False" model="account.move.line" name="account.move.journal.select" string="Standard entry"/>
<record id="ir_open_journal_period" model="ir.values">
<field name="key2">tree_but_open</field>
<field name="model">account.journal.period</field>
<field name="name">Open Journal</field>
<field eval="'ir.actions.wizard,%d'%action_move_journal_line_form_select" name="value"/>
<field eval="True" name="object"/>
</record>
<!-- <wizard id="action_move_journal_line_form" menu="False" model="account.move.line" name="account.move.journal" string="Entries by Line"/>
<!-- <wizard id="action_move_journal_line_form" menu="False" model="account.move.line" name="account.move.journal" string="Entries by Line"/>
<menuitem icon="STOCK_JUSTIFY_FILL" action="action_move_journal_line_form" id="menu_action_move_journal_line_form" parent="account.menu_finance_entries" type="wizard" sequence="5"/>
-->
<!--
+21 -41
View File
@@ -16,42 +16,22 @@
<wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice" groups="base.group_user"/>
<!-- wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice" groups="base.group_user"/-->
<!-- close year, period, journal -->
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Generate Fiscal Year Opening Entries"/>
<menuitem
action="wizard_fiscalyear_close"
id="menu_wizard_fy_close"
parent="menu_account_end_year_treatments"
type="wizard"
sequence="1"/>
<!-- <wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Generate Fiscal Year Opening Entries"/>-->
<!---->
<!-- <menuitem-->
<!-- action="wizard_fiscalyear_close"-->
<!-- id="menu_wizard_fy_close"-->
<!-- parent="menu_account_end_year_treatments"-->
<!-- type="wizard"-->
<!-- sequence="1"/>-->
<!-- <wizard id="wizard_fiscalyear_close_state" menu="False" model="account.fiscalyear" name="account.fiscalyear.close.state" string="Close a Fiscal Year"/>
<menuitem action="wizard_fiscalyear_close_state" id="menu_wizard_fy_close_state" parent="menu_account_end_year_treatments" type="wizard"/>
-->
<wizard
id="wizard_open_closed_fiscalyear"
menu="False"
model="account.fiscalyear"
name="account.open_closed_fiscalyear"
string="Cancel Opening Entries"/>
<menuitem
action="wizard_open_closed_fiscalyear"
id="menu_wizard_open_closed_fy"
sequence="2"
parent="account.menu_account_end_year_treatments" type="wizard"/>
<!-- period close
<wizard id="wizard_period_close" model="account.period" name="account.period.close" string="Close a Period"/>
<wizard id="action_account_period_close" model="account.period" name="account.period.close" string="Close a Period"/>
-->
<!-- automatic reconcile -->
<wizard id="wizard_automatic_reconcile" menu="False" model="account.account" name="account.automatic.reconcile" string="Automatic reconciliation"/>
<menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/>
@@ -59,12 +39,12 @@
<!-- Import entry in statement -->
<wizard
string="Import invoices"
model="account.bank.statement"
name="populate_statement_from_inv"
menu="False"
id="wizard_populate_statement_from_inv"/>
<!-- <wizard-->
<!-- string="Import invoices"-->
<!-- model="account.bank.statement"-->
<!-- name="populate_statement_from_inv"-->
<!-- menu="False"-->
<!-- id="wizard_populate_statement_from_inv"/>-->
<!-- manual reconcile -->
<wizard id="wizard_reconcile" model="account.move.line" name="account.move.line.reconcile" string="Reconcile Entries"/>
@@ -110,10 +90,10 @@
<!-- account.move validate -->
<wizard id="wizard_validate_account_moves" menu="False" model="account.move" name="account.move.validate" string="Validate Ledger Postings"/>
<!-- <wizard id="wizard_validate_account_moves" menu="False" model="account.move" name="account.move.validate" string="Validate Ledger Postings"/>
<menuitem action="wizard_validate_account_moves" id="menu_validate_account_moves" parent="account.menu_finance_periodical_processing" type="wizard"/>
<wizard id="wizard_validate_account_moves_line" menu="True" model="account.move.line" name="account.move_line.validate" string="Validate Ledger Postings"/>
<wizard id="wizard_validate_account_moves_line" menu="True" model="account.move.line" name="account.move_line.validate" string="Validate Ledger Postings"/>-->
<!-- Use Models -->
<wizard string="Create Entries From Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>
@@ -122,7 +102,7 @@
<wizard string="Create Entries From Models" model="account.move.line" name="account_use_models" menu="True" id="wizard_line_account_use_model"/>
<!-- account.invoice -->
<wizard string="Open State" model="account.invoice" name="account.wizard_paid_open" menu="False" id="wizard_paid_open" groups="base.group_user"/>
<!-- <wizard string="Open State" model="account.invoice" name="account.wizard_paid_open" menu="False" id="wizard_paid_open" groups="base.group_user"/> -->
<!-- generic report wizard -->
<wizard id="wizard_account_balance_report" menu="False" model="account.account" name="account.account.balance.report" string="Account Balance"/>
@@ -131,15 +111,15 @@
<wizard id="wizard_general_ledger" menu="False" model="account.account" name="account.general.ledger.report" string="General Ledger"/>
<menuitem icon="STOCK_PRINT" action="wizard_general_ledger" id="menu_general_ledger" parent="account.menu_generic_report" type="wizard"/>
<wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print Journal" />
<!-- <wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print Journal" />
<menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard" />
<wizard id="wizard_central_journal" menu="False" model="account.journal.period" name="account.central.journal.report" string="Print Central Journal" />
<menuitem icon="STOCK_PRINT" action="wizard_central_journal" id="menu_central_journal" parent="account.menu_generic_report" type="wizard" />
<wizard id="wizard_general_journal" menu="False" model="account.journal.period" name="account.general.journal.report" string="Print General Journal" />
<menuitem icon="STOCK_PRINT" action="wizard_general_journal" id="menu_general_journal" parent="account.menu_generic_report" type="wizard" />
<menuitem icon="STOCK_PRINT" action="wizard_general_journal" id="menu_general_journal" parent="account.menu_generic_report" type="wizard" />-->
<wizard id="wizard_invoice_currency_change" model="account.invoice" name="account.invoice.currency_change" string="Change Currency" groups="base.group_user"/>
<!-- <wizard id="wizard_invoice_currency_change" model="account.invoice" name="account.invoice.currency_change" string="Change Currency" groups="base.group_user"/>-->
</data>
</openerp>
+17 -8
View File
@@ -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
+13 -10
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
+4 -4
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -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:
+2 -2
View File
@@ -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:
+41 -39
View File
@@ -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<len(res):
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
res[i]['account'] = obj_account.browse(self.cr, self.uid, res[i]['account_id'], context=context)
i+=1
return res
def _get_codes(self,based_on, company_id, parent=False, level=0,period_list=[]):
tc = self.pool.get('account.tax.code')
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)])
def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context={}):
obj_tc = self.pool.get('account.tax.code')
ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], context=context)
res = []
for code in tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
res.append(('.'*2*level,code))
for code in obj_tc.browse(self.cr, self.uid, ids, {'based_on': based_on}):
res.append(('.'*2*level, code))
res += self._get_codes(based_on, company_id, code.id, level+1)
res += self._get_codes(based_on, company_id, code.id, level+1, context=context)
return res
def _add_codes(self,based_on, account_list=[],period_list=[]):
def _add_codes(self, based_on, account_list=[], period_list=[], context={}):
res = []
obj_tc = self.pool.get('account.tax.code')
for account in account_list:
tc = self.pool.get('account.tax.code')
ids = tc.search(self.cr, self.uid, [('id','=',account[1].id)])
ids = obj_tc.search(self.cr, self.uid, [('id','=', account[1].id)], context=context)
sum_tax_add = 0
for period_ind in period_list[0][2]:
for code in tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
for period_ind in period_list:
for code in obj_tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
sum_tax_add = sum_tax_add + code.sum_period
code.sum_period = sum_tax_add
res.append((account[0],code))
res.append((account[0], code))
return res
def _get_company(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
def _get_company(self, form, context={}):
obj_company = self.pool.get('res.company')
return obj_company.browse(self.cr, self.uid, form['company_id'], context=context).name
def _get_currency(self, form):
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
def _get_currency(self, form, context={}):
obj_company = self.pool.get('res.company')
return obj_company.browse(self.cr, self.uid, form['company_id'], context=context).currency_id.name
def sort_result(self,accounts):
def sort_result(self, accounts, context={}):
# On boucle sur notre rapport
result_accounts = []
ind=0
@@ -191,7 +193,7 @@ class tax_report(rml_parse.rml_parse):
bcl_rup_ind = ind - 1
while (bcl_current_level >= 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:
+12 -12
View File
@@ -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:
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, 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:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_central_journal" model="ir.ui.view">
<field name="name">Account central Journal</field>
<field name="model">account.central.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Central Journal">
<group col="4" colspan="6">
<field name="journal_id"/>
<field name="period_id"/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_account_central_journal" model="ir.actions.act_window">
<field name="name">Account Central Journal</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.central.journal</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Print Central Journal"
parent="account.menu_generic_report"
action="action_account_central_journal"
id="menu_account_central_journal"
icon="STOCK_PRINT"/>
</data>
</openerp>
@@ -0,0 +1,74 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, 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:
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_change_currency" model="ir.ui.view">
<field name="name">Change Currency</field>
<field name="model">account.change.currency</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invoice Currency">
<field name="currency_id"/>
<separator colspan="4"/>
<group colspan="2" col="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="change_currency" string="Change Currency" type="object" icon="gtk-go-forward"/>
</group>
</form>
</field>
</record>
<record id="action_account_change_currency" model="ir.actions.act_window">
<field name="name">Change Currency</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.change.currency</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_change_currency"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="account_change_currency">
<field name="model_id" ref="account.model_account_invoice" />
<field name="object" eval="1" />
<field name="name">Change Currency</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_change_currency'))"/>
<field name="key">action</field>
<field name="model">account.invoice</field>
</record>
</data>
</openerp>
-1
View File
@@ -21,7 +21,6 @@
from osv import fields, osv
from tools.translate import _
import tools
class account_chart(osv.osv_memory):
"""
@@ -0,0 +1,228 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import 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:
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_fiscalyear_close" model="ir.ui.view">
<field name="name">account.fiscalyear.close.form</field>
<field name="model">account.fiscalyear.close</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Generate Fiscal Year Opening Entries Close a Fiscal Year with new entries">
<group colspan="4" >
<field name="fy_id" domain = "[('state','=','draft')]"/>
<field name="fy2_id" domain = "[('state','=','draft')]"/>
<field name="journal_id" />
<field name="period_id" domain ="[('fiscalyear_id','=',fy2_id)]" />
</group>
<group colspan="4" >
<field name="report_name" />
</group>
<group colspan="4" >
<separator string="Are you sure you want to create entries?" colspan="4"/>
<field name="sure"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Create" name="data_save" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_fiscalyear_close" model="ir.actions.act_window">
<field name="name">Generate Fiscal Year Opening Entries</field>
<field name="res_model">account.fiscalyear.close</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_fiscalyear_close"/>
<field name="target">new</field>
</record>
<menuitem action="action_account_fiscalyear_close"
id="menu_wizard_fy_close"
parent="menu_account_end_year_treatments" />
</data>
</openerp>
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, 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:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_general_journal" model="ir.ui.view">
<field name="name">Account Genral Journal</field>
<field name="model">account.general.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print General Journal">
<group col="4" colspan="6">
<field name="journal_id"/>
<field name="period_id"/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_account_general_journal" model="ir.actions.act_window">
<field name="name">Account General Journal</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.general.journal</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Print General Journal"
parent="account.menu_generic_report"
action="action_account_general_journal"
id="menu_account_general_journal"
icon="STOCK_PRINT"/>
</data>
</openerp>
@@ -18,13 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import tools
import netsvc
class account_invoice_refund(osv.osv_memory):
"""Refunds invoice."""
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="open_journal_button_view" model="ir.ui.view">
<field name="name">Open Journal Button</field>
<field name="model">account.journal.select</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Journal Select">
<label string="Are you sure you want to open Journal Entries!" colspan="4"/>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open Entries" name="action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_open_journal_button" model="ir.actions.act_window">
<field name="name">Open Journal</field>
<field name="res_model">account.journal.select</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="open_journal_button_view"/>
<field name="target">new</field>
</record>
<record id="ir_open_journal_period" model="ir.values">
<field name="key2">tree_but_open</field>
<field name="model">account.journal.period</field>
<field name="name">Open Journal</field>
<field eval="'ir.actions.act_window,%d'%action_open_journal_button" name="value"/>
<field eval="True" name="object"/>
</record>
</data>
</openerp>
@@ -18,11 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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()
@@ -15,7 +15,7 @@
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel" />
<button icon="gtk-open"
string="Open for reconciliation" name="action_open_window"
string="Open for Reconciliation" name="action_open_window"
type="object" />
</group>
</form>
@@ -23,7 +23,7 @@
</record>
<record id="action_account_reconcile_select" model="ir.actions.act_window">
<field name="name">Reconcile entries</field>
<field name="name">Reconcile Entries</field>
<field name="res_model">account.move.line.reconcile.select</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@@ -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()
@@ -15,7 +15,7 @@
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel" />
<button icon="gtk-open"
string="Open for Unreconciliation" name="action_open_window"
string="Open For Unreconciliation" name="action_open_window"
type="object" />
</group>
</form>
@@ -23,7 +23,7 @@
</record>
<record id="action_account_unreconcile_select" model="ir.actions.act_window">
<field name="name">Unreconcile entries</field>
<field name="name">Unreconcile Entries</field>
<field name="res_model">account.move.line.unreconcile.select</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import 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:
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_open_closed_fiscalyear" model="ir.ui.view">
<field name="name">account.open.closed.fiscalyear.form</field>
<field name="model">account.open.closed.fiscalyear</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Choose Fiscal Year ">
<group colspan="4" >
<field name="fyear_id" domain = "[('state','=','draft')]"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open" name="remove_entries" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_open_closed_fiscalyear" model="ir.actions.act_window">
<field name="name">Cancel Opening Entries</field>
<field name="res_model">account.open.closed.fiscalyear</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_open_closed_fiscalyear"/>
<field name="target">new</field>
</record>
<menuitem action="action_account_open_closed_fiscalyear"
id="menu_wizard_open_closed_fy" sequence="2"
parent="account.menu_account_end_year_treatments" />
</data>
</openerp>
@@ -0,0 +1,191 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_invoice_pay" model="ir.ui.view">
<field name="name">account.invoice.pay.form</field>
<field name="model">account.invoice.pay</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Pay invoice">
<group colspan="4" >
<field name="amount"/>
<newline/>
<field name="name"/>
<field name="date"/>
<field name="journal_id"/>
<field name="period_id"/>
</group>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Partial Payment" name="pay_and_reconcile" type="object"/>
<button icon="gtk-execute" string="Full Payment" name="wo_check" type="object"/>
</group>
</form>
</field>
</record>
<act_window name="Pay Invoice"
res_model="account.invoice.pay"
src_model="account.invoice"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_account_invoice_pay"/>
<record id="view_account_invoice_pay_writeoff" model="ir.ui.view">
<field name="name">account.invoice.pay.writeoff.form</field>
<field name="model">account.invoice.pay.writeoff</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Information addendum">
<group colspan="4" >
<separator string="Write-Off Move" colspan="4"/>
<field name="writeoff_journal_id"/>
<field name="writeoff_acc_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="comment"/>
<separator string="Analytic" colspan="4"/>
<field name="analytic_id"/>
</group>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Pay and reconcile" name="pay_and_reconcile_writeoff" type="object"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
@@ -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:
@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, 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:
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_print_journal" model="ir.ui.view">
<field name="name">Account Print Journal</field>
<field name="model">account.print.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Journal">
<group col="4" colspan="6">
<field name="journal_id"/>
<field name="period_id"/>
<newline/>
<field name="sort_selection"/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_account_print_journal" model="ir.actions.act_window">
<field name="name">Account Print Journal</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.print.journal</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Print Journal"
parent="account.menu_generic_report"
action="action_account_print_journal"
id="menu_account_print_journal"
icon="STOCK_PRINT"/>
</data>
</openerp>
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, 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:
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_state_open" model="ir.ui.view">
<field name="name">Account State Open</field>
<field name="model">account.state.open</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Open Invoice">
<label string="Are you sure you want to open this invoice ?"/>
<newline/>
<label string="(Invoice should be unreconciled if you want to open it)"/>
<separator colspan="4"/>
<group colspan="2" col="4">
<button special="cancel" string="No" icon="gtk-no"/>
<button name="change_inv_state" string="Yes" type="object" icon="gtk-yes"/>
</group>
</form>
</field>
</record>
<record id="action_account_state_open" model="ir.actions.act_window">
<field name="name">Account State Open</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.state.open</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_state_open"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,163 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_statement_from_invoice" model="ir.ui.view">
<field name="name">account.statement.from.invoice.form</field>
<field name="model">account.statement.from.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Invoices in Statement">
<group colspan="4" >
<field name="date"/>
<newline/>
<field name="journal_ids" domain="[('type','in',['sale','purchase','cash'])]"/>
</group>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Go" name="search_invoices" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_view_account_statement_from_invoice" model="ir.actions.act_window">
<field name="name">Import Invoices in Statement</field>
<field name="res_model">account.statement.from.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_statement_from_invoice"/>
<field name="target">new</field>
</record>
<record id="view_account_statement_from_invoice_lines" model="ir.ui.view">
<field name="name">account.statement.from.invoice.lines.form</field>
<field name="model">account.statement.from.invoice.lines</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Entries">
<group colspan="4" >
<field name="line_ids" />
</group>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Ok" name="populate_statement" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_view_account_statement_from_invoice_lines" model="ir.actions.act_window">
<field name="name">Import Entries</field>
<field name="res_model">account.statement.from.invoice.lines</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_statement_from_invoice_lines"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import 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:
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--Account Moves-->
<record id="validate_account_move_view" model="ir.ui.view">
<field name="name">Validate Account Move</field>
<field name="model">validate.account.move</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Validate Account Entries">
<separator string="Select Period and Journal for Validation" colspan="4"/>
<field name="journal_id"/>
<newline/>
<field name="period_id"/>
<separator string="Information" colspan="4"/>
<label string="All draft account entries in this journal and period will be validated. It means you won't be able to modify their accouting fields." colspan="4"/>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Validate" name="validate_move" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_validate_account_move" model="ir.actions.act_window">
<field name="name">Open Journal</field>
<field name="res_model">validate.account.move</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="validate_account_move_view"/>
<field name="target">new</field>
</record>
<menuitem
name="Validate Ledger Postings"
parent="account.menu_finance_periodical_processing"
action="action_validate_account_move"
id="menu_validate_account_moves"
/>
<!--Account Move lines-->
<record id="validate_account_move_line_view" model="ir.ui.view">
<field name="name">Validate Ledger Postings</field>
<field name="model">validate.account.move.lines</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Validate Moves">
<separator string="Validate Ledger Postings" colspan="4"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="validate_move_lines" string="Validate" type="object" icon="gtk-go-forward" default_focus="1"/>
</form>
</field>
</record>
<record id="action_validate_account_move_line" model="ir.actions.act_window">
<field name="name">Validate Ledger Postings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">validate.account.move.lines</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="validate_account_move_line_view"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="event_registration_values">
<field name="model_id" ref="account.model_account_move_line" />
<field name="object" eval="1" />
<field name="name">Validate Ledger Postings</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_validate_account_move_line'))" />
<field name="key">action</field>
<field name="model">account.move.line</field>
</record>
</data>
</openerp>
+64
View File
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, 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:
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem
id="menu_tax_report"
name="Taxes"
parent="account.menu_finance_generic_reporting" sequence="3"/>
<record id="view_account_vat_declaration" model="ir.ui.view">
<field name="name">Account Vat Declaration</field>
<field name="model">account.vat.declaration</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Period">
<field name="company_id"/>
<newline/>
<field name="based_on"/>
<newline/>
<field name="periods"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel" string="Cancel" />
<button name="create_vat" string="Print VAT Decl." colspan="1" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_account_vat_declaration" model="ir.actions.act_window">
<field name="name">Account Vat Declaration</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.vat.declaration</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Print Taxes Report"
parent="menu_tax_report"
action="action_account_vat_declaration"
id="menu_account_vat_declaration"
icon="STOCK_PRINT"/>
</data>
</openerp>
@@ -1,72 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
from tools.translate import _
form = '''<?xml version="1.0"?>
<form string="Print Central Journal">
<field name="journal_id"/>
<field name="period_id"/>
</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:
@@ -1,106 +0,0 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
class wizard_change_currency(wizard.interface):
'''
OpenERP Wizard
'''
form = '''<?xml version="1.0"?>
<form string="Invoice Currency">
<field name="currency_id"/>
</form>'''
message = '''<?xml version="1.0"?>
<form string="Invoice Currency">
<label string="You can not change currency for Open Invoice !"/>
</form>'''
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')
@@ -1,228 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import osv
import pooler
from tools.translate import _
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Fiscal Year with new entries">
<field name="fy_id"/>
<field name="fy2_id"/>
<field name="journal_id"/>
<field name="period_id"/>
<field name="report_name" colspan="4"/>
<separator string="Are you sure you want to create entries?" colspan="4"/>
<field name="sure"/>
</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:
@@ -1,70 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
from tools.translate import _
form = '''<?xml version="1.0"?>
<form string="Print General Journal">
<field name="journal_id"/>
<field name="period_id"/>
</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:
@@ -1,81 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
from osv import fields, osv
from tools.translate import _
form = """<?xml version="1.0"?>
<form string="Choose Fiscal Year">
<field name="fyear_id" domain="[('state','=','draft')]"/>
</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:
-188
View File
@@ -1,188 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
import time
from tools.translate import _
import tools
import decimal_precision as dp
pay_form = '''<?xml version="1.0"?>
<form string="Pay invoice">
<field name="amount"/>
<newline/>
<field name="name"/>
<field name="date"/>
<field name="journal_id"/>
<field name="period_id"/>
</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 = '''<?xml version="1.0"?>
<form string="Information addendum">
<separator string="Write-Off Move" colspan="4"/>
<field name="writeoff_journal_id"/>
<field name="writeoff_acc_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="comment"/>
<separator string="Analytic" colspan="4"/>
<field name="analytic_id"/>
</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:
@@ -1,79 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
from tools.translate import _
form = '''<?xml version="1.0"?>
<form string="Print Journal">
<field name="journal_id"/>
<field name="period_id"/>
<field name="sort_selection"/>
</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:
@@ -1,58 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import netsvc
from tools.translate import _
form = '''<?xml version="1.0"?>
<form string="Open Invoice">
<label string="Are you sure you want to open this invoice ?"/>
<newline/>
<label string="(Invoice should be unreconciled if you want to open it)"/>
</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:
@@ -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 = '''<?xml version="1.0"?>
<form string="Import Invoices in Statement">
<label string="Choose Journal and Payment Date" colspan="4"/>
<field name="date"/>
<field name="journal_id" colspan="4"/>
</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 = '''<?xml version="1.0"?>
<form string="Import Entries">
<field name="lines" colspan="4" height="300" width="800" nolabel="1"
domain="[('id', 'in', [%s])]"/>
</form>''' % (','.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:
@@ -1,89 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
from osv import osv
import pooler
from tools.translate import _
_journal_form = '''<?xml version="1.0"?>
<form string="Validate Account Entries">
<separator string="Select Period and Journal for Validation" colspan="4"/>
<field name="journal_id"/>
<newline/>
<field name="period_id"/>
<separator string="Information" colspan="4"/>
<label string="All draft account entries in this journal and period will be validated. It means you won't be able to modify their accouting fields." colspan="4"/>
</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:
-90
View File
@@ -1,90 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import wizard
import pooler
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="company_id"/>
<newline/>
<field name="based_on"/>
<field name="periods" colspan="4"/>
</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:
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -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,
+1 -4
View File
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
+9 -11
View File
@@ -1,63 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="dep_management" model="hr.department">
<field name="name">Management</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
</record>
<record id="dep_administration" model="hr.department">
<field name="name">Administration</field>
<field name="parent_id" ref="dep_management"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
</record>
<record id="dep_technical" model="hr.department">
<field name="name">Technical department</field>
<field name="parent_id" ref="dep_management"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
</record>
<record id="dep_it" model="hr.department">
<field name="name">IT</field>
<field name="parent_id" ref="dep_technical"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
</record>
<record id="dep_marketing" model="hr.department">
<field name="name">Marketing</field>
<field name="parent_id" ref="dep_management"/>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
</record>
<record id="dep_sales" model="hr.department">
<field name="name">Sales</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
<field name="parent_id" ref="dep_management"/>
</record>
<record id="dep_sales_europe" model="hr.department">
<field name="name">Sales Europe</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
<field name="parent_id" ref="dep_sales"/>
</record>
<record id="dep_sales_america" model="hr.department">
<field name="name">Sales America</field>
<field name="company_id" ref="base.main_company"/>
<field name="manager_id" ref="base.user_root"/>
<field name="parent_id" ref="dep_sales"/>
</record>
</data>
</openerp>
+3
View File
@@ -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:
@@ -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,
+9 -9
View File
@@ -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:
@@ -2,22 +2,22 @@
<openerp>
<data>
<wizard id="si_so" model="hr.employee" name="hr.si_so" string="Sign in / Sign out"/>
<wizard id="wizard_attendance_error" keyword="client_print_multi" model="hr.employee" name="hr.attendance.report" string="Print Attendance Error Report"/>
<!--<wizard multi="1" menu="False" id="si_so" model="hr.employee" name="hr.si_so" string="Sign in / Sign out"/>-->
<!--<wizard id="wizard_attendance_error" keyword="client_print_multi" model="hr.employee" name="hr.attendance.report" string="Print Attendance Error Report"/>
<wizard id="print_week" keyword="client_print_multi" model="hr.employee" name="hr.attendance.print_week" string="Print Timesheet by week"/>
<wizard id="print_month" keyword="client_print_multi" model="hr.employee" name="hr.attendance.print_month" string="Print Timesheet by month"/>
<wizard id="print_week" keyword="client_print_multi" model="hr.employee" name="hr.attendance.print_week" string="Print Timesheet by week"/>-->
<!--<wizard id="print_month" keyword="client_print_multi" model="hr.employee" name="hr.attendance.print_month" string="Print Timesheet by month"/>-->
<menuitem action="si_so" id="menu_si_so" parent="menu_hr_time_tracking" type="wizard" sequence="1"
groups="group_hr_attendance"/>
<!-- <menuitem action="si_so" id="menu_si_so" parent="menu_hr_time_tracking" type="wizard" sequence="1"
groups="group_hr_attendance"/>-->
<!--Time Tracking menu for Project Management-->
<menuitem icon="terp-project" id="base.menu_main_pm" name="Project Management" sequence="1"/>
<menuitem
id="base.menu_project_management_time_tracking"
name="Time Tracking"
parent="base.menu_main_pm" sequence="3"/>
<menuitem action="hr_attendance.si_so" id="menu_project_management_si_so" parent="base.menu_project_management_time_tracking" type="wizard" sequence="9"/>
<!--<menuitem action="hr_attendance.si_so" id="menu_project_management_si_so" parent="base.menu_project_management_time_tracking" type="wizard" sequence="9"/>
-->
</data>
</openerp>
+7 -7
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_attendance_month" model="ir.ui.view">
<field name="name">Attendance Report Monthly</field>
<field name="model">hr.attendance.month</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Attendance Report Monthly">
<group col="4" colspan="6">
<field name="month"/>
<field name="year"/>
<newline/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/>
</group>
</form>
</field>
</record>
<record id="action_hr_attendance_month" model="ir.actions.act_window">
<field name="name">Print Timesheet by month</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.attendance.month</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="hr_attendance_month_values">
<field name="model_id" ref="hr.model_hr_employee" />
<field name="object" eval="1" />
<field name="name">Print Timesheet by month</field>
<field name="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_attendance_month'))" />
<field name="key">action</field>
<field name="model">hr.employee</field>
</record>
</data>
</openerp>
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import time
_date_form = '''<?xml version="1.0"?>
<form string="Timesheets by week">
<separator string="Select a starting and a end date" colspan="4"/>
<field name="init_date"/>
<newline/>
<field name="end_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:
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_attendance_week" model="ir.ui.view">
<field name="name">Attendance Report Week</field>
<field name="model">hr.attendance.week</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Attendance Report Weekly">
<group col="4" colspan="6">
<separator string="Select a starting and a end date" colspan="4"/>
<field name="init_date"/>
<field name="end_date"/>
<newline/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/>
</group>
</form>
</field>
</record>
<record id="action_hr_attendance_week" model="ir.actions.act_window">
<field name="name">Print Timesheet by week</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.attendance.week</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="hr_attendance_week_values">
<field name="model_id" ref="hr.model_hr_employee" />
<field name="object" eval="1" />
<field name="name">Print Timesheet by week</field>
<field name="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_attendance_week'))" />
<field name="key">action</field>
<field name="model">hr.employee</field>
</record>
</data>
</openerp>
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_attendance_error" model="ir.ui.view">
<field name="name">Attendance Report Error</field>
<field name="model">hr.attendance.error</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Attendance Report Error">
<group col="4" colspan="6">
<separator string="Analysis Information" colspan="4"/>
<field name="init_date"/>
<field name="end_date"/>
<field name="max_delay"/>
<label string="Bellow this delay, the error is considered to be voluntary" colspan="2"/>
<newline/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/>
</group>
</form>
</field>
</record>
<record id="action_hr_attendance_error" model="ir.actions.act_window">
<field name="name">Print Attendance Error Report</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.attendance.error</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="hr_attendance_error_values">
<field name="model_id" ref="hr.model_hr_employee" />
<field name="object" eval="1" />
<field name="name">Print Attendance Error Report</field>
<field name="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_attendance_error'))" />
<field name="key">action</field>
<field name="model">hr.employee</field>
</record>
</data>
</openerp>
@@ -0,0 +1,185 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_attendance_sigh_in_out" model="ir.ui.view">
<field name="name">hr.sign.in.out.form</field>
<field name="model">hr.sign.in.out</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Sign in / Sign out">
<group colspan="4" >
<separator string="You are now ready to sign in or out of the attendance follow up" colspan="4" />
<field name="name" />
<field name="state" />
</group>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-go-back" string="Sign in" name="si_check" type="object"/>
<button icon="gtk-go-forward" string="Sign out" name="so_check" type="object"/>
</group>
</form>
</field>
</record>
<record id="view_hr_attendance_message" model="ir.ui.view">
<field name="name">hr.sign.in.out.form</field>
<field name="model">hr.sign.in.out</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Sign in / Sign out">
<label string="Sign-Out Entry must follow Sign-In." colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Ok"/>
</group>
</form>
</field>
</record>
<record id="action_hr_attendance_sigh_in_out" model="ir.actions.act_window">
<field name="name">Sign in / Sign out</field>
<field name="res_model">hr.sign.in.out</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_hr_attendance_sigh_in_out"/>
<field name="target">new</field>
</record>
<menuitem action="action_hr_attendance_sigh_in_out"
id="menu_hr_attendance_sigh_in_out"
parent="menu_hr_time_tracking" groups="group_hr_attendance" />
<record id="view_hr_attendance_so_ask" model="ir.ui.view">
<field name="name">hr.sign.in.out.ask.form</field>
<field name="model">hr.sign.in.out.ask</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="hr.sign.out.ask">
<group colspan="4" >
<separator string="You did not sign out the last time. Please enter the date and time you signed out." colspan="4" />
<field name="name" />
<field name="last_time" string="Your last sign out" />
</group>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-go-back" string="Sign in" name="sign_in" type="object"/>
</group>
</form>
</field>
</record>
<record id="view_hr_attendance_si_ask" model="ir.ui.view">
<field name="name">hr.sign.in.out.ask.form</field>
<field name="model">hr.sign.in.out.ask</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="hr.sign.in.out.ask">
<group colspan="4" >
<separator string="You did not sign in the last time. Please enter the date and time you signed in." colspan="4" />
<field name="name" />
<field name="last_time" string="Your last sign in" />
</group>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-go-back" string="Sign out" name="sign_out" type="object"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
@@ -1,76 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import time
import pooler
from tools.translate import _
_date_form = '''<?xml version="1.0"?>
<form string="Attendance Report">
<separator string="Analysis Information" colspan="4"/>
<field name="init_date"/>
<field name="end_date"/>
<field name="max_delay"/>
<label string="Bellow this delay, the error is considered to be voluntary" colspan="2"/>
</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:
@@ -1,63 +0,0 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import time
_date_form = '''<?xml version="1.0"?>
<form string="Timesheets by month">
<separator string="Select a month" colspan="4"/>
<field name="month"/>
<field name="year"/>
</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:
-197
View File
@@ -1,197 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import time
from tools.translate import _
si_so_form ='''<?xml version="1.0"?>
<form string="Sign in / Sign out">
<separator string="You are now ready to sign in or out of the attendance follow up" colspan="4" />
<field name="name" readonly="True" />
<field name="state" readonly="True" />
</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 = '''<?xml version="1.0" ?>
<form string="Sign in status">
<seperator string="This is the status of your sign in request. Check it out maybe you were already signed in." colspan="4" />
<field name="success" readonly="True" />
</form>'''
si_fields = {
'success' : {'string' : "Sign in's status", 'type' : 'char', 'required' : True, 'readonly' : True},
}
so_form = '''<?xml version="1.0" ?>
<form string="Sign in status">
<seperator string="This is the status of your sign out request. Check it out maybe you were already signed out." colspan="4" />
<field name="success" readonly="True" />
</for>'''
so_fields = {
'success' : {'string' : "Sign out's status", 'type' : 'char', 'required' : True, 'readonly' : True},
}
def _get_empid(self, cr, uid, data, context):
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 _sign_in(self, cr, uid, data, context):
service = netsvc.LocalService('object_proxy')
emp_id = data['form']['emp_id']
if 'last_time' in data['form'] :
if data['form']['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
raise wizard.except_wizard(_('UserError'), _('The sign-out date must be in the past'))
return {'success': False}
service.execute(cr.dbname, uid, 'hr.attendance', 'create', {
'name': data['form']['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 wizard.except_wizard(_('UserError'), _('A sign-in must be right after a sign-out !'))
return {'success': success}
def _sign_out(self, cr, uid, data, context):
service = netsvc.LocalService('object_proxy')
emp_id = data['form']['emp_id']
if 'last_time' in data['form'] :
if data['form']['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
raise wizard.except_wizard(_('UserError'), _('The Sign-in date must be in the past'))
return {'success': False}
service.execute(cr.dbname, uid, 'hr.attendance', 'create', {'name':data['form']['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 wizard.except_wizard(_('UserError'), _('A sign-out must be right after a sign-in !'))
return {'success' : success}
so_ask_form ='''<?xml version="1.0"?>
<form string="Sign in / Sign out">
<separator string="You did not sign out the last time. Please enter the date and time you signed out." colspan="4" />
<field name="name" readonly="True" />
<field name="last_time" />
</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 ='''<?xml version="1.0"?>
<form string="Sign in / Sign out">
<separator string="You did not sign in the last time. Please enter the date and time you signed in." colspan="4" />
<field name="name" readonly="True" />
<field name="last_time" />
</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 = '''<?xml version="1.0"?>
<form string="Warning">
<label string="Sign-Out Entry must follow Sign-In." colspan="4" />
</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:
+12 -15
View File
@@ -18,23 +18,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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:
+5
View File
@@ -229,5 +229,10 @@
<menuitem id="hr_menu_contract_main" parent="hr.menu_hr_root" name="Contracts" sequence="3"/>
<menuitem action="action_hr_contract" id="hr_menu_contract" parent="hr_menu_contract_main" name="Contracts"/>
<!-- Contracts Button on Employee Form -->
<act_window domain="[('employee_id', '=', active_id)]" id="act_hr_employee_2_hr_contract" name="Contracts" res_model="hr.contract" src_model="hr.employee"/>
</data>
</openerp>
+7 -4
View File
@@ -338,9 +338,12 @@
id="menu_open_hr_evaluation_interview_requests"
action="action_hr_evaluation_interview_tree"/>
<menuitem name="Evaluation Reminders" parent="menu_eval_hr"
id="menu_eval_send_mail"
action="action_hr_evaluation_send_mail"
sequence="45"/>
<menuitem name="Evaluation Reminders" parent="menu_eval_hr"
id="menu_eval_send_mail"
action="action_hr_evaluation_send_mail"
sequence="45"/>
<!-- Evaluation Interviews Button on Employee Form -->
<act_window domain="[('user_to_review_id', '=', active_id)]" id="act_hr_employee_2_hr__evaluation_interview" name="Evaluation Interviews" res_model="hr.evaluation.interview" src_model="hr.employee"/>
</data>
</openerp>
+14 -12
View File
@@ -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:
@@ -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': [],

Some files were not shown because too many files have changed in this diff Show More