bzr revid: olt@tinyerp.com-20090119090224-4ev07g50n3y5k9v6
This commit is contained in:
Olivier Laurent 2009-01-19 10:02:24 +01:00
commit 18aca884c2
20 changed files with 380 additions and 226 deletions

View File

@ -77,7 +77,8 @@ class account_payment_term_line(osv.osv):
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the payment term lines from the lowest sequences to the higher ones"),
'value': fields.selection([('procent','Percent'),('balance','Balance'),('fixed','Fixed Amount')], 'Value',required=True),
'value_amount': fields.float('Value Amount'),
'days': fields.integer('Number of Days',required=True, help="Number of days to add before computation of the day of month."),
'days': fields.integer('Number of Days',required=True, help="Number of days to add before computation of the day of month." \
"If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."),
'days2': fields.integer('Day of the Month',required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."),
'payment_id': fields.many2one('account.payment.term','Payment Term', required=True, select=True),
}
@ -129,6 +130,7 @@ class account_account(osv.osv):
_name = "account.account"
_description = "Account"
_parent_store = True
_parent_order = 'length(code),code'
def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
@ -559,8 +561,8 @@ class account_period(osv.osv):
_columns = {
'name': fields.char('Period Name', size=64, required=True),
'code': fields.char('Code', size=12),
'special': fields.boolean('Special Period', size=12,
help="Special periods are periods that can overlap, like the 13rd period in fiscal years for closing entries."),
'special': fields.boolean('Opening/Closing Period', size=12,
help="These periods can overlap."),
'date_start': fields.date('Start of period', required=True, states={'done':[('readonly',True)]}),
'date_stop': fields.date('End of period', required=True, states={'done':[('readonly',True)]}),
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True),
@ -680,7 +682,6 @@ class account_fiscalyear(osv.osv):
_inherit = "account.fiscalyear"
_description = "Fiscal Year"
_columns = {
'start_journal_period_id':fields.many2one('account.journal.period','New Entries Journal'),
'end_journal_period_id':fields.many2one('account.journal.period','End of Year Entries Journal', readonly=True),
}
@ -1136,6 +1137,19 @@ class account_tax_code(osv.osv):
res[record.id] = round(_rec_get(record), 2)
return res
def _sum_year(self, cr, uid, ids, name, args, context):
if 'fiscalyear_id' in context and context['fiscalyear_id']:
fiscalyear_id = context['fiscalyear_id']
else:
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False)
where = ''
if fiscalyear_id:
pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids)
if pids:
where = ' and period_id in (' + (','.join(pids))+')'
return self._sum(cr, uid, ids, name, args, context,
where=where)
def _sum_period(self, cr, uid, ids, name, args, context):
if 'period_id' in context and context['period_id']:
period_id = context['period_id']
@ -1154,7 +1168,7 @@ class account_tax_code(osv.osv):
'name': fields.char('Tax Case Name', size=64, required=True),
'code': fields.char('Case Code', size=64),
'info': fields.text('Description'),
'sum': fields.function(_sum, method=True, string="Year Sum"),
'sum': fields.function(_sum_year, method=True, string="Year Sum"),
'sum_period': fields.function(_sum_period, method=True, string="Period Sum"),
'parent_id': fields.many2one('account.tax.code', 'Parent Code', select=True),
'child_ids': fields.one2many('account.tax.code', 'parent_id', 'Childs Codes'),
@ -1216,8 +1230,10 @@ class account_tax(osv.osv):
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the taxes lines from the lowest sequences to the higher ones. The order is important if you have a tax that have several tax childs. In this case, the evaluation order is important."),
'amount': fields.float('Amount', required=True, digits=(14,4)),
'active': fields.boolean('Active'),
'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code')], 'Tax Type', required=True),
'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True),
'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code'),('balance','Balance')], 'Tax Type', required=True,
help="The computation method for the tax amount."),
'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True,
help="If not applicable (computed through a Python code), the tax do not appears on the invoice."),
'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developpers to create specific taxes in a custom domain."),
'account_collected_id':fields.many2one('account.account', 'Invoice Tax Account'),
'account_paid_id':fields.many2one('account.account', 'Refund Tax Account'),
@ -1330,13 +1346,31 @@ class account_tax(osv.osv):
exec tax.python_compute in localdict
amount = localdict['result']
data['amount'] = amount
elif tax.type=='balance':
data['amount'] = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)
data['balance'] = cur_price_unit
amount2 = data['amount']
if len(tax.child_ids):
if tax.child_depend:
del res[-1]
latest = res.pop()
amount = amount2
child_tax = self._unit_compute(cr, uid, tax.child_ids, amount, address_id, product, partner)
res.extend(child_tax)
if tax.child_depend:
for r in res:
for name in ('base','ref_base'):
if latest[name+'_code_id'] and latest[name+'_sign'] and not r[name+'_code_id']:
r[name+'_code_id'] = latest[name+'_code_id']
r[name+'_sign'] = latest[name+'_sign']
r['price_unit'] = latest['price_unit']
latest[name+'_code_id'] = False
for name in ('tax','ref_tax'):
if latest[name+'_code_id'] and latest[name+'_sign'] and not r[name+'_code_id']:
r[name+'_code_id'] = latest[name+'_code_id']
r[name+'_sign'] = latest[name+'_sign']
r['amount'] = data['amount']
latest[name+'_code_id'] = False
if tax.include_base_amount:
cur_price_unit+=amount2
return res
@ -1352,8 +1386,14 @@ class account_tax(osv.osv):
one tax for each tax id in IDS and their childs
"""
res = self._unit_compute(cr, uid, taxes, price_unit, address_id, product, partner)
total = 0.0
for r in res:
r['amount'] *= quantity
if r.get('balance',False):
r['amount'] = round(r['balance'] * quantity, 2) - total
else:
r['amount'] = round(r['amount'] * quantity, 2)
total += r['amount']
return res
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
@ -1383,6 +1423,10 @@ class account_tax(osv.osv):
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
exec tax.python_compute_inv in localdict
amount = localdict['result']
elif tax.type=='balance':
data['amount'] = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)
data['balance'] = cur_price_unit
if tax.include_base_amount:
cur_price_unit -= amount
@ -1435,8 +1479,13 @@ class account_tax(osv.osv):
one tax for each tax id in IDS and their childs
"""
res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None)
total = 0.0
for r in res:
r['amount'] *= quantity
if r.get('balance',False):
r['amount'] = round(r['balance'] * quantity, 2) - total
else:
r['amount'] = round(r['amount'] * quantity, 2)
total += r['amount']
return res
account_tax()

