bzr revid: fp@tinyerp.com-20100404184958-i1cwl4uwswu9fyyt
This commit is contained in:
Fabien Pinckaers
2010-04-04 20:49:58 +02:00
60 changed files with 1883 additions and 1509 deletions
+10
View File
@@ -46,7 +46,17 @@ module named account_voucherss
'security/account_security.xml',
'security/ir.model.access.csv',
'account_menuitem.xml',
'wizard/account_invoice_refund_view.xml',
'wizard/account_period_close_view.xml',
'wizard/account_fiscalyear_close_state.xml',
'wizard/account_chart_view.xml',
'wizard/account_move_bank_reconcile_view.xml',
'wizard/account_move_line_reconcile_select_view.xml',
'wizard/account_move_journal_view.xml',
'account_wizard.xml',
'wizard/account_move_line_unreconcile_select_view.xml',
'wizard/account_subscription_generate_view.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_view.xml',
'account_end_fy.xml',
'account_invoice_view.xml',
+1 -1
View File
@@ -153,7 +153,7 @@
<field name="period_id" groups="base.group_user"/>
<group colspan="2" col="1" groups="base.group_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
</group>
<notebook colspan="4">
<page string="Invoice">
+1
View File
@@ -24,3 +24,4 @@
</data>
</openerp>
+12 -6
View File
@@ -668,9 +668,9 @@
<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"/>
-->
<!--
Entries lines
-->
@@ -1007,9 +1007,9 @@
<menuitem action="action_move_line_search" id="menu_action_move_line_search" parent="account.next_id_29"/>
<menuitem id="menu_finance_charts" name="Charts" parent="account.menu_finance" sequence="4"/>
<wizard id="wizard_account_chart" menu="False" model="account.account" name="account.chart" string="Chart of Accounts"/>
<!-- <wizard id="wizard_account_chart" menu="False" model="account.account" name="account.chart" string="Chart of Accounts"/>
<menuitem icon="STOCK_INDENT" action="wizard_account_chart" id="menu_action_account_tree2" parent="account.menu_finance_charts" type="wizard"/>
-->
<record id="view_bank_statement_reconcile_form" model="ir.ui.view">
@@ -1079,8 +1079,14 @@
groups="group_account_user"/>
<menuitem action="action_bank_statement_reconciliation_form" id="menu_action_account_bank_reconcile_tree" parent="next_id_30"/>
<wizard id="action_account_bank_reconcile_tree" menu="False" model="account.move.line" name="account.move.bank.reconcile" string="Bank reconciliation"/>
<menuitem action="action_account_bank_reconcile_tree" id="menu_action_account_bank_reconcile_check_tree" parent="account.next_id_30" type="wizard"/>
<!-- <wizard id="action_account_bank_reconcile_tree" menu="False" model="account.move.line" name="account.move.bank.reconcile" string="Bank reconciliation"/> -->
<!-- <menuitem action="action_account_bank_reconcile_tree" id="menu_action_account_bank_reconcile_check_tree" parent="account.next_id_30" type="wizard"/> -->
<!-- bank reconsilation -->
<menuitem action="action_account_bank_reconcile_tree"
id="menu_action_account_bank_reconcile_check_tree"
parent="account.next_id_30" />
<act_window
domain="[('account_id', '=', active_id)]"
+26 -6
View File
@@ -7,7 +7,14 @@
name="account.balance.account.balance.report"
keyword="client_print_multi"
id="wizard_account_balance_compare_report"/>
<wizard id="wizard_invoice_refund" model="account.invoice" name="account.invoice.refund" string="Credit Note" groups="base.group_user"/>
<!-- <wizard id="wizard_invoice_refund" model="account.invoice" name="account.invoice.refund" string="Credit Note" groups="base.group_user"/> -->
<!-- <wizard id="wizard_invoice_refund" model="account.invoice" name="account.invoice.refund" string="Credit Note" groups="base.group_user"/>-->
<!-- for test only -->
<wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice" groups="base.group_user"/>
@@ -21,8 +28,9 @@
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"/>
<!-- <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"
@@ -35,12 +43,19 @@
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="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"/><menuitem action="wizard_automatic_reconcile" id="menu_automatic_reconcile" parent="next_id_20" type="wizard"/>
<menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/>
<menuitem action="wizard_automatic_reconcile" id="menu_automatic_reconcile" parent="next_id_20" type="wizard"/>
<!-- Import entry in statement -->
@@ -57,19 +72,24 @@
<wizard id="wizard_reconcile_unreconcile" model="account.move.reconcile" name="account.reconcile.unreconcile" string="Unreconcile Entries"/>
<wizard id="wizard_reconcile_select" menu="False" model="account.move.line" name="account.move.line.reconcile.select" string="Reconcile entries"/>
<!-- <wizard id="wizard_reconcile_select" menu="False" model="account.move.line" name="account.move.line.reconcile.select" string="Reconcile entries"/>
<menuitem action="wizard_reconcile_select" id="menu_reconcile_select" parent="account.next_id_20" type="wizard"/>
-->
<!-- unreconcile -->
<wizard id="wizard_unreconcile" model="account.move.line" name="account.move.line.unreconcile" string="Unreconcile Entries"/>
<!-- unreconcile
<wizard id="wizard_unreconcile_select" menu="False" model="account.move.line" name="account.move.line.unreconcile.select" string="Unreconcile entries"/>
<menuitem action="wizard_unreconcile_select" id="menu_unreconcile_select" parent="account.next_id_20" type="wizard"/>
-->
<!-- subscriptions -->
<!--
<wizard id="wizard_generate_subscription" menu="False" model="account.subscription" name="account.subscription.generate" string="Create subscription entries"/>
<menuitem action="wizard_generate_subscription" id="menu_generate_subscription" parent="account.menu_finance_periodical_processing" type="wizard"/>
-->
<!-- Aged partner balance -->
<wizard id="wizard_aged_trial_balance" menu="False" model="res.partner" name="account.aged.trial.balance" string="Aged Partner Balance"/>
<menuitem id="next_id_22" name="Partner Accounts" parent="menu_finance_generic_reporting" sequence="1"/>
+6 -2
View File
@@ -204,10 +204,14 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_account_analytic_line_tree"/>
</record>
<wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Entries by Line"/>
<wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Entries by Line"/>
<menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/>
<menuitem type="wizard" icon="STOCK_JUSTIFY_FILL" action="action_account_analytic_line" id="account_entries_analytic_entries" parent="next_id_41"/>
<!-- Entries by Line -->
<menuitem icon="STOCK_JUSTIFY_FILL"
action="action_project_account_analytic_line_form"
id="account_entries_analytic_entries"
parent="next_id_41"/>
<record id="action_account_tree1" model="ir.actions.act_window">
<field name="name">Analytic Entries</field>
+3 -3
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/>.
#
##############################################################################
@@ -25,7 +25,7 @@ import wizard_account_analytic_inverted_balance_report
import wizard_account_analytic_cost_ledger_report
import wizard_account_analytic_cost_ledger_for_journal_report
import wizard_account_analytic_analytic_check
import wizard_account_analytic_line
import project_account_analytic_line
import wizard_analytic_account_chart
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,58 @@
# -*- 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 project_account_analytic_line(osv.osv_memory):
_name = "project.account.analytic.line"
_description = "Analytic Entries by line"
_columns = {
'from_date': fields.date('From'),
'to_date': fields.date('To'),
}
def action_open_window(self, cr, uid, ids, context={}):
mod_obj =self.pool.get('ir.model.data')
domain = []
for data in self.read(cr, uid, ids, context=context):
from_date = data['from_date']
to_date = data['to_date']
if from_date and to_date:
domain = [('date','>=',from_date), ('date','<=',to_date)]
elif from_date:
domain = [('date','>=',from_date)]
elif to_date:
domain = [('date','<=',to_date)]
result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter')
id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
return {
'name': _('Analytic Entries by line'),
'view_type': 'form',
"view_mode": 'tree,form',
'res_model': 'account.analytic.line',
'type': 'ir.actions.act_window',
'domain': domain,
'search_view_id': id['res_id'],
}
project_account_analytic_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_project_account_analytic_line_form" model="ir.ui.view">
<field name="name">project.account.analytic.line.form</field>
<field name="model">project.account.analytic.line</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="View Account Analytic Lines">
<group colspan="4" >
<field name="from_date"/>
<newline/>
<field name="to_date" />
</group>
<label string ="(Keep empty to open the current situation)" />
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Open Entries" name="action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_project_account_analytic_line_form" model="ir.actions.act_window">
<field name="name">Entries By Line</field>
<field name="res_model">project.account.analytic.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_project_account_analytic_line_form"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,84 +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 time
from tools.translate import _
def _action_open_window(self, cr, uid, data, context):
domain = []
from_date = data['form']['from_date']
to_date = data['form']['to_date']
if from_date and to_date:
domain = [('date','>=',from_date),('date','<=',to_date)]
elif from_date:
domain = [('date','>=',from_date)]
elif to_date:
domain = [('date','<=',to_date)]
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
return {
'name': _('Analytic Entries by line'),
'view_type': 'form',
"view_mode": 'tree,form',
'res_model': 'account.analytic.line',
'type': 'ir.actions.act_window',
'domain': domain,
'search_view_id': id['res_id'],}
class account_analytic_line(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="View Account Analytic Lines">
<separator string="Account Analytic Lines Analysis" colspan="4"/>
<field name="from_date"/>
<newline/>
<field name="to_date"/>
<newline/>
<label string=""/>
<label string="(Keep empty to open the current situation)" align="0.0" colspan="3"/>
</form>'''
form1_fields = {
'from_date': {
'string': 'From',
'type': 'date',
},
'to_date': {
'string': 'To',
'type': 'date',
},
}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Entries','gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
account_analytic_line('account.analytic.line')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+11 -16
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,40 +15,36 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_automatic_reconcile
import wizard_reconcile_select
import wizard_unreconcile_select
import account_move_line_reconcile_select
import account_move_line_unreconcile_select
import wizard_reconcile
import wizard_unreconcile
import wizard_refund
import account_invoice_refund
import wizard_pay_invoice
import wizard_journal
import account_move_journal
import wizard_journal_select
import wizard_bank_reconcile
import wizard_subscription_generate
import account_move_bank_reconcile
import account_subscription_generate
import wizard_aged_trial_balance
import wizard_general_ledger_report
import wizard_third_party_ledger
import wizard_account_balance_report
import wizard_partner_balance_report
import wizard_period_close
import account_period_close
import wizard_fiscalyear_close
import wizard_fiscalyear_close_state
import account_fiscalyear_close_state
import wizard_open_closed_fiscalyear
import wizard_vat
import wizard_compare_account_balance_report
import wizard_invoice_state
import wizard_account_duplicate
import wizard_account_chart
import account_chart
import wizard_move_line_select
import wizard_validate_account_move
@@ -64,5 +60,4 @@ import wizard_change_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+74
View File
@@ -0,0 +1,74 @@
# -*- 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_chart(osv.osv_memory):
"""
For Chart of Accounrs
"""
_name = "account.chart"
_description = "chart"
_columns = {
'fiscalyear': fields.many2one('account.fiscalyear', \
'Fiscal year', \
help = 'Keep empty for all open fiscal years'),
'target_move': fields.selection([
('all', 'All Entries'),
('posted', 'All Posted Entries'),
], 'Target Moves', required = True),
}
def _get_defaults(self, cr, uid, context={}):
"""Return default Fiscalyear value"""
fiscalyear_obj = self.pool.get('account.fiscalyear')
fiscalyear = fiscalyear_obj.find(cr, uid)
return fiscalyear
def account_chart_open_window(self, cr, uid, ids, context={}):
"""
Opens chart of Accounts
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of account chart’s IDs
@return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
"""
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
for data in self.read(cr, uid, ids,context=context):
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'],context=context)[0]['res_id']
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = str({'fiscalyear': data['fiscalyear'], \
'state': data['target_move']})
if data['fiscalyear']:
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']],context=context)[0]['code']
return result
_defaults = {
'fiscalyear': _get_defaults,
'target_move': lambda * a: 'all'
}
account_chart()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_chart" model="ir.ui.view">
<field name="name">account.chart.form</field>
<field name="model">account.chart</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account charts">
<group colspan="4" >
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<field name="target_move"/>
</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 Charts"
name="account_chart_open_window" type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_chart" model="ir.actions.act_window">
<field name="name">Chart of Accounts</field>
<field name="res_model">account.chart</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_chart"/>
<field name="target">new</field>
</record>
<menuitem icon="STOCK_INDENT" action="action_account_chart"
id="menu_action_account_tree2"
parent="account.menu_finance_charts" />
</data>
</openerp>
@@ -0,0 +1,65 @@
# -*- 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_state(osv.osv_memory):
"""
Closes Account Fiscalyear
"""
_name = "account.fiscalyear.close.state"
_description = "Fiscalyear Close state"
_columns = {
'fy_id': fields.many2one('account.fiscalyear', \
'Fiscal Year to close', required=True),
'sure': fields.boolean('Check this box', required=False)
}
def data_save(self, cr, uid, ids, context={}):
"""
This function close account fiscalyear
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Account fiscalyear close state’s IDs
"""
for data in self.read(cr, uid, ids,context=context):
if not data['sure']:
raise osv.except_osv(_('UserError'), _('Closing of states \
cancelled, please check the box !'))
fy_id = data['fy_id']
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period \
WHERE fiscalyear_id = %s)',
('done', fy_id))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('done', fy_id))
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s WHERE id = %s', ('done', fy_id))
return {}
account_fiscalyear_close_state()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_fiscalyear_close_state" model="ir.ui.view">
<field name="name">account.fiscalyear.close.state.form</field>
<field name="model">account.fiscalyear.close.state</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Close states of Fiscal year and periods">
<group colspan="4" >
<field name="fy_id" domain = "[('state','=','draft')]"/>
<separator string="Are you sure you want to close the fiscal year ?" 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-close" string="Close states" name="data_save" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_fiscalyear_close_state" model="ir.actions.act_window">
<field name="name">Close a Fiscal Year</field>
<field name="res_model">account.fiscalyear.close.state</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_fiscalyear_close_state"/>
<field name="target">new</field>
</record>
<menuitem action="action_account_fiscalyear_close_state"
id="menu_wizard_fy_close_state"
parent="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/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import tools
import netsvc
class account_invoice_refund(osv.osv_memory):
"""Refunds invoice."""
_name = "account.invoice.refund"
_description = "Invoice Refund"
_columns = {
'date': fields.date('Operation date', required=False),
'period': fields.many2one('account.period', 'Force period', required=False),
'description': fields.char('Description', size=150, required=True),
}
def compute_refund(self, cr, uid, ids, mode, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: the account invoice refund’s ID or list of IDs
"""
inv_obj = self.pool.get('account.invoice')
reconcile_obj = self.pool.get('account.move.reconcile')
account_m_line_obj = self.pool.get('account.move.line')
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
for form in self.read(cr, uid, ids,context=context):
created_inv = []
date = False
period = False
description = False
for inv in inv_obj.browse(cr, uid, context['active_ids'],context=context):
if inv.state in ['draft', 'proforma2', 'cancel']:
raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
if form['period'] :
period = form['period']
else:
period = inv.period_id and inv.period_id.id or False
if form['date'] :
date = form['date']
if not form['period'] :
cr.execute("select name from ir_model_fields \
where model = 'account.period' \
and name = 'company_id'")
result_query = cr.fetchone()
if result_query:
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop \
and company_id = %s limit 1 """,
(form['date'], self.pool.get('res.users').browse(cr, uid, uid,context=context).company_id.id,))
else:
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop \
limit 1 """, (form['date'],))
res = cr.fetchone()
if res:
period = res[0]
else:
date = inv.date_invoice
if form['description'] :
description = form['description']
else:
description = inv.name
if not period:
raise osv.except_osv(_('Data Insufficient !'), \
_('No Period found on Invoice!'))
refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description)
refund = inv_obj.browse(cr, uid, refund_id[0],context=context)
inv_obj.write(cr, uid, [refund.id], {'date_due': date,
'check_total': inv.check_total})
inv_obj.button_compute(cr, uid, refund_id)
created_inv.append(refund_id[0])
if mode in ('cancel', 'modify'):
movelines = inv.move_id.line_id
to_reconcile_ids = {}
for line in movelines :
if line.account_id.id == inv.account_id.id :
to_reconcile_ids[line.account_id.id] = [line.id]
if type(line.reconcile_id) != osv.orm.browse_null :
reconcile_obj.unlink(cr, uid, line.reconcile_id.id)
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', \
refund.id, 'invoice_open', cr)
refund = inv_obj.browse(cr, uid, refund_id[0],context=context)
for tmpline in refund.move_id.line_id :
if tmpline.account_id.id == inv.account_id.id :
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
for account in to_reconcile_ids :
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
writeoff_period_id=period,
writeoff_journal_id=inv.journal_id.id,
writeoff_acc_id=inv.account_id.id
)
if mode == 'modify' :
invoice = inv_obj.read(cr, uid, [inv.id],
['name', 'type', 'number', 'reference',
'comment', 'date_due', 'partner_id',
'address_contact_id', 'address_invoice_id',
'partner_insite', 'partner_contact',
'partner_ref', 'payment_term', 'account_id',
'currency_id', 'invoice_line', 'tax_line',
'journal_id', 'period_id'],context=context)
invoice = invoice[0]
del invoice['id']
invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'],context=context)
invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines)
tax_lines = self.pool.get('account.invoice.tax').read(
cr, uid, invoice['tax_line'],context=context)
tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines)
invoice.update({
'type': inv.type,
'date_invoice': date,
'state': 'draft',
'number': False,
'invoice_line': invoice_lines,
'tax_line': tax_lines,
'period_id': period,
'name': description
})
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0]
inv_id = inv_obj.create(cr, uid, invoice, {})
if inv.payment_term.id:
data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], inv.payment_term.id, date)
if 'value' in data and data['value']:
inv_obj.write(cr, uid, [inv_id], data['value'])
created_inv.append(inv_id)
if inv.type == 'out_invoice':
xml_id = 'action_invoice_tree1'
elif inv.type == 'in_invoice':
xml_id = 'action_invoice_tree2'
elif type == 'out_refund':
xml_id = 'action_invoice_tree3'
else:
xml_id = 'action_invoice_tree4'
result = mod_obj._get_id(cr, uid, 'account', xml_id)
id = mod_obj.read(cr, uid, result, ['res_id'],context=context)['res_id']
result = act_obj.read(cr, uid, id,context=context)
result['res_id'] = created_inv
return result
def invoice_refund(self, cr, uid, ids, context={}):
return self.compute_refund(cr, uid, ids, 'refund', context=context)
def invoice_cancel(self, cr, uid, ids, context={}):
return self.compute_refund(cr, uid, ids, 'cancel', context=context)
def invoice_modify(self, cr, uid, ids, context={}):
return self.compute_refund(cr, uid, ids, 'modify', context=context)
account_invoice_refund()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_invoice_refund" model="ir.ui.view">
<field name="name">account.invoice.refund.form</field>
<field name="model">account.invoice.refund</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Credit Note">
<group colspan="4" >
<label string="Are you sure you want to refund this invoice ?" colspan="2"/>
<newline/>
<field name="date"/>
<field name="period"/>
<field name="description"/>
</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-redo" string="Refund Invoice" name="invoice_refund" type="object"/>
<button icon="gtk-ok" string="Cancel Invoice" name="invoice_cancel" type="object"/>
<button icon="gtk-undo" string="Modify Invoice" name="invoice_modify" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_invoice_refund" model="ir.actions.act_window">
<field name="name">Credit Note</field>
<field name="res_model">account.invoice.refund</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_invoice_refund"/>
<field name="target">new</field>
</record>
<act_window id="action_account_invoice_refund"
key2 = "client_action_multi" name="Credit Note"
res_model="account.invoice.refund" src_model="account.invoice"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>
@@ -0,0 +1,63 @@
# -*- 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 tools
from osv import fields, osv
from tools.translate import _
class account_move_bank_reconcile(osv.osv_memory):
"""
Bank Reconciliation
"""
_name = "account.move.bank.reconcile"
_description = "Move bank reconcile"
_columns = {
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
}
def action_open_window(self, cr, uid, ids, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account move bank reconcile’s ID or list of IDs
@return: dictionary of Open account move line on given journal_id.
"""
for data in self.read(cr, uid, ids,context=context):
cr.execute('select default_credit_account_id \
from account_journal where id=%s', (data['journal_id'],))
account_id = cr.fetchone()[0]
if not account_id:
raise osv.except_osv(_('Error'), _('You have to define \
the bank account\nin the journal definition for reconciliation.'))
return {
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data['journal_id'], account_id),
'name': _('Standard Encoding'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': False,
'context': "{'journal_id': %d}" % (data['journal_id'],),
'type': 'ir.actions.act_window'
}
account_move_bank_reconcile()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_bank_reconcile" model="ir.ui.view">
<field name="name">account.move.bank.reconcile.form</field>
<field name="model">account.move.bank.reconcile</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Bank reconciliation">
<group colspan="4" >
<field name="journal_id"/>
</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 for bank reconciliation" name="action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_bank_reconcile_tree" model="ir.actions.act_window">
<field name="name">Bank reconciliation</field>
<field name="res_model">account.move.bank.reconcile</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_move_bank_reconcile"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,98 @@
# -*- 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_move_journal(osv.osv_memory):
_name = "account.move.journal"
_description = "Move journal"
_columns = {
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'period_id': fields.many2one('account.period', 'Period', required=True),
}
def _get_period(self, cr, uid, context={}):
"""Return default account period value"""
ids = self.pool.get('account.period').find(cr, uid, context=context)
period_id = False
if len(ids):
period_id = ids[0]
return period_id
def action_open_window(self, cr, uid, ids, context={}):
"""
This function Open action move line window on given period and Journal/Payment Mode
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account move journal’s ID or list of IDs
@return: dictionary of Open action move line window on given period and Journal/Payment Mode
"""
jp = self.pool.get('account.journal.period')
mod_obj = self.pool.get('ir.model.data')
for data in self.read(cr, uid, ids, ['journal_id', 'period_id'],context=context):
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
view_res = cr.fetchone()
journal_id = data['journal_id']
period_id = data['period_id']
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), \
('period_id', '=', period_id)],context=context)
if not len(ids):
name = self.pool.get('account.journal').read(cr, uid, [journal_id])[0]['name']
state = self.pool.get('account.period').read(cr, uid, [period_id])[0]['state']
if state == 'done':
raise osv.except_osv(_('UserError'), _('This period is already closed !'))
company = self.pool.get('account.period').read(cr, uid, [period_id])[0]['company_id'][0]
jp.create(cr, uid, {'name': name, 'period_id': period_id, 'journal_id': journal_id, 'company_id': company},context=context)
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)],context=context)
jp = jp.browse(cr, uid, ids, context=context)[0]
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
res = mod_obj.read(cr, uid, result, ['res_id'],context=context)
return {
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (journal_id, period_id),
'name': name,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': view_res,
'context': "{'journal_id': %d, 'period_id': %d}" % (journal_id, period_id),
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
_defaults = {
'period_id': _get_period
}
account_move_journal()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_journal_form" model="ir.ui.view">
<field name="name">account.move.journal.form</field>
<field name="model">account.move.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Standard entries">
<group colspan="4" >
<field name="journal_id"/>
<newline/>
<field name="period_id" />
</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 Journal" name="action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_move_journal_line_form" model="ir.actions.act_window">
<field name="name">Entries by Line</field>
<field name="res_model">account.move.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_move_journal_form"/>
<field name="target">new</field>
</record>
<menuitem icon="STOCK_JUSTIFY_FILL"
action="action_account_move_journal_line_form"
id="menu_action_move_journal_line_form"
parent="account.menu_finance_entries" sequence="5" />
</data>
</openerp>
@@ -0,0 +1,58 @@
# -*- 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_move_line_reconcile_select(osv.osv_memory):
_name = "account.move.line.reconcile.select"
_description = "Move line reconcile select"
_columns = {
'account_id': fields.many2one('account.account', 'Account', \
domain = [('reconcile', '=', 1)], required=True),
}
def action_open_window(self, cr, uid, ids, context={}):
"""
This function Open account move line window for reconcile on given account id
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account move line reconcile select’s ID or list of IDs
@return: dictionary of Open account move line window for reconcile on given account id
"""
for data in self.read(cr, uid, ids,context=context):
return {
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'],
'name': _('Reconciliation'),
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
account_move_line_reconcile_select()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_line_reconcile_select" model="ir.ui.view">
<field name="name">account.move.line.reconcile.select.form</field>
<field name="model">account.move.line.reconcile.select</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Reconciliation">
<group colspan="4" >
<field name="account_id"/>
</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 for reconciliation" name="action_open_window"
type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_reconcile_select" model="ir.actions.act_window">
<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>
<field name="view_id" ref="view_account_move_line_reconcile_select"/>
<field name="target">new</field>
</record>
<menuitem id="next_id_20" name="Reconciliation"
parent="menu_finance_periodical_processing" />
<menuitem action="action_account_reconcile_select"
id="menu_reconcile_select" parent="account.next_id_20" />
</data>
</openerp>
@@ -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/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import tools
class account_move_line_unreconcile_select(osv.osv_memory):
_name = "account.move.line.unreconcile.select"
_description = "Unreconciliation"
_columns ={
'account_id': fields.many2one('account.account','Account',required=True),
}
def action_open_window(self, cr, uid, ids, context={}):
for data in self.read(cr, uid, ids):
return {
'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['account_id'],
'name': 'Unreconciliation',
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
account_move_line_unreconcile_select()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_line_unreconcile_select" model="ir.ui.view">
<field name="name">account.move.line.unreconcile.select.form</field>
<field name="model">account.move.line.unreconcile.select</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Unreconciliation">
<group colspan="4" >
<field name="account_id"/>
</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 for Unreconciliation" name="action_open_window"
type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_unreconcile_select" model="ir.actions.act_window">
<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>
<field name="view_id" ref="view_account_move_line_unreconcile_select"/>
<field name="target">new</field>
</record>
<menuitem action="action_account_unreconcile_select"
id="menu_unreconcile_select" parent="account.next_id_20" />
</data>
</openerp>
@@ -0,0 +1,54 @@
# -*- 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_period_close(osv.osv_memory):
"""
close period
"""
_name = "account.period.close"
_description = "period close"
_columns = {
'sure': fields.boolean('Check this box', required=False),
}
def data_save(self, cr, uid, ids, context={}):
"""
This function close period
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account period close’s ID or list of IDs
"""
mode = 'done'
for form in self.read(cr, uid, ids,context=context):
if form['sure']:
for id in context['active_ids']:
cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
cr.execute('update account_period set state=%s where id=%s', (mode, id))
return {}
account_period_close()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_period_close" model="ir.ui.view">
<field name="name">account.period.close.form</field>
<field name="model">account.period.close</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Close Period">
<group colspan="4" >
<separator string="Are you sure ?" 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-close" string="Close Period" name="data_save" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_period_close" model="ir.actions.act_window">
<field name="name">Close a Period</field>
<field name="res_model">account.period.close</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_period_close"/>
<field name="target">new</field>
</record>
<record id="action_idea_post_vote_values" model="ir.values">
<field name="model_id" ref="model_account_period" />
<field name="object" eval="1" />
<field name="name"></field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_period_close'))"/>
<field name="key">action</field>
<field name="model">account.period</field>
</record>
</data>
</openerp>
@@ -0,0 +1,43 @@
# -*- 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
class account_subscription_generate(osv.osv_memory):
_name = "account.subscription.generate"
_description = "Subscription Compute"
_columns = {
'date': fields.date('Date', required=True),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
}
def action_generate(self, cr, uid, ids, context={}):
for data in self.read(cr, uid, ids, context=context):
cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],))
ids = map(lambda x: x[0], cr.fetchall())
self.pool.get('account.subscription.line').move_create(cr, uid, ids, context=context)
return {}
account_subscription_generate()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_subscription_generate" model="ir.ui.view">
<field name="name">account.subscription.generate.form</field>
<field name="model">account.subscription.generate</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Subscription Compute">
<group colspan="4" >
<separator string="Generate entries before:" colspan="4"/>
<field name="date"/>
</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="Compute Entry Dates"
name="action_generate" type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_subscription_generate" model="ir.actions.act_window">
<field name="name">Create Subscription Entries</field>
<field name="res_model">account.subscription.generate</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_subscription_generate"/>
<field name="target">new</field>
</record>
<menuitem action="action_account_subscription_generate" id="menu_generate_subscription" parent="account.menu_finance_periodical_processing" />
</data>
</openerp>
@@ -1,80 +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
class wizard_account_chart(wizard.interface):
_account_chart_arch = '''<?xml version="1.0"?>
<form string="Open account charts">
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<field name="target_move"/>
</form>'''
_account_chart_fields = {
'fiscalyear': {
'string': 'Fiscal year',
'type': 'many2one',
'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal years',
},
'target_move': {
'string': 'Target Moves',
'type': 'selection',
'selection': [('all','All Entries'),('posted','All Posted Entries')],
'required': True,
'default': lambda *a:"all",
},
}
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
return data['form']
def _account_chart_open_window(self, cr, uid, data, context):
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = str({'fiscalyear': data['form']['fiscalyear'],'state':data['form']['target_move']})
if data['form']['fiscalyear']:
result['name']+=':'+pooler.get_pool(cr.dbname).get('account.fiscalyear').read(cr,uid,[data['form']['fiscalyear']])[0]['code']
return result
states = {
'init': {
'actions': [_get_defaults],
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('open', 'Open', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
}
}
wizard_account_chart('account.chart')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,67 +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 tools.translate import _
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="journal_id"/>
</form>''' % ('Open Bank reconciliation',)
_journal_fields = {
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
cr.execute('select default_credit_account_id from account_journal where id=%s', (form['journal_id'],))
account_id = cr.fetchone()[0]
if not account_id:
raise wizard.except_wizard(_('Error'), _('You have to define the bank account\nin the journal definition for reconciliation.'))
return {
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id),
'name': _('Standard Encoding'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': False,
'context': "{'journal_id':%d}" % (form['journal_id'],),
'type': 'ir.actions.act_window'
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('open','Open', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.bank.reconcile')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,71 +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 states of Fiscal year and periods">
<field name="fy_id"/>
<separator string="Are you sure you want to close the fiscal year ?" 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')]},
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_save(self, cr, uid, data, context):
if not data['form']['sure']:
raise wizard.except_wizard(_('UserError'), _('Closing of states cancelled, please check the box !'))
pool = pooler.get_pool(cr.dbname)
fy_id = data['form']['fy_id']
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
('done',fy_id))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('done',fy_id))
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s WHERE id = %s', ('done', fy_id))
return {}
class wiz_journal_close_state(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel', 'gtk-cancel'),('close','Close states', 'gtk-ok')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close_state('account.fiscalyear.close.state')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-99
View File
@@ -1,99 +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="Standard entries">
<field name="journal_id"/>
<newline/>
<field name="period_id"/>
</form>'''
def _period_get(self, cr, uid, datas, ctx={}):
try:
pool = pooler.get_pool(cr.dbname)
ids = pool.get('account.period').find(cr, uid, context=ctx)
return {'period_id': ids[0]}
except:
return {}
_journal_fields = {
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
'period_id': {
'string':'Period',
'type':'many2one',
'relation':'account.period',
'required':True,
}
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
view_res = cr.fetchone()
jp = pooler.get_pool(cr.dbname).get('account.journal.period')
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
if not len(ids):
name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state']
if state == 'done':
raise wizard.except_wizard(_('UserError'), _('This period is already closed !'))
company = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['company_id'][0]
jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id'], 'company_id':company})
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
jp = jp.browse(cr, uid, ids, context=context)[0]
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
return {
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (form['journal_id'],form['period_id']),
'name': name,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': view_res,
'context': "{'journal_id':%d, 'period_id':%d}" % (form['journal_id'],form['period_id']),
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [_period_get],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('open','Open Journal', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.journal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,57 +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
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Period">
<separator string="Are you sure ?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_save(self, cr, uid, data, context):
mode = 'done'
if data['form']['sure']:
for id in data['ids']:
cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
cr.execute('update account_period set state=%s where id=%s', (mode, id))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel', 'gtk-cancel'),('close','Close Period', 'gtk-ok')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close('account.period.close')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,61 +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 tools.translate import _
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="account_id"/>
</form>''' % ('Reconciliation',)
_journal_fields = {
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account','domain': [('reconcile','=',1)], 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
return {
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['form']['account_id'],
'name': _('Reconciliation'),
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
class wiz_rec_select(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for reconciliation')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_rec_select('account.move.line.reconcile.select')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-226
View File
@@ -1,226 +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 osv
import netsvc
import time
from tools.translate import _
sur_form = '''<?xml version="1.0"?>
<form string="Credit Note">
<label string="Are you sure you want to refund this invoice ?" colspan="2"/>
<newline />
<field name="date" />
<field name="period" />
<field name="description" width="150" />
</form>'''
sur_fields = {
'date': {'string':'Operation date','type':'date', 'required':'False'},
'period':{'string': 'Force period', 'type': 'many2one',
'relation': 'account.period', 'required': False},
'description':{'string':'Description', 'type':'char', 'required':'True'},
}
class wiz_refund(wizard.interface):
def _invoice_refund(self, cr, uid, data, context):
return self._compute_refund(cr, uid, data, 'refund', context)
def _invoice_cancel(self, cr, uid, data, context):
return self._compute_refund(cr, uid, data, 'cancel', context)
def _invoice_modify(self, cr, uid, data, context):
return self._compute_refund(cr, uid, data, 'modify', context)
def _compute_refund(self, cr, uid, data, mode, context):
form = data['form']
pool = pooler.get_pool(cr.dbname)
reconcile_obj = pool.get('account.move.reconcile')
account_m_line_obj = pool.get('account.move.line')
created_inv = []
date = False
period = False
description = False
for inv in pool.get('account.invoice').browse(cr, uid, data['ids']):
if inv.state in ['draft', 'proforma2', 'cancel']:
raise wizard.except_wizard(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
if form['period'] :
period = form['period']
else:
period = inv.period_id and inv.period_id.id or False
if form['date'] :
date = form['date']
if not form['period'] :
cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'")
result_query = cr.fetchone()
if result_query:
#in multi company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop and company_id = %s limit 1 """,
(form['date'],pool.get('res.users').browse(cr,uid,uid).company_id.id,))
else:
#in mono company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop limit 1 """,
(form['date'],))
res = cr.fetchone()
if res:
period = res[0]
else:
date = inv.date_invoice
if form['description'] :
description = form['description']
else:
description = inv.name
if not period:
raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
# we compute due date
#!!!due date = date inv date on formdate
pool.get('account.invoice').write(cr, uid, [refund.id],{'date_due':date,'check_total':inv.check_total})
# to make the taxes calculated
pool.get('account.invoice').button_compute(cr, uid, refund_id)
created_inv.append(refund_id[0])
#if inv is paid we unreconcile
if mode in ('cancel','modify'):
movelines = inv.move_id.line_id
#we unreconcile the lines
to_reconcile_ids = {}
for line in movelines :
#if the account of the line is the as the one in the invoice
#we reconcile
if line.account_id.id == inv.account_id.id :
to_reconcile_ids[line.account_id.id] =[line.id]
if type(line.reconcile_id) != osv.orm.browse_null :
reconcile_obj.unlink(cr,uid, line.reconcile_id.id)
#we advance the workflow of the refund to open
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', refund.id, 'invoice_open', cr)
#we reload the browse record
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
#we match the line to reconcile
for tmpline in refund.move_id.line_id :
if tmpline.account_id.id == inv.account_id.id :
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
for account in to_reconcile_ids :
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
writeoff_period_id=period,
writeoff_journal_id=inv.journal_id.id,
writeoff_acc_id=inv.account_id.id
)
#we create a new invoice that is the copy of the original
if mode == 'modify' :
invoice = pool.get('account.invoice').read(cr, uid, [inv.id],
['name', 'type', 'number', 'reference',
'comment', 'date_due', 'partner_id', 'address_contact_id',
'address_invoice_id', 'partner_insite','partner_contact',
'partner_ref', 'payment_term', 'account_id', 'currency_id',
'invoice_line', 'tax_line', 'journal_id','period_id'
]
)
invoice = invoice[0]
del invoice['id']
invoice_lines = pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'])
invoice_lines = pool.get('account.invoice')._refund_cleanup_lines(cr, uid, invoice_lines)
tax_lines = pool.get('account.invoice.tax').read(
cr, uid, invoice['tax_line'])
tax_lines = pool.get('account.invoice')._refund_cleanup_lines(cr, uid, tax_lines)
invoice.update({
'type': inv.type,
'date_invoice': date,
'state': 'draft',
'number': False,
'invoice_line': invoice_lines,
'tax_line': tax_lines,
'period_id': period,
'name':description
})
#take the id part of the tuple returned for many2one fields
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
inv_id = pool.get('account.invoice').create(cr, uid, invoice,{})
# we compute due date
if inv.payment_term.id:
data = pool.get('account.invoice').onchange_payment_term_date_invoice(cr, uid, [inv_id],inv.payment_term.id,date)
if 'value' in data and data['value']:
pool.get('account.invoice').write(cr, uid, [inv_id],data['value'])
created_inv.append(inv_id)
#we get the view id
mod_obj = pool.get('ir.model.data')
act_obj = pool.get('ir.actions.act_window')
if inv.type == 'out_invoice':
xml_id = 'action_invoice_tree5'
elif inv.type == 'in_invoice':
xml_id = 'action_invoice_tree8'
elif type == 'out_refund':
xml_id = 'action_invoice_tree10'
else:
xml_id = 'action_invoice_tree12'
#we get the model
result = mod_obj._get_id(cr, uid, 'account', xml_id)
id = mod_obj.read(cr, uid, result, ['res_id'])['res_id']
# we read the act window
result = act_obj.read(cr, uid, id)
result['res_id'] = created_inv
return result
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':sur_form, 'fields':sur_fields, 'state':[('end','Cancel'),('refund','Refund Invoice'),('cancel_invoice','Cancel Invoice'),('modify_invoice','Modify Invoice')]}
},
'refund': {
'actions': [],
'result': {'type':'action', 'action':_invoice_refund, 'state':'end'},
},
'cancel_invoice': {
'actions': [],
'result': {'type':'action', 'action':_invoice_cancel, 'state':'end'},
},
'modify_invoice': {
'actions': [],
'result': {'type':'action', 'action':_invoice_modify, 'state':'end'},
},
}
wiz_refund('account.invoice.refund')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,61 +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
#
# TODO: add an intermediate screen for checks
#
_subscription_form = '''<?xml version="1.0"?>
<form string="%s">
<separator string="Generate entries before:" colspan="4"/>
<field name="date"/>
</form>''' % ('Subscription Compute',)
_subscription_fields = {
'date': {'string':'Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
}
class wiz_subscription(wizard.interface):
def _action_generate(self, cr, uid, data, context={}):
cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['form']['date'],))
ids = map(lambda x: x[0], cr.fetchall())
pooler.get_pool(cr.dbname).get('account.subscription.line').move_create(cr, uid, ids)
return {}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_subscription_form, 'fields':_subscription_fields, 'state':[('end','Cancel', 'gtk-cancel'),('generate','Compute', 'gtk-ok')]}
},
'generate': {
'actions': [_action_generate],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_subscription('account.subscription.generate')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,59 +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
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="account_id"/>
</form>''' % ('Unreconciliation',)
_journal_fields = {
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
return {
'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['form']['account_id'],
'name': 'Unreconciliation',
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
class wiz_unrec_select(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel', 'gtk-cancel'),('open','Open for unreconciliation', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_unrec_select('account.move.line.unreconcile.select')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -1
View File
@@ -41,13 +41,14 @@
'depends': ['crm', 'base_contact', 'account'],
'init_xml': ['event_data.xml'],
'update_xml': [
'event_wizard.xml',
'wizard/event_confirm_registration_view.xml',
'event_view.xml',
'event_sequence.xml',
'security/event_security.xml',
'security/ir.model.access.csv',
'wizard/event_registration_view.xml',
'wizard/event_registrations_partner.xml',
'wizard/event_make_invoice_view.xml',
],
'demo_xml': ['event_demo.xml'],
'installable': True,
+27 -2
View File
@@ -151,6 +151,31 @@ event()
class event_registration(osv.osv):
def check_confirm(self, cr, uid, ids, context):
mod_obj = self.pool.get('ir.model.data')
current_registration = self.browse(cr, uid, [ids[0]])[0]
total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
if total_confirmed <= current_registration.event_id.register_max or current_registration.event_id.register_max == 0:
self.write(cr, uid, [ids[0]], {'state':'open'}, context=context)
self._history(cr, uid, [ids[0]], 'Open', history=True)
self.mail_user(cr, uid, [ids[0]])
return True
else:
model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_event_confirm_registration')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context.update({'reg_id': ids[0]})
return {
'name': _('Confirm Registration'),
'context': context,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'event.confirm.registration',
'views': [(resource_id,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
def _history(self, cr, uid,ids,keyword, history=False, email=False, context={}):
for case in self.browse(cr, uid, ids):
if not case.case_id:
@@ -244,14 +269,14 @@ class event_registration(osv.osv):
"invoice_id":fields.many2one("account.invoice","Invoice"),
'date_closed': fields.datetime('Closed', readonly=True),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id)]"),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
}
_defaults = {
'nb_register': lambda *a: 1,
+2 -2
View File
@@ -162,7 +162,7 @@
<field name="arch" type="xml">
<tree string="Registration">
<field name="id"/>
<field name="date"/>
<field name="create_date"/>
<field name="event_id"/>
<field name="partner_id"/>
<field name="nb_register"/>
@@ -203,7 +203,7 @@
<group col="8" colspan="4">
<field name="state" select="1" colspan="2"/>
<button name="button_reg_close" string="Registration Invoiced" states="open" type="object" icon="gtk-print"/>
<button name="%(event_confirm_registration)d" string="Confirm Registration" states="draft" type="action" icon="gtk-apply"/>
<button name="check_confirm" string="Confirm Registration" states="draft" type="object" icon="gtk-apply"/>
<button name="button_reg_cancel" string="Cancel Registration" states="draft,open" type="object" icon="gtk-cancel"/>
</group>
</page>
-32
View File
@@ -1,32 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<!-- <wizard
string="Registrations"
model="event.event"
name="wizard_event_registration"
id="wizard_event_registration"/> -->
<!-- <wizard
string="List Register Partners"
model="event.event"
name="event.event_reg_partners"
id="wizard_event_reg_partners"/> -->
<wizard string="Make Invoice"
model="event.registration"
name="event.reg_make_invoice"
id="event_reg_invoice"
menu="True"
/>
<wizard string="Confirm Registration"
model="event.registration"
name="event.confirm_registration"
id="event_confirm_registration"
menu="False"
/>
</data>
</openerp>
+2 -2
View File
@@ -20,7 +20,7 @@
##############################################################################
import event_registration
import make_invoice
import event_make_invoice
import event_registrations_partner
import confirm_registration
import event_confirm_registration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,80 +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 ir
import pooler
from osv.osv import except_osv
from osv import fields,osv
import netsvc
ARCH = '''<?xml version="1.0"?>
<form string="Registration Confirmation">
<label string="The event limit is reached. What do you want to do?" colspan="4"/>
</form>'''
ARCH_fields={}
def _confirm(self, cr, uid, data, context):
registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
current_registration = registration_obj.browse(cr, uid, [data['id']])[0]
total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
if total_confirmed <= current_registration.event_id.register_max or current_registration.event_id.register_max == 0:
return 'confirm'
return 'split'
def _check_confirm(self, cr, uid, data, context):
registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
registration_obj.write(cr, uid, [data['id']], {'state':'open',})
registration_obj._history(cr, uid, [data['id']], 'Open', history=True)
registration_obj.mail_user(cr,uid,[data['id']])
return {}
class confirm_registration(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'choice', 'next_state' : _confirm}
},
'split' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : ARCH,'fields':ARCH_fields,
'state' : [('end', 'Cancel'),('confirm', 'Confirm Anyway') ]}
},
'confirm' : {
'actions' : [],
'result' : {'type' : 'action', 'action': _check_confirm, 'state' : 'end'}
},
'end' : {
'actions' : [],
'result': {'type': 'state', 'state': 'end'},
},
}
confirm_registration('event.confirm_registration')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,47 @@
# -*- 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
class event_confirm_registration(osv.osv_memory):
"""
Confirm Event Registration
"""
_name = "event.confirm.registration"
_description = "Event Registraion"
_columns = {
'msg': fields.text('Message', readonly=True),
}
_defaults={
'msg':lambda *a:'The event limit is reached. What do you want to do?'
}
def confirm(self, cr, uid, ids, context):
registration_obj = self.pool.get('event.registration')
reg_id = context.get('reg_id', False) or context.get('active_id', False)
if reg_id:
registration_obj.write(cr, uid, [reg_id], {'state':'open',})
registration_obj._history(cr, uid, [reg_id], 'Open', history=True)
registration_obj.mail_user(cr,uid,[reg_id])
return {}
event_confirm_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_event_confirm_registration" model="ir.ui.view">
<field name="name">Registration Confirmation</field>
<field name="model">event.confirm.registration</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Registration Confirmation">
<field name="msg"/>
<separator string="" colspan="4"/>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
<button icon="gtk-ok" name="confirm" string="Confirm Anyway" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_event_confirm_registration" model="ir.actions.act_window">
<field name="name">Registrations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.confirm.registration</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_event_confirm_registration"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
</data>
</openerp>
+140
View File
@@ -0,0 +1,140 @@
# -*- 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
class event_make_invoice(osv.osv_memory):
"""
Make Invoices
"""
_name = "event.make.invoice"
_description = "Event Make Invoice"
_columns = {
'inv_created': fields.char('Invoice Created', size=32, readonly=True),
'inv_rejected': fields.char('Invoice Rejected', size=32, readonly=True),
'inv_rej_reason': fields.text('Error Messages', readonly=True),
# 'invoice_ids': fields.char('Invoice Ids', size=128), # Improve me
}
def _makeInvoices(self, cr, uid, context={}):
invoices = {}
invoice_ids = []
create_ids=[]
tax_ids=[]
inv_create = 0
inv_reject = 0
inv_rej_reason = ""
list_inv = []
obj_event_reg = self.pool.get('event.registration')
obj_lines = self.pool.get('account.invoice.line')
inv_obj = self.pool.get('account.invoice')
data_event_reg = obj_event_reg.browse(cr,uid, context['active_ids'], context=context)
for reg in data_event_reg:
if reg.state=='draft':
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Invoice cannot be created if the registration is in draft state. \n"
continue
if (not reg.tobe_invoiced):
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registration is set as 'Cannot be invoiced'. \n"
continue
if reg.invoice_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registration already has an invoice linked. \n"
continue
if not reg.event_id.product_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Event related doesn't have any product defined. \n"
continue
if not reg.partner_invoice_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registration doesn't have any partner to invoice. \n"
continue
partner_address_list = reg.partner_invoice_id and self.pool.get('res.partner').address_get(cr, uid, [reg.partner_invoice_id.id], adr_pref=['invoice'])
partner_address_id = partner_address_list['invoice']
if not partner_address_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registered partner doesn't have an address to make the invoice. \n"
continue
inv_create = inv_create + 1
value = obj_lines.product_id_change(cr, uid, [], reg.event_id.product_id.id,uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id)
data_product = self.pool.get('product.product').browse(cr,uid,[reg.event_id.product_id.id])
for tax in data_product[0].taxes_id:
tax_ids.append(tax.id)
vals = value['value']
vals.update({
'name': reg.name,
'price_unit': reg.unit_price,
'quantity': reg.nb_register,
'product_id':reg.event_id.product_id.id,
'invoice_line_tax_id': [(6, 0, tax_ids)],
})
inv_line_ids = obj_event_reg._create_invoice_lines(cr, uid, [reg.id], vals)
inv = {
'name': reg.invoice_label,
'origin': reg.invoice_label,
'type': 'out_invoice',
'reference': False,
'account_id': reg.partner_invoice_id.property_account_receivable.id,
'partner_id': reg.partner_invoice_id.id,
'address_invoice_id':partner_address_id,
'address_contact_id':partner_address_id,
'invoice_line': [(6,0,[inv_line_ids])],
'currency_id' :reg.partner_invoice_id.property_product_pricelist.currency_id.id,
'comment': "",
'payment_term':reg.partner_invoice_id.property_payment_term.id,
'fiscal_position': reg.partner_invoice_id.property_account_position.id
}
inv_id = inv_obj.create(cr, uid, inv)
list_inv.append(inv_id)
obj_event_reg.write(cr, uid, reg.id, {'invoice_id': inv_id, 'state': 'done'})
obj_event_reg._history(cr, uid, [reg.id], 'Invoiced', history=True)
# {'inv_created' : str(inv_create) , 'inv_rejected' : str(inv_reject), 'invoice_ids': str(list_inv), 'inv_rej_reason': inv_rej_reason}
return {'inv_created' : str(inv_create) , 'inv_rejected' : str(inv_reject), 'inv_rej_reason': inv_rej_reason}
def default_get(self, cr, uid, fields_list, context=None):
res = super(event_make_invoice, self).default_get(cr, uid, fields_list, context)
res.update(self._makeInvoices(cr, uid, context=context))
return res
def confirm(self, cr, uid, ids, context={}):
obj_model = self.pool.get('ir.model.data')
data_inv = self.read(cr, uid, ids, [], context)[0]
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')])
resource_id = obj_model.read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
return {
# 'domain': "[('id','in', ["+','.join(map(str,data_inv['invoice_ids']))+"])]",
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'views': [(False,'tree'),(resource_id,'form')],
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window'
}
event_make_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_event_make_invoice" model="ir.ui.view">
<field name="name">event.make.invoice</field>
<field name="model">event.make.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Make Invoices">
<field name="inv_created" />
<field name="inv_rejected" />
<field name="inv_rej_reason" colspan="4"/>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Ok"/>
<button icon="gtk-ok" name="confirm" string="Open" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_event_confirm_registration" model="ir.actions.act_window">
<field name="name">Make Invoices</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.make.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_event_make_invoice"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
<act_window id="action_make_invoices"
key2 = "client_action_multi" name="Make Invoice"
res_model="event.make.invoice" src_model="event.registration"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>
-158
View File
@@ -1,158 +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
form = """<?xml version="1.0"?>
<form string="Create Invoices">
<newline />
<field name="inv_created"/>
<newline />
<field name="inv_rejected"/>
<newline />
<field name="inv_rej_reason" width="400"/>
</form>
"""
fields = {
'inv_created': {'string':'Invoice Created', 'type':'char', 'readonly':True},
'inv_rejected': {'string':'Invoice Rejected', 'type':'char', 'readonly':True},
'inv_rej_reason': {'string':'Error Messages', 'type':'text', 'readonly':True},
}
def _makeInvoices(self, cr, uid, data, context):
invoices = {}
invoice_ids = []
create_ids=[]
tax_ids=[]
pool_obj=pooler.get_pool(cr.dbname)
inv_create = 0
inv_reject = 0
inv_rej_reason = ""
list_inv = []
obj_event_reg=pool_obj.get('event.registration')
data_event_reg=obj_event_reg.browse(cr,uid,data['ids'])
obj_lines=pool_obj.get('account.invoice.line')
for reg in data_event_reg:
if reg.state=='draft':
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Invoice cannot be created if the registration is in draft state. \n"
continue
if (not reg.tobe_invoiced):
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registration is set as 'Cannot be invoiced'. \n"
continue
if reg.invoice_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registration already has an invoice linked. \n"
continue
if not reg.event_id.product_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Event related doesn't have any product defined. \n"
continue
if not reg.partner_invoice_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registration doesn't have any partner to invoice. \n"
continue
partner_address_list = reg.partner_invoice_id and pool_obj.get('res.partner').address_get(cr, uid, [reg.partner_invoice_id.id], adr_pref=['invoice'])
partner_address_id = partner_address_list['invoice']
if not partner_address_id:
inv_reject = inv_reject + 1
inv_rej_reason += "ID "+str(reg.id)+": Registered partner doesn't have an address to make the invoice. \n"
continue
inv_create = inv_create + 1
value=obj_lines.product_id_change(cr, uid, [], reg.event_id.product_id.id,uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id)
data_product=pool_obj.get('product.product').browse(cr,uid,[reg.event_id.product_id.id])
for tax in data_product[0].taxes_id:
tax_ids.append(tax.id)
vals = value['value']
vals.update({
'name': reg.name,
'price_unit': reg.unit_price,
'quantity': reg.nb_register,
'product_id':reg.event_id.product_id.id,
'invoice_line_tax_id': [(6,0,tax_ids)],
})
inv_line_ids = obj_event_reg._create_invoice_lines(cr, uid, [reg.id], vals)
inv = {
'name': reg.invoice_label,
'origin': reg.invoice_label,
'type': 'out_invoice',
'reference': False,
'account_id': reg.partner_invoice_id.property_account_receivable.id,
'partner_id': reg.partner_invoice_id.id,
'address_invoice_id':partner_address_id,
'address_contact_id':partner_address_id,
'invoice_line': [(6,0,[inv_line_ids])],
'currency_id' :reg.partner_invoice_id.property_product_pricelist.currency_id.id,
'comment': "",
'payment_term':reg.partner_invoice_id.property_payment_term.id,
'fiscal_position': reg.partner_invoice_id.property_account_position.id
}
inv_obj = pool_obj.get('account.invoice')
inv_id = inv_obj.create(cr, uid, inv)
list_inv.append(inv_id)
obj_event_reg.write(cr, uid,reg.id, {'invoice_id' : inv_id,'state':'done'})
obj_event_reg._history(cr, uid,[reg.id], 'Invoiced', history=True)
return {'inv_created' : str(inv_create) , 'inv_rejected' : str(inv_reject) , 'invoice_ids': list_inv, 'inv_rej_reason': inv_rej_reason}
class make_invoice(wizard.interface):
def _list_invoice(self, cr, uid, data, context):
pool_obj = pooler.get_pool(cr.dbname)
model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')])
resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
return {
'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]",
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'views': [(False,'tree'),(resource_id,'form')],
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window'
}
states = {
'init' : {
'actions' : [_makeInvoices],
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state':[('end','Ok'),('open','Open')]}
},
'open': {
'actions': [],
'result': {'type':'action', 'action':_list_invoice, 'state':'end'}
}
}
make_invoice("event.reg_make_invoice")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+3 -3
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,11 +15,11 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import company
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+10 -9
View File
@@ -18,10 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Belgium - Plan Comptable Minimum Normalise',
{ 'name': 'Belgium - Plan Comptable Minimum Normalise',
'version': '1.1',
'category': 'Localisation/Account Charts',
'description': """
@@ -34,8 +31,12 @@
* This is the same wizard that runs from Financial Management/Configuration/Financial Accounting/Financial Accounts/Generate Chart of Accounts from a Chart Template.
Wizards provided by this module:
* Enlist the partners with their related VAT and invoiced amounts.Prepares an XML file format.Path to access : Financial Management/Reporting/Listing of VAT Customers.
* Prepares an XML file for Vat Declaration of the Main company of the User currently Logged in.Path to access : Financial Management/Reporting/Listing of VAT Customers.
* Partner VAT Intra: Enlist the partners with their related VAT and invoiced amounts.Prepares an XML file format.
Path to access : Financial Management/Reporting//Legal Statements/Belgium Statements/Partner VAT Listing
* Periodical VAT Declaration: Prepares an XML file for Vat Declaration of the Main company of the User currently Logged in.
Path to access : Financial Management/Reporting/Legal Statements/Belgium Statements/Periodical VAT Declaration
* Annual Listing Of VAT-Subjected Customers: Prepares an XML file for Vat Declaration of the Main company of the User currently Logged in.Based on Fiscal year
Path to access : Financial Management/Reporting/Legal Statements/Belgium Statements/Annual Listing Of VAT-Subjected Customers
""",
'author': 'Tiny',
@@ -51,13 +52,13 @@
'account_pcmn_belgium.xml',
'l10n_be_wizard.xml',
'wizard/l10n_be_account_vat_declaration_view.xml',
'wizard/l10n_be_vat_intra_view.xml',
'wizard/l10n_be_partner_vat_listing.xml',
'l10n_be_sequence.xml',
'fiscal_templates.xml',
'security/ir.model.access.csv'
],
'demo_xml': [
'account.report.report.csv'
],
'demo_xml': ['account.report.report.csv'],
'installable': True,
'certificate': '0031977724637',
}
-81
View File
@@ -2,90 +2,9 @@
<openerp>
<data>
<menuitem
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
<wizard
string="Annual Listing of VAT-Subjected Customers"
model="res.partner"
name="list.vat.detail"
menu="False"
id="partner_wizard_vat"/>
<menuitem
name="Annual Listing of VAT-Subjected Customers"
parent="menu_finance_belgian_statement"
action="partner_wizard_vat"
type="wizard"
id="partner_wizard_vat_menu"/>
<!-- <wizard
string="Periodical VAT Declaration"
name="wizard.account.xml.vat.declaration"
menu="False"
id="wizard_xml_vat_declaration"/>
<menuitem
name="Periodical VAT Declaration"
parent="menu_finance_belgian_statement"
action="wizard_xml_vat_declaration"
type="wizard"
id="account_wizard_vat_declaration"/> -->
<wizard
string="Partner VAT intra"
model="res.partner"
name="vat.intra.xml"
menu="False"
id="partner_vat_intra"/>
<menuitem
name="Partner VAT intra"
parent="menu_finance_belgian_statement"
action="partner_vat_intra"
type="wizard"
id="partner_intra_vat_menu"/>
<record id="config_call_account_template" model="ir.actions.todo">
<field name="action_id" ref="account.action_wizard_multi_chart"/>
</record>
<!-- osv_memory for vat listing of clients -->
<record id="view_vat_listing" model="ir.ui.view">
<field name="name">step.vat.listing</field>
<field name="model">vat.listing.clients</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="VAT listing">
<field name="name"/>
<field name="vat"/>
<newline/>
<field name="country"/>
<newline/>
<field name="amount"/>
<field name="turnover"/>
</form>
</field>
</record>
<record id="view_vat_listing" model="ir.ui.view">
<field name="name">step.vat.listing</field>
<field name="model">vat.listing.clients</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="VAT listing">
<field name="name"/>
<field name="vat"/>
<newline/>
<field name="country"/>
<newline/>
<field name="amount"/>
<field name="turnover"/>
</tree>
</field>
</record>
</data>
</openerp>
+2 -4
View File
@@ -19,10 +19,8 @@
#
##############################################################################
import account_vat_declaration
import partner_vat_listing
import wizard_vat_intra
import l10_be_partner_vat_listing
import l10n_be_vat_intra
import l10n_be_account_vat_declaration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,3 +1,6 @@
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# -*- coding: utf-8 -*-
##############################################################################
#
@@ -19,13 +22,8 @@
#
##############################################################################
import time
import datetime
import base64
from tools.translate import _
import tools
import wizard
import pooler
from tools.translate import _
import tools
from osv import fields, osv
@@ -33,75 +31,32 @@ from osv import fields, osv
class vat_listing_clients(osv.osv_memory):
_name = 'vat.listing.clients'
_columns = {
'name': fields.char('Cleint Name', size=64),
'name': fields.char('Client Name', size=64),
'vat': fields.char('VAT', size=64),
'country': fields.char('Country', size=64),
'amount': fields.float('Amount'),
'turnover': fields.float('Turnover'),
}
}
vat_listing_clients()
form = """<?xml version="1.0"?>
<form string="Select Fiscal Year">
<label string="This wizard will create an XML file for Vat details and total invoiced amounts per partner." colspan="4"/>
<newline/>
<field name="fyear" />
<newline/>
<field name="mand_id" help="Should be provided when subscription of INTERVAT service is done"/>
<newline/>
<field name="limit_amount" help="Limit under which the partners will not be included into the listing"/>
<newline/>
<field name="test_xml" help="Sets the XML output as test file"/>
</form>"""
class partner_vat(osv.osv_memory):
""" Vat Listing """
_name = "partner.vat"
fields = {
'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True,},
'mand_id':{'string':'MandataireId','type':'char','size':'30','required': True,},
'limit_amount':{'string':'Limit Amount','type':'integer','required': True, },
'test_xml': {'string':'Test XML file', 'type':'boolean', },
}
client_form = """<?xml version="1.0"?>
<form string="Select Fiscal Year">
<label string="You can remove clients/partners which you do not want in exported xml file" colspan="4"/>
<separator string="Clients" colspan="4"/>
<field name="partners" colspan="4" width="600" height="250" widget="one2many" nolabel="1"/>
</form>"""
client_fields = {
'partners': {'string': 'Cleints', 'type': 'many2many', 'relation': 'vat.listing.clients', 'required': False, 'help': 'You can remove clients/partners which you do not want to show in xml file'},
}
msg_form = """<?xml version="1.0"?>
<form string="Notification">
<separator string="XML File has been Created." colspan="4"/>
<field name="msg" colspan="4" nolabel="1"/>
<field name="name"/>
<newline/>
<field name="file_save" />
</form>"""
msg_fields = {
'name': {'string': 'File name', 'type':'char', 'size':'32'},
'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},
'file_save':{'string': 'Save File',
'type': 'binary',
'readonly': True,},
}
class wizard_vat(wizard.interface):
def _get_partner(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
period = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fyear'])])
p_id_list = pool.get('res.partner').search(cr,uid,[('vat_subjected','!=',False)])
def get_partner(self, cursor, user, ids, context={}):
obj_period = self.pool.get('account.period')
obj_partner = self.pool.get('res.partner')
obj_vat_lclient = self.pool.get('vat.listing.clients')
obj_model_data = self.pool.get('ir.model.data')
data = self.read(cursor, user, ids)[0]
period = obj_period.search(cursor, user, [('fiscalyear_id', '=', data['fyear'])], context=context)
p_id_list = obj_partner.search(cursor, user, [('vat_subjected', '!=', False)], context=context)
if not p_id_list:
raise wizard.except_wizard(_('Data Insufficient!'),_('No partner has a VAT Number asociated with him.'))
raise osv.except_osv(_('Data Insufficient!'), _('No partner has a VAT Number asociated with him.'))
partners = []
records = []
for obj_partner in pool.get('res.partner').browse(cr, uid, p_id_list):
for obj_partner in obj_partner.browse(cursor, user, p_id_list, context=context):
record = {} # this holds record per partner
#This listing is only for customers located in belgium, that's the
@@ -114,8 +69,8 @@ class wizard_vat(wizard.interface):
break
if not go_ahead:
continue
cr.execute('select b.code,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in %s and l.partner_id=%s and l.period_id=ANY(%s) group by b.code',(('produit','tax'),obj_partner.id,period,))
line_info = cr.fetchall()
cursor.execute('select b.code, sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in %s and l.partner_id=%s and l.period_id=ANY(%s) group by b.code',(('produit','tax'),obj_partner.id,period,))
line_info = cursor.fetchall()
if not line_info:
continue
@@ -127,7 +82,7 @@ class wizard_vat(wizard.interface):
#~addr = pool.get('res.partner').address_get(cr, uid, [obj_partner.id], ['invoice'])
#~ if addr.get('invoice',False):
#~ads=pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
#~ads=pool.get('res.partner.address').browse(cr, uid, [addr['invoice']])[0]
#~ if ads.country_id:
#~ record.append(ads.country_id.code)
@@ -141,38 +96,81 @@ class wizard_vat(wizard.interface):
record['amount'] = 0
record['turnover'] = 0
record['name'] = obj_partner.name
for item in line_info:
if item[0]=='produit':
if item[0] == 'produit':
record['turnover'] += item[1]
else:
record['amount'] += item[1]
id_client = pool.get('vat.listing.clients').create(cr, uid, record)
id_client = obj_vat_lclient.create(cursor, user, record, context=context)
partners.append(id_client)
records.append(record)
context.update({'partner_ids': partners, 'fyear': data['fyear'], 'limit_amount': data['limit_amount'], 'mand_id':data['mand_id']})
model_data_ids = obj_model_data.search(cursor, user, [('model','=','ir.ui.view'), ('name','=','view_vat_listing')])
resource_id = obj_model_data.read(cursor, user, model_data_ids, fields=['res_id'])[0]['res_id']
return {
# 'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]",
'name': 'Vat Listing',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'partner.vat.list',
'views': [(resource_id,'form')],
'context': context,
'type': 'ir.actions.act_window',
'target': 'new',
}
return {'partners':partners}
_columns = {
'fyear': fields.many2one('account.fiscalyear','Fiscal Year', required=True),
'mand_id': fields.char('MandataireId', size=14, required=True, help="This identifies the representative of the sending company. This is a string of 14 characters"),
'limit_amount': fields.integer('Limit Amount', required=True),
'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"),
}
partner_vat()
def _create_xml(self, cr, uid, data, context):
class partner_vat_list(osv.osv_memory):
""" Partner Vat Listing """
_name = "partner.vat.list"
_columns = {
'partner_ids': fields.many2many('vat.listing.clients', 'vat_partner_rel', 'vat_id', 'partner_id', 'Clients', required=False, help='You can remove clients/partners which you do not want to show in xml file'),
'name': fields.char('File Name', size=32),
'msg': fields.text('File created', size=64, readonly=True),
'file_save' : fields.binary('Save File', readonly=True),
}
def _get_partners(self, cursor, user, context={}):
return context.get('partner_ids', [])
_defaults={
'partner_ids': _get_partners
}
def create_xml(self, cursor, user, ids, context={}):
datas=[]
pool = pooler.get_pool(cr.dbname)
seq_controlref = pool.get('ir.sequence').get(cr, uid,'controlref')
seq_declarantnum = pool.get('ir.sequence').get(cr, uid,'declarantnum')
obj_cmpny = pool.get('res.users').browse(cr, uid, uid).company_id
obj_sequence = self.pool.get('ir.sequence')
obj_users = self.pool.get('res.users')
obj_partner = self.pool.get('res.partner')
obj_fyear = self.pool.get('account.fiscalyear')
obj_addr = self.pool.get('res.partner.address')
obj_vat_lclient = self.pool.get('vat.listing.clients')
obj_model_data = self.pool.get('ir.model.data')
seq_controlref = obj_sequence.get(cursor, user, 'controlref')
seq_declarantnum = obj_sequence.get(cursor, user, 'declarantnum')
obj_cmpny = obj_users.browse(cursor, user, user, context=context).company_id
company_vat = obj_cmpny.partner_id.vat
if not company_vat:
raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
cref = company_vat + seq_controlref
dnum = cref + seq_declarantnum
obj_year=pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear'])
obj_year= obj_fyear.browse(cursor, user, context['fyear'], context=context)
street = zip_city = country = ''
addr = pool.get('res.partner').address_get(cr, uid, [obj_cmpny.partner_id.id], ['invoice'])
addr = obj_partner.address_get(cursor, user, [obj_cmpny.partner_id.id], ['invoice'])
if addr.get('invoice',False):
ads=pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
ads = obj_addr.browse(cursor, user, [addr['invoice']], context=context)[0]
zip_city = pool.get('res.partner.address').get_city(cr,uid,ads.id)
zip_city = obj_addr.get_city(cursor, user, ads.id)
if not zip_city:
zip_city = ''
if ads.street:
@@ -185,8 +183,8 @@ class wizard_vat(wizard.interface):
sender_date = time.strftime('%Y-%m-%d')
data_file = '<?xml version="1.0"?>\n<VatList xmlns="http://www.minfin.fgov.be/VatList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.minfin.fgov.be/VatList VatList.xml" RecipientId="VAT-ADMIN" SenderId="'+ str(company_vat) + '"'
data_file +=' ControlRef="'+ cref + '" MandataireId="'+ tools.ustr(data['form']['mand_id']) + '" SenderDate="'+ str(sender_date)+ '"'
if data['form']['test_xml']:
data_file +=' ControlRef="'+ cref + '" MandataireId="'+ tools.ustr(context['mand_id']) + '" SenderDate="'+ str(sender_date)+ '"'
if ['test_xml']:
data_file += ' Test="0"'
data_file += ' VersionTech="1.2">'
data_file += '\n<AgentRepr DecNumber="1">\n\t<CompanyInfo>\n\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t<Name>'+tools.ustr(obj_cmpny.name)+'</Name>\n\t\t<Street>'+ tools.ustr(street) +'</Street>\n\t\t<CityAndZipCode>'+ tools.ustr(zip_city) +'</CityAndZipCode>'
@@ -194,25 +192,24 @@ class wizard_vat(wizard.interface):
data_comp = '\n<CompanyInfo>\n\t<VATNum>'+str(company_vat)+'</VATNum>\n\t<Name>'+tools.ustr(obj_cmpny.name)+'</Name>\n\t<Street>'+ tools.ustr(street) +'</Street>\n\t<CityAndZipCode>'+ tools.ustr(zip_city) +'</CityAndZipCode>\n\t<Country>'+ tools.ustr(country) +'</Country>\n</CompanyInfo>'
data_period = '\n<Period>'+ tools.ustr(obj_year.date_stop[:4]) +'</Period>'
error_message = []
for partner in data['form']['partners']:
data = self.read(cursor, user, ids)[0]
for partner in data['partner_ids']:
if isinstance(partner, list) and partner:
datas.append(partner[2])
else:
client_data = pool.get('vat.listing.clients').read(cr, uid, partner, context=context)
client_data = obj_vat_lclient.read(cursor, user, partner, context=context)
datas.append(client_data)
seq=0
data_clientinfo=''
sum_tax=0.00
sum_turnover=0.00
seq = 0
data_clientinfo = ''
sum_tax = 0.00
sum_turnover = 0.00
if len(error_message):
data['form']['msg']='Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
return data['form']
msg ='Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
return msg
for line in datas:
if not line:
continue
if line['turnover'] < data['form']['limit_amount']:
if line['turnover'] < context['limit_amount']:
continue
seq +=1
sum_tax +=line['amount']
@@ -221,28 +218,11 @@ class wizard_vat(wizard.interface):
data_decl ='\n<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" TurnOverSum="'+ str(int(sum_turnover * 100)) +'" TaxSum="'+ str(int(sum_tax * 100)) +'" />'
data_file += tools.ustr(data_decl) + tools.ustr(data_comp) + tools.ustr(data_period) + tools.ustr(data_clientinfo) + '\n</VatList>'
msg = 'Save the File with '".xml"' extension.'
file_save = base64.encodestring(data_file.encode('utf8'))
self.write(cursor, user, ids, {'file_save':file_save, 'msg':msg, 'name':'vat_list.xml'}, context=context)
return True
data['form']['msg'] = 'Save the File with '".xml"' extension.'
data['form']['file_save'] = base64.encodestring(data_file.encode('utf8'))
data['form']['name'] = 'vat_list.xml'
return data['form']
partner_vat_list()
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancel', 'gtk-cancel'),('go_step','View Clients', 'gtk-ok')]},
},
'go_step': {
'actions': [_get_partner],
'result': {'type':'form', 'arch':client_form, 'fields':client_fields, 'state':[('end','Cancel', 'gtk-cancel'),('go','Create XML', 'gtk-ok')]},
},
'go': {
'actions': [_create_xml],
'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok', 'gtk-cancel')]},
}
}
wizard_vat('list.vat.detail')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,27 +18,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import datetime
import base64
from osv import osv, fields
from tools.translate import _
class l10n_be_vat_declaration(osv.osv_memory):
""" Vat Declaration """
""" Periodical VAT Declaration """
_name = "l1on_be.vat.declaration"
_description = "Vat Declaration"
_columns = {
'period_id': fields.many2one('account.period','Period', required=True),
'msg': fields.text('File created', size=64, readonly=True),
'file_save' : fields.binary('Save File'),
}
'file_save': fields.binary('Save File'),
}
_defaults = {
'msg': lambda *a:'''Save the File with '".xml"' extension.''',
}
}
def create_xml(self, cr, uid, ids, context={}):
obj_fyear = self.pool.get('account.fiscalyear')
@@ -53,7 +51,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
user_cmpny = obj_company.name
vat_no=obj_company.partner_id.vat
if not vat_no:
raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
tax_code_ids = obj_tax_code.search(cr, uid, [], context=context)
ctx = context.copy()
@@ -66,8 +64,6 @@ class l10n_be_vat_declaration(osv.osv_memory):
address = post_code = city = ''
city, post_code, address = obj_comp._get_default_ad(obj_company.partner_id.address)
year_id = obj_fyear.find(cr, uid)
account_period = obj_acc_period.browse(cr, uid, data['period_id'], context=context)
@@ -89,23 +85,23 @@ class l10n_be_vat_declaration(osv.osv_memory):
#starting month and ending month of selected period are not the same
#it means that the accounting isn't based on periods of 1 month but on quarters
quarter = str(((int(starting_month) - 1) / 3) + 1)
data_of_file += '<QUARTER>'+quarter+'</QUARTER>\n\t\t\t'
data_of_file += '<QUARTER>' + quarter + '</QUARTER>\n\t\t\t'
else:
data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t'
data_of_file += '<MONTH>' + starting_month + '</MONTH>\n\t\t\t'
data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'
data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
for item in tax_info:
if item['code']:
if item['code'] == '71-72':
item['code']='71'
item['code'] = '71'
if item['code'] in list_of_tags:
data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t\t<D' + str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
data['file_save'] = base64.encodestring(data_of_file)
self.write(cr, uid, ids, {'file_save':data['file_save']}, context=context)
return True
l10n_be_vat_declaration()
@@ -3,9 +3,9 @@
<data>
<menuitem
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
<record id="view_vat_declaration" model="ir.ui.view">
<field name="name">Select Period</field>
@@ -13,9 +13,9 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Period">
<group colspan="4" >
<field name="period_id" select="1"/>
<button colspan="1" name="create_xml" string="Create XML" type="object" default_focus="1"/>
<group colspan="4" >
<field name="period_id" select="1" default_focus="1"/>
<button colspan="1" name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
</group>
<separator string="XML Flie has been Created." colspan="4"/>
<group colspan="4" >
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
<record id="view_partner_vat_listing" model="ir.ui.view">
<field name="name">Partner VAT Listing</field>
<field name="model">partner.vat</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Fiscal Year">
<label string="This wizard will create an XML file for Vat details and total invoiced amounts per partner." colspan="4"/>
<newline/>
<field name="fyear" default_focus="1"/>
<newline/>
<field name="mand_id"/>
<newline/>
<field name="limit_amount"/>
<newline/>
<field name="test_xml"/>
<separator colspan="4"/>
<group colspan="4" >
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button colspan="1" name="get_partner" string="View Client" type="object" icon="terp-partner"/>
</group>
</form>
</field>
</record>
<record id="action_partner_vat_listing" model="ir.actions.act_window">
<field name="name">Partner VAT Listing</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">partner.vat</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_partner_vat_listing"/>
<field name="target">new</field>
</record>
<menuitem
name="Annual Listing Of VAT-Subjected Customers"
parent="menu_finance_belgian_statement"
action="action_partner_vat_listing"
id="partner_vat_listing"/>
<record id="view_vat_listing" model="ir.ui.view">
<field name="name">Vat Listing</field>
<field name="model">partner.vat.list</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Fiscal Year" >
<label string="You can remove clients/partners which you do not want in exported xml file" colspan="4"/>
<separator string="Clients" colspan="4"/>
<field name="partner_ids" colspan="4" nolabel="1" default_focus="1"/>
<separator colspan="4"/>
<group colspan="4" >
<button colspan="1" name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
</group>
<separator string="XML File has been Created." colspan="4"/>
<field name="msg" colspan="4" nolabel="1"/>
<field name="name"/>
<newline/>
<field name="file_save" />
<separator colspan="4"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
</form>
</field>
</record>
<!-- osv_memory for vat listing of clients -->
<record id="view_vat_listing_form" model="ir.ui.view">
<field name="name">step.vat.listing</field>
<field name="model">vat.listing.clients</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="VAT listing">
<field name="name"/>
<field name="vat"/>
<newline/>
<field name="country"/>
<newline/>
<field name="amount"/>
<field name="turnover"/>
</form>
</field>
</record>
<record id="view_vat_listing_tree" model="ir.ui.view">
<field name="name">step.vat.listing</field>
<field name="model">vat.listing.clients</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="VAT listing">
<field name="name"/>
<field name="vat"/>
<newline/>
<field name="country"/>
<newline/>
<field name="amount"/>
<field name="turnover"/>
</tree>
</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,92 +15,69 @@
# 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
import datetime
import pooler
import base64
form_intra = """<?xml version="1.0"?>
<form string="Partner VAT Intra">
<notebook>
<page string="General Information">
<label string="This wizard will create an XML file for Vat Intra" colspan="4"/>
<newline/>
<field name="fyear" />
<newline/>
<field name="mand_id" help="This identifies the representative of the sending company. This is a string of 14 characters"/>
<newline/>
<field name="trimester" help="It will be the first digit of period" />
<newline/>
<field name="test_xml" help="Sets the XML output as test file"/>
</page>
<page string="European Countries">
<field name="country_ids" colspan="4" nolabel="1" />
</page>
</notebook>
</form>"""
fields_intra = {
'trimester': {'string': 'Trimester Number', 'type': 'selection', 'selection':[
('1','Jan/Feb/Mar'),
('2','Apr/May/Jun'),
('3','Jul/Aug/Sep'),
('4','Oct/Nov/Dec')], 'required': True},
'test_xml': {'string':'Test XML file', 'type':'boolean'},
'mand_id':{'string':'MandataireId','type':'char','size':'14','required': True},
'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'country_ids': {
'string': 'European Countries',
'type': 'many2many',
'relation': 'res.country',
'required': False
},
}
from osv import osv, fields
msg_form = """<?xml version="1.0"?>
<form string="Notification">
<separator string="XML File has been Created." colspan="4"/>
<field name="msg" colspan="4" nolabel="1"/>
<field name="file_save" />
</form>"""
msg_fields = {
'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},
'file_save':{'string': 'Save File',
'type': 'binary',
'readonly': True,},
}
class partner_vat_intra(osv.osv_memory):
class parter_vat_intra(wizard.interface):
""" Partner Vat Intra"""
_name = "partner.vat.intra"
_description = 'Partner VAT Intra'
def _get_europe_country(self, cr, uid, data, context):
country_ids = pooler.get_pool(cr.dbname).get('res.country').search(cr, uid, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])
return {'country_ids': country_ids}
def _get_europe_country(self, cursor, user, context={}):
obj_country = self.pool.get('res.country')
return obj_country.search(cursor, user, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])
_columns = {
'trimester': fields.selection( [('1','Jan/Feb/Mar'),
('2','Apr/May/Jun'),
('3','Jul/Aug/Sep'),
('4','Oct/Nov/Dec')],
'Trimester Number', required=True, help="It will be the first digit of period"),
'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"),
'mand_id' : fields.char('MandataireId', size=14, required=True, help="This identifies the representative of the sending company. This is a string of 14 characters"),
'fyear': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True),
'msg': fields.text('File created', size=64, readonly=True),
'file_save' : fields.binary('Save File', readonly=True),
'country_ids': fields.many2many('res.country', 'vat_country_rel', 'vat_id', 'country_id', 'European Countries'),
}
_defaults = {
'country_ids': _get_europe_country,
}
def create_xml(self, cursor, user, ids, context={}):
obj_user = self.pool.get('res.users')
obj_fyear = self.pool.get('account.fiscalyear')
obj_sequence = self.pool.get('ir.sequence')
obj_partner = self.pool.get('res.partner')
obj_partner_add = self.pool.get('res.partner.address')
data_cmpny = obj_user.browse(cursor, user, user).company_id
data = self.read(cursor, user, ids)[0]
data_fiscal = obj_fyear.browse(cursor, user, data['fyear'], context=context)
def _create_xml(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
data_cmpny = pool.get('res.users').browse(cr, uid, uid).company_id
data_fiscal = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear'])
company_vat = data_cmpny.partner_id.vat
if not company_vat:
raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!')
raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
seq_controlref = pool.get('ir.sequence').get(cr, uid,'controlref')
seq_declarantnum = pool.get('ir.sequence').get(cr, uid,'declarantnum')
seq_controlref = obj_sequence.get(cursor, user, 'controlref')
seq_declarantnum = obj_sequence.get(cursor, user, 'declarantnum')
cref = company_vat + seq_controlref
dnum = cref + seq_declarantnum
if len(data_fiscal.date_start.split('-')[0]) < 4:
raise wizard.except_wizard('Data Insufficient','Trimester year should be length of 4 digits!')
period_trimester = data['form']['trimester'] + data_fiscal.date_start.split('-')[0]
raise osv.except_osv(_('Data Insufficient'),_('Trimester year should be length of 4 digits!'))
period_trimester = data['trimester'] + data_fiscal.date_start.split('-')[0]
street = zip_city = country = ''
addr = pool.get('res.partner').address_get(cr, uid, [data_cmpny.partner_id.id], ['invoice'])
addr = obj_partner.address_get(cursor, user, [data_cmpny.partner_id.id], ['invoice'])
if addr.get('invoice',False):
ads = pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
ads = obj_partner_add.browse(cursor, user, [addr['invoice']])[0]
zip_city = (ads.city or '') + ' ' + (ads.zip or '')
if zip_city== ' ':
zip_city = ''
@@ -114,8 +91,8 @@ class parter_vat_intra(wizard.interface):
sender_date = time.strftime('%Y-%m-%d')
data_file = '<?xml version="1.0"?>\n<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="' + str(company_vat) + '"'
data_file +=' ControlRef="' + cref + '" MandataireId="' + data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
if data['form']['test_xml']:
data_file +=' ControlRef="' + cref + '" MandataireId="' + data['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
if data['test_xml']:
data_file += ' Test="1"'
data_file += ' VersionTech="1.2">'
data_file +='\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
@@ -127,35 +104,35 @@ class parter_vat_intra(wizard.interface):
error_message = []
seq = 0
amount_sum = 0
p_id_list = pool.get('res.partner').search(cr,uid,[('vat','!=',False)])
p_id_list = obj_partner.search(cursor, user, [('vat','!=',False)])
if not p_id_list:
raise wizard.except_wizard('Data Insufficient!','No partner has a VAT Number asociated with him.')
raise osv.except_osv(_('Data Insufficient!'),_('No partner has a VAT Number asociated with him.'))
nb_period = len(data_fiscal.period_ids)
fiscal_periods = data_fiscal.period_ids
if data['form']['trimester'] == '1':
if data['trimester'] == '1':
if nb_period == 12:
start_date = fiscal_periods[0].date_start
end_date = fiscal_periods[2].date_stop
elif nb_period == 4:
start_date = fiscal_periods[0].date_start
end_date = fiscal_periods[0].date_stop
elif data['form']['trimester'] == '2':
elif data['trimester'] == '2':
if nb_period == 12:
start_date = fiscal_periods[3].date_start
end_date = fiscal_periods[5].date_stop
elif nb_period == 4:
start_date = fiscal_periods[1].date_start
end_date = fiscal_periods[1].date_stop
elif data['form']['trimester'] == '3':
elif data['trimester'] == '3':
if nb_period == 12:
start_date = fiscal_periods[6].date_start
end_date = fiscal_periods[8].date_stop
elif nb_period == 4:
start_date = fiscal_periods[2].date_start
end_date = fiscal_periods[2].date_stop
elif data['form']['trimester'] == '4':
elif data['trimester'] == '4':
if nb_period == 12:
start_date = fiscal_periods[9].date_start
end_date = fiscal_periods[11].date_stop
@@ -168,19 +145,19 @@ class parter_vat_intra(wizard.interface):
for p_id in p_id_list:
list_partner = []
partner = pool.get('res.partner').browse(cr, uid, p_id)
partner = obj_partner.browse(cursor, user, p_id, context=context)
go_ahead = False
country_code = ''
for ads in partner.address:
if ads.type == 'default' and (ads.country_id and ads.country_id.id in data['form']['country_ids'][0][2]):
if ads.type == 'default' and (ads.country_id and ads.country_id.id in data['country_ids']):
go_ahead = True
country_code = ads.country_id.code
break
if not go_ahead:
continue
cr.execute('select sum(debit)-sum(credit) as amount from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'receivable'"') and l.partner_id=%%s and l.date between %s' % (period,), (p_id,))
res = cr.dictfetchall()
cursor.execute('select sum(debit)-sum(credit) as amount from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'receivable'"') and l.partner_id=%%s and l.date between %s' % (period,), (p_id,))
res = cursor.dictfetchall()
list_partner.append(res[0]['amount'])
list_partner.append('T') #partner.ref ...should be check
list_partner.append(partner.vat)
@@ -202,8 +179,8 @@ class parter_vat_intra(wizard.interface):
record[p_id] = list_partner
if len(error_message):
data['form']['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
return data['form']
data['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
return data['msg']
data_clientinfo = ''
for r in record:
@@ -215,18 +192,11 @@ class parter_vat_intra(wizard.interface):
amount_sum = int(amount_sum)
data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >'
data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>'
data['form']['msg'] = 'Save the File with '".xml"' extension.'
data['form']['file_save'] = base64.encodestring(data_file)
return data['form']
data['msg'] = 'XML Flie has been Created. Save the File with '".xml"' extension.'
data['file_save'] = base64.encodestring(data_file)
self.write(cursor, user, ids, {'file_save':data['file_save'], 'msg':data['msg']}, context=context)
return True
states = {
'init': {
'actions': [_get_europe_country],
'result': {'type': 'form', 'arch':form_intra, 'fields': fields_intra, 'state':[('end','Cancel', 'gtk-cancel'),('go','Create XML', 'gtk-ok') ]}
},
'go': {
'actions': [_create_xml],
'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok', 'gtk-cancel')]},
}
}
parter_vat_intra('vat.intra.xml')
partner_vat_intra()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
<record id="view_vat_intra" model="ir.ui.view">
<field name="name">Partner VAT intra</field>
<field name="model">partner.vat.intra</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Partner VAT intra">
<notebook>
<page string="General Information">
<label string="This wizard will create an XML file for Vat Intra" colspan="4"/>
<newline/>
<field name="fyear" default_focus="1" />
<newline/>
<field name="mand_id"/>
<newline/>
<field name="trimester"/>
<newline/>
<field name="test_xml"/>
<newline/>
<button colspan="4" name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
<separator colspan="4"/>
<group colspan="4" >
<field name="msg" nolabel="1" colspan="4"/>
<field name="file_save" readonly="True"/>
</group>
<button special="cancel" colspan="4" string="Cancel" icon="gtk-cancel"/>
</page>
<page string="European Countries">
<field name="country_ids" colspan="4" nolabel="1" />
</page>
</notebook>
<newline/>
</form>
</field>
</record>
<record id="action_vat_intra" model="ir.actions.act_window">
<field name="name">Partner Vat Intra</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">partner.vat.intra</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_vat_intra"/>
<field name="target">new</field>
</record>
<menuitem
name="Partner VAT Intra"
parent="menu_finance_belgian_statement"
action="action_vat_intra"
id="l10_be_vat_intra"/>
</data>
</openerp>
+1 -1
View File
@@ -20,7 +20,7 @@
##############################################################################
import stock_traceability
import stock_move
import stock_move
import stock_partial_picking
import stock_partial_move
import stock_picking_make