View File

@ -3,13 +3,17 @@
<data>
<record id="action_account_period_tree" model="ir.actions.act_window">
<field name="name">Close Period</field>
<field name="name">Close a Period</field>
<field name="res_model">account.period</field>
<field name="view_type">form</field>
<field name="domain">[('state','=','draft')]</field>
<field name="view_id" ref="view_account_period_tree"/>
</record>
<menuitem action="action_account_period_tree" id="menu_action_account_period_close_tree" parent="account.menu_account_end_year_treatments"/>
<menuitem
action="action_account_period_tree"
id="menu_action_account_period_close_tree"
parent="account.menu_account_end_year_treatments"
sequence="0"/>
</data>
</openerp>

View File

@ -367,8 +367,7 @@ class account_move_line(osv.osv):
'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'),
#TODO: remove this
'amount_taxed':fields.float("Taxed Amount",digits=(16,2)),
'parent_move_lines':fields.many2many('account.move.line', 'account_move_line_rel', 'child_id', 'parent_id', 'Parent'),
'reconcile_implicit':fields.boolean('Implicit Reconciliation')
}
def _get_date(self, cr, uid, context):
@ -537,11 +536,7 @@ class account_move_line(osv.osv):
currency = 0.0
account_id = False
partner_id = False
implicit_lines = []
for line in unrec_lines:
if line.parent_move_lines:
for i in line.parent_move_lines:
implicit_lines.append(i.id)
if line.state <> 'valid':
raise osv.except_osv(_('Error'),
_('Entry "%s" is not valid !') % line.name)
@ -563,7 +558,7 @@ class account_move_line(osv.osv):
GROUP BY account_id,reconcile_id')
r = cr.fetchall()
#TODO: move this check to a constraint in the account_move_reconcile object
if len(r) != 1:
if (len(r) != 1) and context.get('same_account', True):
raise osv.except_osv(_('Error'), _('Entries are not of the same account or already reconciled ! '))
if not unrec_lines:
raise osv.except_osv(_('Error'), _('Entry is already reconciled'))
@ -640,10 +635,6 @@ class account_move_line(osv.osv):
'line_partial_ids': map(lambda x: (3,x,False), ids)
})
wf_service = netsvc.LocalService("workflow")
if implicit_lines:
self.write(cr, uid, implicit_lines, {'reconcile_implicit':True,'reconcile_id':r_id})
for id in implicit_lines:
wf_service.trg_trigger(uid, 'account.move.line', id, cr)
# the id of the move.reconcile is written in the move.line (self) by the create method above
# because of the way the line_id are defined: (4, x, False)
for id in ids:

View File

@ -16,7 +16,6 @@
<field name="code" select="1"/>
<field name="date_start"/>
<field name="date_stop"/>
<field name="start_journal_period_id"/>
<field name="end_journal_period_id"/>
<separator colspan="4" string="Periods"/>
<field colspan="4" name="period_ids" nolabel="1" widget="one2many_list">
@ -162,13 +161,14 @@
<field name="type">tree</field>
<field name="field_parent">child_id</field>
<field name="arch" type="xml">
<tree string="Chart of accounts" toolbar="1">
<tree string="Chart of accounts" toolbar="1" colors="blue:type=='view'">
<field name="code"/>
<field name="name"/>
<field name="debit"/>
<field name="credit"/>
<field name="balance"/>
<field name="company_currency_id"/>
<field name="type" invisible="1"/>
</tree>
</field>
</record>
@ -263,8 +263,8 @@
<page string="General Information">
<field name="view_id"/>
<field name="sequence_id"/>
<field name="default_debit_account_id" attrs="{'required':[('type','=','cash')]}"/>
<field name="default_credit_account_id" attrs="{'required':[('type','=','cash')]}"/>
<field name="default_debit_account_id" attrs="{'required':[('type','=','cash')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="default_credit_account_id" attrs="{'required':[('type','=','cash')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="currency"/>
<field name="user_id" groups="base.group_extended"/>
<newline/>
@ -272,6 +272,7 @@
<field name="group_invoice_lines"/>
<field name="update_posted"/>
<field name="entry_posted"/>
<field name="fy_seq_id" colspan="4" widget="one2many_list" >
<tree string="Invoice Sequences">
<field name="fiscalyear_id"/>
@ -282,7 +283,6 @@
<field name="sequence_id"/>
</form>
</field>
<field name="entry_posted"/>
</page>
<page string="Entry Controls">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
@ -423,7 +423,7 @@
<field colspan="4" domain="[('partner_id','=',context.get('partner_id', False)),('state','=','valid'),('account_id','=',context.get('account_id', False)),('reconcile_id', '=', False)]" name="line_ids" nolabel="1" view_mode="tree"/>
<field colspan="4" name="line_new_ids" nolabel="1">
<tree editable="bottom" string="Write-Off">
<field name="account_id"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="amount"/>
<field name="name"/>
</tree>
@ -670,14 +670,15 @@
<field name="type">tree</field>
<field eval="4" name="priority"/>
<field name="arch" type="xml">
<tree string="Account Entry Line">
<tree string="Account Entry Line" editable="top" on_write="_on_create_write">
<field name="date"/>
<field name="period_id"/>
<field name="move_id"/>
<field name="ref"/>
<field name="invoice"/>
<field name="name"/>
<field name="partner_id"/>
<field name="account_id"/>
<field name="account_id" domain="[('journal_id','=',journal_id)]"/>
<field name="journal_id"/>
<field name="debit" sum="Total debit"/>
<field name="credit" sum="Total credit"/>
@ -706,7 +707,7 @@
<field name="date" select="1"/>
<field name="ref" select="2"/>
<field name="invoice" select="2"/>
<field name="account_id" select="1"/>
<field name="account_id" select="1" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="partner_id" select="1" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date)"/>
<field name="debit" select="2"/>
@ -739,10 +740,6 @@
<page string="Analytic Lines">
<field colspan="4" name="analytic_lines" nolabel="1"/>
</page>
<page string="Linked Lines" groups="base.group_extended">
<field colspan="4" name="reconcile_implicit"/>
<field colspan="4" name="parent_move_lines" nolabel="0"/>
</page>
</notebook>
</form>
</field>
@ -763,7 +760,7 @@
<field name="date" select="2"/>
<field name="journal_id" readonly="False" select="1"/>
<field name="period_id" readonly="False" select="2"/>
<field name="account_id" select="1"/>
<field name="account_id" select="1" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="partner_id" select="2" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date)"/>
<newline/>
<field name="debit" select="2"/>
@ -782,7 +779,6 @@
<newline/>
<field name="account_tax_id" domain="[('parent_id','=',False)]"/>
<field name="analytic_account_id"/>
<field colspan="4" name="reconcile_implicit"/>
<separator colspan="4" string="State"/>
<newline/>
<field name="reconcile_id"/>
@ -851,7 +847,7 @@
<form string="Account Entry Line">
<separator colspan="4" string="General Information"/>
<field name="name" select="1"/>
<field name="account_id"/>
<field name="account_id" domain="[('journal_id','=',parent.journal_id)]"/>
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,parent.date,parent.journal_id)"/>
<field name="debit" select="1"/>
@ -876,7 +872,7 @@
<field name="invoice"/>
<field name="name"/>
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,parent.date,parent.journal_id)"/>
<field name="account_id"/>
<field name="account_id" domain="[('journal_id','=',parent.journal_id)]"/>
<field name="date_maturity"/>
<field name="debit" sum="Total Debit"/>
<field name="credit" sum="Total Credit"/>
@ -926,7 +922,7 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_move_line_tree"/>
</record>
<record id="action_move_line_search_view1" model="ir.actions.act_window.view">
@ -935,6 +931,11 @@
<field name="view_id" ref="view_move_line_tree"/>
<field name="act_window_id" ref="action_move_line_search"/>
</record>
<record id="action_move_line_search_view2" model="ir.actions.act_window.view">
<field eval="11" name="sequence"/>
<field name="view_mode">form</field>
<field name="act_window_id" ref="action_move_line_search"/>
</record>
<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="7"/>
@ -1089,7 +1090,7 @@
<field colspan="4" name="name" select="1"/>
<field name="sequence"/>
<field name="ref" select="1"/>
<field name="account_id"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="partner_id"/>
<field name="debit" select="1"/>
<field name="credit" select="1"/>
@ -1152,6 +1153,7 @@
<field name="sequence"/>
<field name="name"/>
<field name="value"/>
<field name="value_amount"/>
<field name="days"/>
<field name="days2"/>
</tree>
@ -1168,7 +1170,7 @@
<field name="name" select="1"/>
<field name="sequence"/>
<field name="value"/>
<field name="value_amount"/>
<field name="value_amount" attrs="{'readonly':[('value','=','balance')]}"/>
<newline/>
<field name="days"/>
<field name="days2"/>

View File

@ -7,13 +7,31 @@
<wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice"/>
<!-- close year, period, journal -->
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Close a Fiscal Year"/>
<menuitem id="menu_finance" name="Financial Management"/><menuitem action="wizard_fiscalyear_close" id="menu_wizard_fy_close" parent="menu_account_end_year_treatments" sequence="11" type="wizard"/>
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Generate Fiscal Year Opening Entries"/>
<wizard id="wizard_open_closed_fiscalyear" menu="False" model="account.fiscalyear" name="account.open_closed_fiscalyear" string="Open a Closed Fiscal Year"/>
<menuitem action="wizard_open_closed_fiscalyear" id="menu_wizard_open_closed_fy" parent="account.menu_account_end_year_treatments" sequence="12" type="wizard"/>
<menuitem
action="wizard_fiscalyear_close"
id="menu_wizard_fy_close"
parent="menu_account_end_year_treatments"
type="wizard"
sequence="1"/>
<wizard id="wizard_period_close" model="account.period" name="account.period.close" string="Close Period"/>
<wizard id="wizard_fiscalyear_close_state" menu="False" model="account.fiscalyear" name="account.fiscalyear.close.state" string="Close a Fiscal Year"/>
<menuitem action="wizard_fiscalyear_close_state" id="menu_wizard_fy_close_state" parent="menu_account_end_year_treatments" type="wizard"/>
<wizard
id="wizard_open_closed_fiscalyear"
menu="False"
model="account.fiscalyear"
name="account.open_closed_fiscalyear"
string="Cancel Opening Entries"/>
<menuitem
action="wizard_open_closed_fiscalyear"
id="menu_wizard_open_closed_fy"
sequence="2"
parent="account.menu_account_end_year_treatments" type="wizard"/>
<wizard id="wizard_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"/>

View File

@ -107,8 +107,8 @@ class account_invoice(osv.osv):
paid_amt = 0.0
to_pay = inv.amount_total
for lines in inv.move_lines:
paid_amt = paid_amt + lines.credit + lines.debit
res[inv.id] = to_pay - paid_amt
paid_amt = paid_amt - lines.credit + lines.debit
res[inv.id] = to_pay - abs(paid_amt)
return res
def _get_lines(self, cr, uid, ids, name, arg, context=None):

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -41,6 +41,7 @@ import wizard_partner_balance_report
import wizard_period_close
import wizard_fiscalyear_close
import wizard_fiscalyear_close_state
import wizard_open_closed_fiscalyear
import wizard_vat

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -26,27 +26,28 @@ import pooler
from tools.translate import _
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Fiscal Year">
<form string="Close Fiscal Year with new entries">
<field name="fy_id"/>
<field name="fy2_id"/>
<field name="report_new"/>
<field name="report_name" colspan="3"/>
<field name="journal_id"/>
<field name="period_id"/>
<field name="report_name" colspan="4"/>
<separator string="Are you sure ?" colspan="4"/>
<separator string="Are you sure you want to create entries?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
'journal_id': {'string':'Opening Entries Journal', 'type':'many2one', 'relation': 'account.journal','required':True},
'period_id': {'string':'Opening Entries Period', 'type':'many2one', 'relation': 'account.period','required':True, 'domain':"[('fiscalyear_id','=',fy2_id)]"},
'fy2_id': {'string':'New Fiscal Year', 'type':'many2one', 'relation': 'account.fiscalyear', 'domain':[('state','=','draft')], 'required':True},
'report_new': {'string':'Create new entries', 'type':'boolean', 'required':True, 'default': lambda *a:True},
'report_name': {'string':'Name of new entries', 'type':'char', 'size': 64, 'required':True},
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_load(self, cr, uid, data, context):
data['form']['report_new'] = True
data['form']['report_name'] = 'End of Fiscal Year Entry'
data['form']['report_name'] = _('End of Fiscal Year Entry')
return data['form']
def _data_save(self, cr, uid, data, context):
@ -56,122 +57,126 @@ def _data_save(self, cr, uid, data, context):
fy_id = data['form']['fy_id']
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'])
start_jp = new_fyear.start_journal_period_id
if data['form']['report_new']:
periods_fy2 = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids
if not periods_fy2:
raise wizard.except_wizard(_('UserError'),
_('There are no periods defined on New Fiscal Year.'))
period=periods_fy2[0]
if not start_jp:
raise wizard.except_wizard(_('UserError'),
_('The new fiscal year should have a journal for new entries define on it'))
periods_fy2 = new_fyear.period_ids
if not periods_fy2:
raise wizard.except_wizard(_('UserError'),
_('There are no periods defined on New Fiscal Year.'))
period=periods_fy2[0]
new_journal = start_jp.journal_id
new_journal = data['form']['journal_id']
new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context)
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
raise wizard.except_wizard(_('UserError'),
_('The journal must have default credit and debit account'))
if not new_journal.centralisation:
raise wizard.except_wizard(_('UserError'),
_('The journal must have centralised counterpart'))
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
raise wizard.except_wizard(_('UserError'),
_('The journal must have default credit and debit account'))
if not new_journal.centralisation:
raise wizard.except_wizard(_('UserError'),
_('The journal must have centralised counterpart'))
query_line = pool.get('account.move.line')._query_get(cr, uid,
obj='account_move_line', context={'fiscalyear': fy_id})
cr.execute('select id from account_account WHERE active')
ids = map(lambda x: x[0], cr.fetchall())
for account in pool.get('account.account').browse(cr, uid, ids,
context={'fiscalyear': fy_id}):
accnt_type_data = account.user_type
if not accnt_type_data:
continue
if accnt_type_data.close_method=='none' or account.type == 'view':
continue
if accnt_type_data.close_method=='balance':
if abs(account.balance)>0.0001:
pool.get('account.move.line').create(cr, uid, {
'debit': account.balance>0 and account.balance,
'credit': account.balance<0 and -account.balance,
'name': data['form']['report_name'],
move_ids = pool.get('account.move.line').search(cr, uid, [
('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)])
if move_ids:
raise wizard.except_wizard(_('UserError'),
_('The opening journal must not have any entry in the new fiscal year !'))
query_line = pool.get('account.move.line')._query_get(cr, uid,
obj='account_move_line', context={'fiscalyear': fy_id})
cr.execute('select id from account_account WHERE active')
ids = map(lambda x: x[0], cr.fetchall())
for account in pool.get('account.account').browse(cr, uid, ids,
context={'fiscalyear': fy_id}):
accnt_type_data = account.user_type
if not accnt_type_data:
continue
if accnt_type_data.close_method=='none' or account.type == 'view':
continue
if accnt_type_data.close_method=='balance':
if abs(account.balance)>0.0001:
pool.get('account.move.line').create(cr, uid, {
'debit': account.balance>0 and account.balance,
'credit': account.balance<0 and -account.balance,
'name': data['form']['report_name'],
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'account_id': account.id
}, {'journal_id': new_journal.id, 'period_id':period.id})
if accnt_type_data.close_method == 'unreconciled':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'AND reconcile_id is NULL ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'account_id': account.id
}, {'journal_id': new_journal.id, 'period_id':period.id})
if accnt_type_data.close_method == 'unreconciled':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'AND reconcile_id is NULL ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move, {
'journal_id': new_journal.id,
'period_id': period.id,
})
pool.get('account.move.line').create(cr, uid, move, {
'journal_id': new_journal.id,
'period_id': period.id,
})
offset += limit
if accnt_type_data.close_method=='detail':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
offset += limit
if accnt_type_data.close_method=='detail':
offset = 0
limit = 100
while True:
cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
parent_id = move['id']
move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
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, end_journal_period_id = %s ' \
'WHERE id = %s', ('done', start_jp and start_jp.id or None, fy_id))
ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id),
('period_id.fiscalyear_id','=',new_fyear.id)])
context['same_account'] = False
pool.get('account.move.line').reconcile(cr, uid, ids, context=context)
new_period = data['form']['period_id']
ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)])
if ids:
cr.execute('UPDATE account_fiscalyear ' \
'SET end_journal_period_id = %s ' \
'WHERE id = %s', (ids[0], new_fyear.id))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [_data_load],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Fiscal Year')]}
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Create entries')]}
},
'close': {
'actions': [_data_save],

View File

@ -0,0 +1,72 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <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'),('close','Close states')]}
},
'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:

View File

@ -27,7 +27,7 @@ from tools.translate import _
form = """<?xml version="1.0"?>
<form string="Choose Fiscal Year">
<field name="fyear_id" domain="[('state','=','done')]"/>
<field name="fyear_id" domain="[('state','=','draft')]"/>
</form>
"""
@ -41,19 +41,18 @@ def _remove_entries(self, cr, uid, data, context):
if not data_fyear.end_journal_period_id:
raise wizard.except_wizard(_('Error'), _('No journal for ending writings have been defined for the fiscal year'))
period_journal = data_fyear.end_journal_period_id
if not period_journal.journal_id.centralisation:
raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart'))
ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
pool.get('account.move').unlink(cr,uid,ids_move)
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
('draft',data_fyear))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('draft',data_fyear))
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s, end_journal_period_id = null '\
'WHERE id = %s', ('draft',data_fyear))
if ids_move:
cr.execute('delete from account_move where id in ('+','.join(map(str,ids_move))+')')
#cr.execute('UPDATE account_journal_period ' \
# 'SET state = %s ' \
# 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
# ('draft',data_fyear))
#cr.execute('UPDATE account_period SET state = %s ' \
# 'WHERE fiscalyear_id = %s', ('draft',data_fyear))
#cr.execute('UPDATE account_fiscalyear ' \
# 'SET state = %s, end_journal_period_id = null '\
# 'WHERE id = %s', ('draft',data_fyear))
return {}
class open_closed_fiscal(wizard.interface):

View File

@ -116,24 +116,6 @@
<para style="P3">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ o['array_table'] and repeatIn(getarray(data['form'],o,array_header=data['form']['select_base']),'array',td=len(data['form']['base_selection'][0][2]),data=data['form']['select_base']) or removeParentNode('section') ]]</para>
<blockTable colWidths="0.0" style="Table5">
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
</blockTable>
</section>
<para style="P3">
<font color="white"> </font>
</para>
<blockTable colWidths="14.0,500.0,14.0" repeatRows="1" style="Table6">
<tr>
<td>
@ -166,8 +148,24 @@
<para style="P3">
<font color="white"> </font>
</para>
<hr color="black" thickness="1.5"/>
</section>
<section>
<para style="P1">[[ repeatIn(lines(data['form']),'o')]]</para>
<para style="P13">[[ o['array_table'] and repeatIn(getarray(data['form'],o,array_header=data['form']['select_base']),'array',td=len(data['form']['base_selection'][0][2]),data=data['form']['select_base']) or removeParentNode('section') ]]</para>
<blockTable colWidths="0.0" style="Table5">
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
<tr>
<td>
<para style="P9"> </para>
</td>
</tr>
</blockTable>
</section>
<hr color="black" thickness="1.5"/>
</story>
</document>

View File

@ -118,7 +118,7 @@ def _set_filter_value(self, cr, uid, data, context):
value_field = set_value_fields.get('value')
field_type = value_field.get('type',False)
field_data = pooler.get_pool(cr.dbname).get('ir.model.fields').read(cr,uid,[form_data.get('field_id')],fields=['ttype','relation','model_id','name','field_description'])[0]
model_name = field_data['model_id'][1]
model_name = pooler.get_pool(cr.dbname).get('ir.model').browse(cr, uid, field_data['model_id'][0]).model
model_pool = pooler.get_pool(cr.dbname).get(model_name)
table_name = model_pool._table
model_name = model_pool._description
@ -145,7 +145,7 @@ def _set_filter_value(self, cr, uid, data, context):
def _set_form_value(self, cr, uid, data, context):
field_id = data['form']['field_id']
field_data = pooler.get_pool(cr.dbname).get('ir.model.fields').read(cr,uid,[field_id])[0]
fields_dict = pooler.get_pool(cr.dbname).get(field_data.get('model_id')[1]).fields_get(cr,uid,fields=[field_data.get('name')])
fields_dict = pooler.get_pool(cr.dbname).get(field_data.get('model')).fields_get(cr,uid,fields=[field_data.get('name')])
value_field = set_value_fields.get('value')
# print "fields_dict :",fields_dict.get(field_data.get('name'))
# set_value_fields['value']= fields_dict.get(field_data.get('name'))

View File

@ -8,11 +8,11 @@
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<field name="property_account_position" position="after">
<label string="VAT :" align="1.0"/>
<group colspan="1" col="2">
<label string="VAT :" align="1.0"/>
<field name="vat" nolabel="1" on_change="vat_change(vat)" select="2"/>
<field name="vat_subjected" nolabel="1"/>
</group>
<field name="vat" nolabel="1" on_change="vat_change(vat)" select="2"/>
</field>
</field>
</record>

View File

@ -118,7 +118,7 @@ class hr_employee(osv.osv):
'user_id' : fields.many2one('res.users', 'Related User'),
'country_id' : fields.many2one('res.country', 'Nationality'),
'birthday' : fields.date("Started on"),
'birthday' : fields.date("Birthday"),
'ssnid': fields.char('SSN No', size=32),
'sinid': fields.char('SIN No', size=32),
'otherid': fields.char('Other ID', size=32),

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -85,49 +85,53 @@ class wizard_vat(wizard.interface):
period="to_date('" + str(obj_year.date_start) + "','yyyy-mm-dd') and to_date('" + str(obj_year.date_stop) +"','yyyy-mm-dd')"
street=zip_city=country=''
if not obj_cmpny.partner_id.address:
street=zip_city=country=''
for ads in obj_cmpny.partner_id.address:
if ads.type=='default':
if ads.zip_id:
zip_city=pooler.get_pool(cr.dbname).get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1]
if ads.street:
street=ads.street
if ads.street2:
street +=ads.street2
if ads.country_id:
country=ads.country_id.code
addr = pooler.get_pool(cr.dbname).get('res.partner').address_get(cr, uid, [obj_cmpny.partner_id.id], ['invoice'])
if addr.get('invoice',False):
ads=pooler.get_pool(cr.dbname).get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
zip_city = pooler.get_pool(cr.dbname).get('res.partner.address').get_city(cr,uid,ads.id)
if not zip_city:
zip_city = ''
if ads.street:
street=ads.street
if ads.street2:
street +=ads.street2
if ads.country_id:
country=ads.country_id.code
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="'+ data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
if data['form']['test_xml']:
data_file += 'Test="0"'
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>'+str(obj_cmpny.name)+'</Name>\n\t\t<Street>'+ str(street) +'</Street>\n\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
data_file +='\n\t\t<Country>'+ str(country) +'</Country>\n\t</CompanyInfo>\n</AgentRepr>'
data_comp ='\n<CompanyInfo>\n\t<VATNum>'+str(company_vat)+'</VATNum>\n\t<Name>'+str(obj_cmpny.name)+'</Name>\n\t<Street>'+ str(street) +'</Street>\n\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t<Country>'+ str(country) +'</Country>\n</CompanyInfo>'
data_period ='\n<Period>'+ str(obj_year.name[-4:]) +'</Period>'
error_message=[]
for p_id in p_id_list:
record=[] # this holds record per partner
obj_partner=pooler.get_pool(cr.dbname).get('res.partner').browse(cr,uid,p_id)
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 ('"'produit'"','"'tax'"') and l.partner_id=%%s and l.date between %s group by a.type' % (period,), (p_id,))
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 ('"'produit'"','"'tax'"') and l.partner_id=%%s and l.date between %s group by b.code' % (period,), (p_id,))
line_info=cr.fetchall()
if not line_info:
continue
record.append(obj_partner.vat)
for ads in obj_partner.address:
if ads.type=='default':
if ads.country_id:
record.append(ads.country_id.code)
else:
raise wizard.except_wizard('Data Insufficient!', 'The Partner "'+obj_partner.name + '"'' has no country associated with its default type address!')
addr = pooler.get_pool(cr.dbname).get('res.partner').address_get(cr, uid, [obj_partner.id], ['invoice'])
if addr.get('invoice',False):
ads=pooler.get_pool(cr.dbname).get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
if ads.country_id:
record.append(ads.country_id.code)
else:
raise wizard.except_wizard('Data Insufficient!', 'The Partner "'+obj_partner.name + '"'' has no default type address!')
error_message.append('Data Insufficient! : '+ 'The Partner "'+obj_partner.name + '"'' has no country associated with its Invoice address!')
if len(record)<2:
record.append('')
error_message.append('Data Insufficient! : '+ 'The Partner "'+obj_partner.name + '"'' has no Invoice address!')
if len(line_info)==1:
if line_info[0][0]=='produit':
record.append(0.00)
@ -144,6 +148,9 @@ class wizard_vat(wizard.interface):
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']
for line in datas:
if line[3]< data['form']['limit_amount']:
continue

View File

@ -258,15 +258,17 @@ class mrp_bom(osv.osv):
factor = bom.product_rounding
result = []
result2 = []
phantom=False
if bom.type=='phantom' and not bom.bom_lines:
newbom = self._bom_find(cr, uid, bom.product_id.id, bom.product_uom.id, properties)
if newbom:
res = self._bom_explode(cr, uid, self.browse(cr, uid, [newbom])[0], factor*bom.product_qty, properties, addthis=True, level=level+10)
result = result + res[0]
result2 = result2 + res[1]
phantom=True
else:
return [],[]
else:
phantom=False
if not phantom:
if addthis and not bom.bom_lines:
result.append(
{

View File

@ -28,7 +28,9 @@
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Projects & Services",
"depends" : ["product", "account", "hr", "process"],
"description": "Project management module that track multi-level projects, tasks, works done on tasks, eso. It is able to render planning, order tasks, eso.",
"description": """Project management module that track multi-level projects, tasks,
works done on tasks, eso. It is able to render planning, order tasks, eso.
""",
"init_xml" : [],
"demo_xml" : ["project_demo.xml"],
"update_xml": [

View File

@ -866,6 +866,10 @@ class sale_order_line(osv.osv):
result = {}
product_obj = product_obj.browse(cr, uid, product, context=context)
if not packaging and product_obj.packaging:
packaging = product_obj.packaging[0].id
result['product_packaging'] = packaging
if packaging:
default_uom = product_obj.uom_id and product_obj.uom_id.id
pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context)

View File

@ -264,7 +264,7 @@
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('state','in',('shipping_except','invoice_except')]</field>
<field name="domain">[('state','in',('shipping_except','invoice_except'))]</field>
</record>
<menuitem action="action_order_tree2" id="menu_action_order_tree2" parent="menu_action_order_tree_all"/>

View File

@ -54,7 +54,7 @@ class stock_location(osv.osv):
_description = "Location"
_parent_name = "location_id"
_parent_store = True
_parent_order = 'name'
_parent_order = 'id'
_order = 'parent_left'
def _complete_name(self, cr, uid, ids, name, args, context):