New modules:
Account simulation You can create as many simulation level as needed You can check journals as simulation journals or real journals You can use and print report Very usefull for IFRS, multiple manner to asset some entries Asset management module Multiple ventilations for an asset Link with the accounting L10N_CH Removed ZIP code by default Account cleaned Use a function for a domain on computed fields and visibility bzr revid: fp@tinyerp.com-e382e83f36b19555b678c670d62fad7a2eef1416
This commit is contained in:
@@ -144,9 +144,9 @@ class account_account(osv.osv):
|
||||
def _credit(self, cr, uid, ids, field_name, arg, context={}):
|
||||
if not 'fiscalyear' in context:
|
||||
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
|
||||
acc_set = ",".join(map(str, ids))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.credit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) AND l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d) GROUP BY a.id" % (acc_set, context['fiscalyear']))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
cr.execute(("SELECT a.id, COALESCE(SUM(l.credit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) AND "+query+" GROUP BY a.id") % (acc_set, ))
|
||||
res2 = cr.fetchall()
|
||||
res = {}
|
||||
for id in ids:
|
||||
@@ -160,7 +160,8 @@ class account_account(osv.osv):
|
||||
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
|
||||
acc_set = ",".join(map(str, ids))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.debit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) and l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d) GROUP BY a.id" % (acc_set, context['fiscalyear']))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
cr.execute(("SELECT a.id, COALESCE(SUM(l.debit*a.sign),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.type!='view' AND a.id IN (%s) and "+query+" GROUP BY a.id") % (acc_set, ))
|
||||
res2 = cr.fetchall()
|
||||
res = {}
|
||||
for id in ids:
|
||||
@@ -175,7 +176,8 @@ class account_account(osv.osv):
|
||||
|
||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||
acc_set = ",".join(map(str, ids2))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM((l.debit-l.credit)),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.id IN (%s) and l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d) GROUP BY a.id" % (acc_set, context['fiscalyear']))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
cr.execute(("SELECT a.id, COALESCE(SUM((l.debit-l.credit)),0) FROM account_account a LEFT JOIN account_move_line l ON (a.id=l.account_id) WHERE a.id IN (%s) and "+query+" GROUP BY a.id") % (acc_set, ))
|
||||
res = {}
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = round(sum,2)
|
||||
@@ -293,7 +295,6 @@ class account_account(osv.osv):
|
||||
return super(account_account, self).copy(cr, uid, id, default, context=context)
|
||||
account_account()
|
||||
|
||||
|
||||
class account_journal_view(osv.osv):
|
||||
_name = "account.journal.view"
|
||||
_description = "Journal View"
|
||||
@@ -326,7 +327,6 @@ class account_journal_column(osv.osv):
|
||||
_order = "sequence"
|
||||
account_journal_column()
|
||||
|
||||
|
||||
class account_journal(osv.osv):
|
||||
_name = "account.journal"
|
||||
_description = "Journal"
|
||||
@@ -462,6 +462,11 @@ class account_period(osv.osv):
|
||||
'state': lambda *a: 'draft',
|
||||
}
|
||||
_order = "date_start"
|
||||
def next(self, cr, uid, period, step, context={}):
|
||||
ids = self.search(cr, uid, [('date_start','>',period.date_start)])
|
||||
if len(ids)>=step:
|
||||
return ids[step-1]
|
||||
return False
|
||||
|
||||
def find(self, cr, uid, dt=None, context={}):
|
||||
if not dt:
|
||||
|
||||
@@ -36,6 +36,11 @@ class account_move_line(osv.osv):
|
||||
_name = "account.move.line"
|
||||
_description = "Entry lines"
|
||||
|
||||
def _query_get(self, cr, uid, obj='l', context={}):
|
||||
if not 'fiscalyear' in context:
|
||||
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
return "l.active AND l.state<>'draft' AND l.period_id in (SELECT id from account_period WHERE fiscalyear_id=%d)" % (context['fiscalyear'] ,)
|
||||
|
||||
def default_get(self, cr, uid, fields, context={}):
|
||||
data = self._default_get(cr, uid, fields, context)
|
||||
for f in data.keys():
|
||||
|
||||
@@ -531,6 +531,8 @@
|
||||
<tree string="Account entry">
|
||||
<field name="ref"/>
|
||||
<field name="name"/>
|
||||
<field name="period_id"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -744,6 +746,7 @@
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="account_id"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="debit"/>
|
||||
<field name="credit"/>
|
||||
<field name="state"/>
|
||||
@@ -763,22 +766,22 @@
|
||||
<separator string="General Information" colspan="4"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="ref" select="1"/>
|
||||
<field name="ref" select="2"/>
|
||||
<newline/>
|
||||
<field name="account_id" select="1"/>
|
||||
<field name="partner_id" select="1"/>
|
||||
|
||||
<field name="debit" select="1"/>
|
||||
<field name="credit" select="1"/>
|
||||
<field name="debit" select="2"/>
|
||||
<field name="credit" select="2"/>
|
||||
|
||||
<separator string="Optional Information" colspan="4"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="amount_currency"/>
|
||||
<field name="quantity" select="1"/>
|
||||
<field name="quantity" select="2"/>
|
||||
<field name="move_id" required="False"/>
|
||||
<newline/>
|
||||
<field name="statement_id" select="1"/>
|
||||
<field name="blocked" select="1"/>
|
||||
<field name="statement_id" select="2"/>
|
||||
<field name="blocked" select="2"/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="date_created"/>
|
||||
|
||||
@@ -786,7 +789,7 @@
|
||||
<field name="journal_id"/>
|
||||
<field name="period_id"/>
|
||||
<field name="reconcile_id"/>
|
||||
<field name="active" select="1"/>
|
||||
<field name="active" select="2"/>
|
||||
<field name="state"/>
|
||||
</page><page string="Analytic Lines">
|
||||
<field name="analytic_lines" colspan="4" nolabel="1"/>
|
||||
@@ -808,29 +811,29 @@
|
||||
<page string="Information">
|
||||
<separator string="General Information" colspan="4"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="date" select="2"/>
|
||||
<field name="journal_id" select="1" readonly="False"/>
|
||||
<field name="period_id" select="1" readonly="False"/>
|
||||
<field name="period_id" select="2" readonly="False"/>
|
||||
<field name="account_id" select="1"/>
|
||||
<field name="partner_id" select="1"/>
|
||||
<field name="partner_id" select="2"/>
|
||||
<newline/>
|
||||
<field name="debit" select="1"/>
|
||||
<field name="credit" select="1"/>
|
||||
<field name="debit" select="2"/>
|
||||
<field name="credit" select="2"/>
|
||||
|
||||
<separator string="Optional Information" colspan="4"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="amount_currency"/>
|
||||
<field name="quantity" select="1"/>
|
||||
<field name="quantity" select="3"/>
|
||||
<field name="move_id" required="False"/>
|
||||
<newline/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="date_created"/>
|
||||
<field name="date_created"/>
|
||||
<field name="blocked" select="1"/>
|
||||
<field name="blocked" select="3"/>
|
||||
|
||||
|
||||
<separator string="State" colspan="4"/>
|
||||
<field name="state" select="1"/>
|
||||
<field name="state" select="2"/>
|
||||
<field name="reconcile_id"/>
|
||||
</page><page string="Analytic Lines">
|
||||
<field name="analytic_lines" colspan="4" nolabel="1"/>
|
||||
@@ -870,7 +873,7 @@
|
||||
<separator string="General Information" colspan="4"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="ref" select="1"/>
|
||||
<field name="period_id" select="1"/>
|
||||
<field name="period_id" select="2"/>
|
||||
<field name="journal_id" select="1"/>
|
||||
|
||||
<separator string="Entry Lines" colspan="4"/>
|
||||
|
||||
+31
-25
@@ -394,20 +394,7 @@ class account_invoice(osv.osv):
|
||||
|
||||
date = inv.date_invoice
|
||||
part = inv.partner_id.id
|
||||
line = map(lambda x:(0,0,{
|
||||
'date':date,
|
||||
'date_maturity': x.get('date_maturity', False),
|
||||
'partner_id':part,
|
||||
'name':x['name'],
|
||||
'debit':x['price']>0 and x['price'],
|
||||
'credit':x['price']<0 and -x['price'],
|
||||
'account_id':x['account_id'],
|
||||
'analytic_lines':x.get('analytic_lines', []),
|
||||
'amount_currency':x.get('amount_currency', False),
|
||||
'currency_id':x.get('currency_id', False),
|
||||
'tax_code_id': x.get('tax_code_id', False),
|
||||
'tax_amount': x.get('tax_amount', False),
|
||||
'ref':x.get('ref',False) }) ,iml)
|
||||
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})) ,iml)
|
||||
|
||||
journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
|
||||
@@ -427,6 +414,23 @@ class account_invoice(osv.osv):
|
||||
self._log_event(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def line_get_convert(self, cr, uid, x, part, date, context={}):
|
||||
return {
|
||||
'date':date,
|
||||
'date_maturity': x.get('date_maturity', False),
|
||||
'partner_id':part,
|
||||
'name':x['name'],
|
||||
'debit':x['price']>0 and x['price'],
|
||||
'credit':x['price']<0 and -x['price'],
|
||||
'account_id':x['account_id'],
|
||||
'analytic_lines':x.get('analytic_lines', []),
|
||||
'amount_currency':x.get('amount_currency', False),
|
||||
'currency_id':x.get('currency_id', False),
|
||||
'tax_code_id': x.get('tax_code_id', False),
|
||||
'tax_amount': x.get('tax_amount', False),
|
||||
'ref':x.get('ref',False)
|
||||
}
|
||||
|
||||
def action_number(self, cr, uid, ids, *args):
|
||||
cr.execute('SELECT id, type, number, move_id FROM account_invoice WHERE id IN ('+','.join(map(str,ids))+')')
|
||||
for (id, invtype, number, move_id) in cr.fetchall():
|
||||
@@ -705,17 +709,7 @@ class account_invoice_line(osv.osv):
|
||||
cur = inv.currency_id
|
||||
|
||||
for line in inv.invoice_line:
|
||||
res.append( {
|
||||
'type':'src',
|
||||
'name':line.name,
|
||||
'price_unit':line.price_unit,
|
||||
'quantity':line.quantity,
|
||||
'price':line.price_subtotal,
|
||||
'account_id':line.account_id.id,
|
||||
'product_id':line.product_id.id,
|
||||
'uos_id':line.uos_id.id,
|
||||
'account_analytic_id':line.account_analytic_id.id,
|
||||
})
|
||||
res.append( self.move_line_get_item(cr, uid, line, context))
|
||||
for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, (line.price_unit *(1.0-(line['discount'] or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id):
|
||||
if inv.type in ('out_invoice', 'in_invoice'):
|
||||
res[-1]['tax_code_id'] = tax['base_code_id']
|
||||
@@ -725,6 +719,18 @@ class account_invoice_line(osv.osv):
|
||||
res[-1]['tax_amount'] = tax['price_unit'] * line['quantity'] * tax['ref_base_sign']
|
||||
return res
|
||||
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
return {
|
||||
'type':'src',
|
||||
'name':line.name,
|
||||
'price_unit':line.price_unit,
|
||||
'quantity':line.quantity,
|
||||
'price':line.price_subtotal,
|
||||
'account_id':line.account_id.id,
|
||||
'product_id':line.product_id.id,
|
||||
'uos_id':line.uos_id.id,
|
||||
'account_analytic_id':line.account_analytic_id.id,
|
||||
}
|
||||
#
|
||||
# Set the tax field according to the account and the partner
|
||||
#
|
||||
|
||||
@@ -41,7 +41,8 @@ class res_partner(osv.osv):
|
||||
for partner in self.browse(cr, uid, ids, context):
|
||||
id = partner.id
|
||||
acc = partner.property_account_receivable[0]
|
||||
cr.execute("select sum(debit-credit) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (acc, id))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
cr.execute(("select sum(debit-credit) from account_move_line l where account_id=%d and partner_id=%d and reconcile_id is null and "+query), (acc, id))
|
||||
res[id]=cr.fetchone()[0] or 0.0
|
||||
except:
|
||||
for id in ids:
|
||||
@@ -54,7 +55,8 @@ class res_partner(osv.osv):
|
||||
for partner in self.browse(cr, uid, ids, context):
|
||||
id = partner.id
|
||||
acc = partner.property_account_payable[0]
|
||||
cr.execute("select sum(debit-credit) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (acc, id))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
cr.execute(("select sum(debit-credit) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and "+query), (acc, id))
|
||||
res[id]=cr.fetchone()[0] or 0.0
|
||||
except:
|
||||
for id in ids:
|
||||
@@ -65,7 +67,8 @@ class res_partner(osv.osv):
|
||||
if not len(args):
|
||||
return []
|
||||
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
|
||||
cr.execute('select partner_id from account_move_line where account_id in (select id from account_account where type=%s) and reconcile_id is null and state<>\'draft\' and partner_id is not null group by partner_id having '+where, ('receivable',) )
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
||||
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) )
|
||||
res = cr.fetchall()
|
||||
if not len(res):
|
||||
return [('id','=','0')]
|
||||
@@ -74,8 +77,9 @@ class res_partner(osv.osv):
|
||||
def _debit_search(self, cr, uid, obj, name, args):
|
||||
if not len(args):
|
||||
return []
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
||||
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
|
||||
cr.execute('select partner_id from account_move_line where account_id in (select id from account_account where type=%s) and reconcile_id is null and state<>\'draft\'and partner_id is not null group by partner_id having '+where, ('payable',) )
|
||||
cr.execute(('select partner_id from account_move_line where account_id in (select id from account_account where type=%s) and reconcile_id is null and '+query+' partner_id is not null group by partner_id having '+where), ('payable',) )
|
||||
res = cr.fetchall()
|
||||
if not len(res):
|
||||
return [('id','=','0')]
|
||||
|
||||
@@ -138,7 +138,8 @@ class account_transfer(osv.osv):
|
||||
value['account_dest_id'] = False
|
||||
|
||||
# compute the amount this partner owe us (the sum of all move lines which have not been matched)
|
||||
cr.execute("SELECT COALESCE(SUM(debit-credit),0) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (a, partner_id))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
||||
cr.execute(("SELECT COALESCE(SUM(debit-credit),0) from account_move_line l where account_id=%d and partner_id=%d and reconcile_id is null and "+query), (a, partner_id))
|
||||
value['amount'] = cr.fetchone()[0]
|
||||
|
||||
d = self._onchange_account_domain(cr,uid,ids,type, value['account_src_id'], value['account_dest_id'])
|
||||
@@ -150,7 +151,8 @@ class account_transfer(osv.osv):
|
||||
value['account_dest_id'] = a
|
||||
|
||||
# compute the amount we owe this partner (the sum of all move lines which have not been matched)
|
||||
cr.execute("SELECT COALESCE(SUM(debit-credit),0) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (a,partner_id))
|
||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
||||
cr.execute(("SELECT COALESCE(SUM(debit-credit),0) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and "+query), (a,partner_id))
|
||||
value['amount'] = -cr.fetchone()[0]
|
||||
|
||||
# get the new domain
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import osv
|
||||
import time
|
||||
import pooler
|
||||
|
||||
pay_form = '''<?xml version="1.0"?>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_asset
|
||||
import account_asset_invoice
|
||||
import wizard
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name" : "Asset management",
|
||||
"version" : "1.0",
|
||||
"depends" : ["account", "account_simulation"],
|
||||
"author" : "Tiny",
|
||||
"description": """Financial and accounting asset management.""",
|
||||
"website" : "http://tinyerp.com/module_account.html",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"init_xml" : [
|
||||
],
|
||||
"demo_xml" : [
|
||||
],
|
||||
"update_xml" : [
|
||||
"account_asset_wizard.xml",
|
||||
"account_asset_view.xml",
|
||||
"account_asset_invoice_view.xml"
|
||||
],
|
||||
# "translations" : {
|
||||
# "fr": "i18n/french_fr.csv"
|
||||
# },
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: product.py 1310 2005-09-08 20:40:15Z pinky $
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
class account_asset_category(osv.osv):
|
||||
_name = 'account.asset.category'
|
||||
_description = 'Asset category'
|
||||
_columns = {
|
||||
'name': fields.char('Asset category', size=64, required=True, select=1),
|
||||
'code': fields.char('Asset code', size=16, select=1),
|
||||
'note': fields.text('Note'),
|
||||
}
|
||||
account_asset_category()
|
||||
|
||||
class account_asset_asset(osv.osv):
|
||||
_name = 'account.asset.asset'
|
||||
_description = 'Asset'
|
||||
|
||||
# def _balance(self, cr, uid, ids, field_name, arg, context={}):
|
||||
# acc_set = ",".join(map(str, ids))
|
||||
# query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
# cr.execute(("SELECT a.id, COALESCE(SUM((l.debit-l.credit)),0) FROM account_asset_asset a LEFT JOIN account_move_line l ON (a.id=l.asset_account_id) WHERE a.id IN (%s) and "+query+" GROUP BY a.id") % (acc_set,))
|
||||
# res = {}
|
||||
# for account_id, sum in cr.fetchall():
|
||||
# res[account_id] = round(sum,2)
|
||||
# for id in ids:
|
||||
# res[id] = round(res.get(id,0.0), 2)
|
||||
# return res
|
||||
def _get_period(self, cr, uid, context={}):
|
||||
print context
|
||||
periods = self.pool.get('account.period').find(cr, uid)
|
||||
if periods:
|
||||
return periods[0]
|
||||
else:
|
||||
return False
|
||||
|
||||
def validate(self, cr, uid, ids, context={}):
|
||||
for asset in self.browse(cr, uid, ids, context):
|
||||
for prop in asset.property_ids:
|
||||
if prop.state=='draft':
|
||||
self.pool.get('account.asset.property').write(cr, uid, [prop.id], {'state':'open'}, context)
|
||||
return self.write(cr, uid, ids, {
|
||||
'state':'normal'
|
||||
}, context)
|
||||
|
||||
def _amount_total(self, cr, uid, ids, name, args, context={}):
|
||||
id_set=",".join(map(str,ids))
|
||||
cr.execute("""SELECT l.asset_id,abs(SUM(l.debit-l.credit)) AS amount FROM
|
||||
account_move_line l
|
||||
WHERE l.asset_id IN ("""+id_set+") GROUP BY l.asset_id ")
|
||||
res=dict(cr.fetchall())
|
||||
for id in ids:
|
||||
res.setdefault(id, 0.0)
|
||||
return res
|
||||
_columns = {
|
||||
'name': fields.char('Asset', size=64, required=True, select=1),
|
||||
'code': fields.char('Asset code', size=16, select=1),
|
||||
'note': fields.text('Note'),
|
||||
'category_id': fields.many2one('account.asset.category', 'Asset category', change_default=True),
|
||||
'localisation': fields.char('Localisation', size=32, select=2),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'parent_id': fields.many2one('account.asset.asset', 'Parent asset'),
|
||||
'child_ids': fields.one2many('account.asset.asset', 'parent_id', 'Childs asset'),
|
||||
'date': fields.date('Date', required=True),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'state': fields.selection([('view','View'),('draft','Draft'),('normal','Normal'),('close','Close')], 'Global state', required=True),
|
||||
'active': fields.boolean('Active', select=2),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'entry_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'property_ids': fields.one2many('account.asset.property', 'asset_id', 'Asset method name', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'value_total': fields.function(_amount_total, method=True, digits=(16,2),string='Total value'),
|
||||
}
|
||||
_defaults = {
|
||||
'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),
|
||||
'date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d'),
|
||||
'active': lambda obj, cr, uid, context: True,
|
||||
'state': lambda obj, cr, uid, context: 'draft',
|
||||
'period_id': _get_period,
|
||||
}
|
||||
def _compute_period(self, cr, uid, property, context={}):
|
||||
if len(property.entry_asset_ids or [])>=property.method_delay:
|
||||
return False
|
||||
if len(property.entry_asset_ids):
|
||||
cp = property.entry_asset_ids[-1].period_id
|
||||
cpid = self.pool.get('account.period').next(cr, uid, cp, property.method_period, context)
|
||||
current_period = self.pool.get('account.period').browse(cr, uid, cpid, context)
|
||||
|
||||
else:
|
||||
current_period = property.asset_id.period_id
|
||||
return current_period
|
||||
|
||||
def _compute_move(self, cr, uid, property, period, context={}):
|
||||
result = []
|
||||
total = 0.0
|
||||
for move in property.asset_id.entry_ids:
|
||||
total += move.debit-move.credit
|
||||
for move in property.entry_asset_ids:
|
||||
total += move.debit-move.credit
|
||||
periods = len(property.entry_asset_ids) - property.method_delay
|
||||
if property.method == 'linear':
|
||||
amount = total / periods
|
||||
else:
|
||||
amount = total / periods
|
||||
|
||||
move_id = self.pool.get('account.move').create(cr, uid, {
|
||||
'journal_id': property.journal_id.id,
|
||||
'period_id': period.id,
|
||||
'name': property.name or property.asset_id.name,
|
||||
'ref': property.asset_id.code
|
||||
})
|
||||
result = [move_id]
|
||||
id = self.pool.get('account.move.line').create(cr, uid, {
|
||||
'name': property.name or property.asset_id.name,
|
||||
'move_id': move_id,
|
||||
'account_id': property.account_asset_id.id,
|
||||
'debit': amount>0 and amount or 0.0,
|
||||
'credit': amount<0 and -amount or 0.0,
|
||||
'ref': property.asset_id.code,
|
||||
'period_id': period.id,
|
||||
'journal_id': property.journal_id.id,
|
||||
'partner_id': property.asset_id.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
})
|
||||
self.pool.get('account.asset.property').write(cr, uid, [property.id], {
|
||||
'entry_asset_ids': [(4, id, [])]
|
||||
})
|
||||
id = self.pool.get('account.move.line').create(cr, uid, {
|
||||
'name': property.name or property.asset_id.name,
|
||||
'move_id': move_id,
|
||||
'account_id': property.account_actif_id.id,
|
||||
'credit': amount>0 and amount or 0.0,
|
||||
'debit': amount<0 and -amount or 0.0,
|
||||
'ref': property.asset_id.code,
|
||||
'period_id': period.id,
|
||||
'journal_id': property.journal_id.id,
|
||||
'partner_id': property.asset_id.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
})
|
||||
self.pool.get('account.asset.property').write(cr, uid, [property.id], {
|
||||
'entry_actif_ids': [(4, id, False)]
|
||||
})
|
||||
if property.method_delay - len(property.entry_asset_ids)<=1:
|
||||
self.pool.get('account.asset.property')._close(cr, uid, property, context)
|
||||
return result
|
||||
return result
|
||||
|
||||
def _compute_entries(self, cr, uid, asset, period_id, context={}):
|
||||
result = []
|
||||
date_start = self.pool.get('account.period').browse(cr, uid, period_id, context).date_start
|
||||
print 'compute entries', date_start
|
||||
for property in asset.property_ids:
|
||||
if property.state=='open':
|
||||
print 'Property State Open'
|
||||
period = self._compute_period(cr, uid, property, context)
|
||||
print period
|
||||
print period and period.date_start
|
||||
if period and (period.date_start<=date_start):
|
||||
result += self._compute_move(cr, uid, property, period, context)
|
||||
return result
|
||||
account_asset_asset()
|
||||
|
||||
class account_asset_property(osv.osv):
|
||||
def _amount_total(self, cr, uid, ids, name, args, context={}):
|
||||
id_set=",".join(map(str,ids))
|
||||
cr.execute("""SELECT l.asset_id,abs(SUM(l.debit-l.credit)) AS amount FROM
|
||||
account_asset_property p
|
||||
left join
|
||||
account_move_line l on (p.asset_id=l.asset_id)
|
||||
WHERE p.id IN ("""+id_set+") GROUP BY l.asset_id ")
|
||||
res=dict(cr.fetchall())
|
||||
for id in ids:
|
||||
res.setdefault(id, 0.0)
|
||||
return res
|
||||
|
||||
def _amount_residual(self, cr, uid, ids, name, args, context={}):
|
||||
id_set=",".join(map(str,ids))
|
||||
cr.execute("""SELECT
|
||||
r.asset_property_id,abs(SUM(l.debit-l.credit)) AS amount
|
||||
FROM
|
||||
account_move_asset_entry_rel r
|
||||
LEFT JOIN
|
||||
account_move_line l on (r.move_id=l.id)
|
||||
WHERE
|
||||
r.asset_property_id IN ("""+id_set+") GROUP BY r.asset_property_id ")
|
||||
res=dict(cr.fetchall())
|
||||
for prop in self.browse(cr, uid, ids, context):
|
||||
res[prop.id] = prop.value_total - res.get(prop.id, 0.0)
|
||||
for id in ids:
|
||||
res.setdefault(id, 0.0)
|
||||
return res
|
||||
|
||||
def _close(self, cr, uid, property, context={}):
|
||||
if property.state<>'close':
|
||||
self.pool.get('account.asset.property').write(cr, uid, [property.id], {
|
||||
'state': 'close'
|
||||
})
|
||||
property.state='close'
|
||||
ok = property.asset_id.state=='open'
|
||||
for prop in property.asset_id.property_ids:
|
||||
ok = ok and prop.state=='close'
|
||||
self.pool.get('account.asset.asset').write(cr, uid, [property.asset_id.id], {
|
||||
'state': 'close'
|
||||
}, context)
|
||||
return True
|
||||
|
||||
_name = 'account.asset.property'
|
||||
_description = 'Asset property'
|
||||
_columns = {
|
||||
'name': fields.char('Method name', size=64, select=1),
|
||||
'type': fields.selection([('direct','Direct'),('indirect','Indirect')], 'Asset type', select=2, required=True),
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True),
|
||||
'account_asset_id': fields.many2one('account.account', 'Asset account', required=True),
|
||||
'account_actif_id': fields.many2one('account.account', 'Actif account', required=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'journal_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),
|
||||
'account_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),
|
||||
|
||||
'method': fields.selection([('linear','Linear'),('progressif','Progressive')], 'Assesment method', required=True),
|
||||
'method_time': fields.selection([('delay','Delay'),('end','Ending period')], 'Time Method', required=True),
|
||||
'method_delay': fields.integer('Number of interval', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_period': fields.integer('Period per interval', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_end': fields.date('Ending date'),
|
||||
|
||||
'date': fields.date('Date created'),
|
||||
|
||||
'entry_asset_ids': fields.many2many('account.move.line', 'account_move_asset_entry_rel', 'asset_property_id', 'move_id', 'Asset Entries'),
|
||||
'entry_actif_ids': fields.many2many('account.move.line', 'account_move_asset_actif_entry_rel', 'asset_property_id', 'move_id', 'Asset Entries'),
|
||||
'board_ids': fields.one2many('account.asset.board', 'asset_id', 'Asset board'),
|
||||
|
||||
'value_total': fields.function(_amount_total, method=True, digits=(16,2),string='Total value'),
|
||||
'value_residual': fields.function(_amount_residual, method=True, digits=(16,2), string='Residual value'),
|
||||
'state': fields.selection([('draft','Draft'), ('open','Open'), ('close','Close')], 'State', required=True),
|
||||
'history_ids': fields.one2many('account.asset.property.history', 'asset_property_id', 'History', readonly=True)
|
||||
}
|
||||
_defaults = {
|
||||
'type': lambda obj, cr, uid, context: 'direct',
|
||||
'state': lambda obj, cr, uid, context: 'draft',
|
||||
'method': lambda obj, cr, uid, context: 'linear',
|
||||
'method_time': lambda obj, cr, uid, context: 'delay',
|
||||
'method_delay': lambda obj, cr, uid, context: 5,
|
||||
'method_period': lambda obj, cr, uid, context: 12,
|
||||
'date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d')
|
||||
}
|
||||
account_asset_property()
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
_inherit = 'account.move.line'
|
||||
_columns = {
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset', relate=True),
|
||||
}
|
||||
account_move_line()
|
||||
|
||||
class account_asset_property_history(osv.osv):
|
||||
_name = 'account.asset.property.history'
|
||||
_description = 'Asset history'
|
||||
_columns = {
|
||||
'name': fields.char('History name', size=64, select=1),
|
||||
'user_id': fields.many2one('res.users', 'User', required=True),
|
||||
'date': fields.date('Date', required=True),
|
||||
'asset_property_id': fields.many2one('account.asset.property', 'Property', required=True),
|
||||
'method_delay': fields.integer('Number of interval'),
|
||||
'method_period': fields.integer('Period per interval'),
|
||||
'method_end': fields.date('Ending date'),
|
||||
'note': fields.text('Note'),
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *args: time.strftime('%Y-%m-%d'),
|
||||
'user_id': lambda self,cr, uid,ctx: uid
|
||||
}
|
||||
account_asset_property_history()
|
||||
|
||||
|
||||
class account_asset_board(osv.osv):
|
||||
_name = 'account.asset.board'
|
||||
_description = 'Asset board'
|
||||
_columns = {
|
||||
'name': fields.char('Asset name', size=64, required=True, select=1),
|
||||
'asset_id': fields.many2one('account.asset.property', 'Asset', required=True, select=1),
|
||||
'value_gross': fields.float('Gross value', required=True, select=1),
|
||||
'value_asset': fields.float('Asset Value', required=True, select=1),
|
||||
'value_asset_cumul': fields.float('Cumul. value', required=True, select=1),
|
||||
'value_net': fields.float('Net value', required=True, select=1),
|
||||
}
|
||||
_auto = False
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view account_asset_board as (
|
||||
select
|
||||
min(l.id) as id,
|
||||
min(l.id) as asset_id,
|
||||
0.0 as value_gross,
|
||||
0.0 as value_asset,
|
||||
0.0 as value_asset_cumul,
|
||||
0.0 as value_net
|
||||
from
|
||||
account_move_line l
|
||||
where
|
||||
l.state <> 'draft' and
|
||||
l.asset_id=3
|
||||
)""")
|
||||
account_asset_board()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: product.py 1310 2005-09-08 20:40:15Z pinky $
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
|
||||
class account_invoice(osv.osv):
|
||||
_inherit = 'account.invoice'
|
||||
def line_get_convert(self, cr, uid, x, part, date, context={}):
|
||||
print self
|
||||
res = super(account_invoice, self).line_get_convert(cr, uid, x, part, date, context)
|
||||
res['asset_id'] = x.get('asset_id', False)
|
||||
return res
|
||||
account_invoice()
|
||||
|
||||
class account_invoice_line(osv.osv):
|
||||
_inherit = 'account.invoice.line'
|
||||
_columns = {
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset'),
|
||||
}
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
res = super(account_invoice_line, self).move_line_get_item(cr, uid, line, context)
|
||||
res['asset_id'] = line.asset_id.id or False
|
||||
if line.asset_id.id and (line.asset_id.state=='draft'):
|
||||
self.pool.get('account.asset.asset').validate(cr, uid, [line.asset_id.id], context)
|
||||
return res
|
||||
account_invoice_line()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
#---------------------------------------------------------
|
||||
# Fiscal Year
|
||||
#---------------------------------------------------------
|
||||
|
||||
<record model="ir.ui.view" id="view_account_invoice_asset_form">
|
||||
<field name="name">account.invoice.line.form</field>
|
||||
<field name="model">account.invoice.line</field>
|
||||
<field name="inherit_id" ref="account.view_invoice_line_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="price_subtotal" position="after">
|
||||
<field name="asset_id" context="name=name"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record model="ir.sequence.type" id="sequence_asset_type">
|
||||
<field name="name">Account asset</field>
|
||||
<field name="code">account.asset.code</field>
|
||||
</record>
|
||||
<record model="ir.sequence" id="sequence_asset">
|
||||
<field name="name">Account asset</field>
|
||||
<field name="code">account.asset.code</field>
|
||||
<field name="prefix"></field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
@@ -0,0 +1,273 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_category_form">
|
||||
<field name="name">account.asset.category.form</field>
|
||||
<field name="model">account.asset.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset category">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="note" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_category_tree">
|
||||
<field name="name">account.asset.category.tree</field>
|
||||
<field name="model">account.asset.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Asset category">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_account_asset_category_form">
|
||||
<field name="name">Asset category</field>
|
||||
<field name="res_model">account.asset.category</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Assets/"
|
||||
id="menu_action_account_asset_category_form"
|
||||
action="action_account_asset_category_form"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_property_tree">
|
||||
<field name="name">account.asset.property.tree</field>
|
||||
<field name="model">account.asset.property</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets methods">
|
||||
<field name="asset_id"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="value_total"/>
|
||||
<field name="value_residual"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_asset_form">
|
||||
<field name="name">account.asset.asset.form</field>
|
||||
<field name="model">account.asset.asset</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset">
|
||||
<notebook>
|
||||
<page string="General info">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="period_id" select="2"/>
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="property_ids" colspan="4" nolabel="1" mode="form,tree">
|
||||
<form string="Properties">
|
||||
<notebook string="Properties" tabpos="up">
|
||||
<page string="General info">
|
||||
<field name="account_asset_id"/>
|
||||
<field name="account_actif_id"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="type"/>
|
||||
<field name="account_analytic_id"/>
|
||||
<field name="journal_analytic_id"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<separator string="Asset method" colspan="4"/>
|
||||
<field name="method" readonly="True"/>
|
||||
<field name="method_time" readonly="True"/>
|
||||
<newline/>
|
||||
<field name="method_delay"/>
|
||||
<field name="method_period"/>
|
||||
<!-- <field name="method_end"/> -->
|
||||
<field name="value_total"/>
|
||||
<field name="value_residual"/>
|
||||
<field name="state" readonly="1"/>
|
||||
<group colspan="2" col="2">
|
||||
<button name="%(wizard_asset_modify)d" states="open" string="Modify method" type="action"/>
|
||||
<button name="%(wizard_asset_close)d" states="open" string="Close method" type="action"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Entries">
|
||||
<field name="entry_asset_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
<field name="entry_actif_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
</page>
|
||||
<page string="Change history">
|
||||
<field name="history_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
<field name="state" readonly="1"/>
|
||||
<group colspan="2" col="2">
|
||||
<button name="validate" states="draft" string="Confirm asset" type="object"/>
|
||||
</group>
|
||||
</page><page string="Entries">
|
||||
<field name="entry_ids" colspan="4" nolabel="1"/>
|
||||
</page><page string="Other information">
|
||||
<field name="date" select="2"/>
|
||||
<field name="sequence"/>
|
||||
<field name="partner_id" select="2"/>
|
||||
<field name="localisation" select="2"/>
|
||||
<field name="parent_id" select="2"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_property_history_form">
|
||||
<field name="name">account.asset.property.history.form</field>
|
||||
<field name="model">account.asset.property.history</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset history">
|
||||
<field name="name" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="method_delay" select="2"/>
|
||||
<field name="method_period"/>
|
||||
<field name="method_end"/>
|
||||
<separator string="Notes" colspan="4"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_property_history_tree">
|
||||
<field name="name">account.asset.property.history.tree</field>
|
||||
<field name="model">account.asset.property.history</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Asset history">
|
||||
<field name="date" select="1"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="method_delay" select="2"/>
|
||||
<field name="method_period"/>
|
||||
<field name="method_end"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_board_form">
|
||||
<field name="name">account.asset.board.form</field>
|
||||
<field name="model">account.asset.board</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset board">
|
||||
<field name="name" select="1"/>
|
||||
<field name="asset_id" select="1"/>
|
||||
<field name="value_gross" select="2"/>
|
||||
<field name="value_asset"/>
|
||||
<field name="value_asset_cumul"/>
|
||||
<field name="value_net"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_account_asset_board_tree">
|
||||
<field name="name">account.asset.board.tree</field>
|
||||
<field name="model">account.asset.board</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Asset board">
|
||||
<field name="name"/>
|
||||
<field name="asset_id"/>
|
||||
<field name="value_gross"/>
|
||||
<field name="value_asset"/>
|
||||
<field name="value_asset_cumul"/>
|
||||
<field name="value_net"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_asset_tree">
|
||||
<field name="name">account.asset.asset.tree</field>
|
||||
<field name="model">account.asset.asset</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="value_total"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_form">
|
||||
<field name="name">Asset</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Assets/"
|
||||
id="menu_action_account_asset_asset_form"
|
||||
action="action_account_asset_asset_form"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_tree">
|
||||
<field name="name">Asset hyerarchy</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">tree</field>
|
||||
<field name="domain">[('parent_id','=',False)]</field>
|
||||
<field name="view_id" ref="view_account_asset_asset_tree"/>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/"
|
||||
id="menu_action_account_asset_asset_tree"
|
||||
action="action_account_asset_asset_tree"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_list">
|
||||
<field name="name">Assets</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/Assets"
|
||||
id="menu_action_account_asset_asset_list"
|
||||
action="action_account_asset_asset_list"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_list_draft">
|
||||
<field name="name">Draft assets</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','draft')]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/Assets/"
|
||||
id="menu_action_account_asset_asset_list_draft"
|
||||
action="action_account_asset_asset_list_draft"/>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_list_normal">
|
||||
<field name="name">Open assets</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','normal')]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/Assets/"
|
||||
id="menu_action_account_asset_asset_list_normal"
|
||||
action="action_account_asset_asset_list_normal"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Financial Management" icon="terp-account"/>
|
||||
|
||||
<wizard
|
||||
string="Refund Invoice"
|
||||
model="account.invoice"
|
||||
name="account.invoice.refund"
|
||||
id="wizard_invoice_refund"/>
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<wizard
|
||||
string="Compute assets"
|
||||
model="account.asset.asset"
|
||||
name="account.asset.compute"
|
||||
keyword="tree_but_action"
|
||||
id="wizard_asset_compute"/>
|
||||
<menuitem
|
||||
name="Financial Management/Periodical Processing/Compute assets"
|
||||
action="wizard_asset_compute"
|
||||
type="wizard"
|
||||
id="menu_wizard_asset_compute"/>
|
||||
|
||||
|
||||
<wizard
|
||||
string="Modify asset"
|
||||
model="account.asset.asset"
|
||||
name="account.asset.modify"
|
||||
id="wizard_asset_modify"
|
||||
menu="False"/>
|
||||
<wizard
|
||||
string="Close asset"
|
||||
model="account.asset.asset"
|
||||
name="account.asset.close"
|
||||
id="wizard_asset_close"
|
||||
menu="False"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -0,0 +1,31 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard_asset_compute
|
||||
import wizard_asset_close
|
||||
import wizard_asset_modify
|
||||
@@ -0,0 +1,56 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
asset_end_arch = '''<?xml version="1.0"?>
|
||||
<form string="Close asset">
|
||||
<separator string="General information" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
asset_end_fields = {
|
||||
}
|
||||
|
||||
class wizard_asset_close(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':asset_end_arch, 'fields':asset_end_fields, 'state':[
|
||||
('end','Cancel'),
|
||||
('asset_close','End of asset')
|
||||
]}
|
||||
},
|
||||
'asset_close': {
|
||||
'actions': [],
|
||||
'result': {'type' : 'state', 'state': 'end'}
|
||||
}
|
||||
}
|
||||
wizard_asset_close('account.asset.close')
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
asset_end_arch = '''<?xml version="1.0"?>
|
||||
<form string="Compute assets">
|
||||
<separator string="Generated entries" colspan="4"/>
|
||||
<field name="move_ids" readonly="1" nolabel="1"/>
|
||||
</form>'''
|
||||
|
||||
asset_end_fields = {
|
||||
'move_ids': {'string':'Entries', 'type': 'one2many', 'relation':'account.move'},
|
||||
}
|
||||
|
||||
|
||||
asset_ask_form = '''<?xml version="1.0"?>
|
||||
<form string="Compute assets">
|
||||
<field name="period_id"/>
|
||||
</form>'''
|
||||
|
||||
asset_ask_fields = {
|
||||
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
||||
}
|
||||
|
||||
def _asset_compute(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ass_obj = pool.get('account.asset.asset')
|
||||
ids = ass_obj.search(cr, uid, [('state','=','normal')], context)
|
||||
ids_create = []
|
||||
for asset in ass_obj.browse(cr, uid, ids, context):
|
||||
ids_create += ass_obj._compute_entries(cr, uid, asset, data['form']['period_id'], context)
|
||||
self.move_ids = ids_create
|
||||
return {'move_ids': ids_create}
|
||||
|
||||
def _asset_open(self, cr, uid, data, context):
|
||||
value = {
|
||||
'name': 'Created moves',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move',
|
||||
'view_id': False,
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
if data['form']['move_ids']:
|
||||
value['domain']= "[('id','in',["+','.join(map(str,self.move_ids))+"])]"
|
||||
else:
|
||||
value['domain']= "[('id','=', False)]"
|
||||
print value
|
||||
return value
|
||||
|
||||
def _get_period(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = pool.get('account.period').find(cr, uid, context=context)
|
||||
period_id = False
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
return {'period_id': period_id}
|
||||
|
||||
class wizard_asset_compute(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_period],
|
||||
'result': {'type':'form', 'arch':asset_ask_form, 'fields':asset_ask_fields, 'state':[
|
||||
('end','Cancel'),
|
||||
('asset_compute','Compute assets')
|
||||
]}
|
||||
},
|
||||
'asset_compute': {
|
||||
'actions': [_asset_compute],
|
||||
'result': {'type' : 'form', 'arch': asset_end_arch, 'fields':asset_end_fields, 'state':[
|
||||
('end','Close'),
|
||||
('asset_open','Open entries')
|
||||
]}
|
||||
},
|
||||
'asset_open': {
|
||||
'actions': [],
|
||||
'result': {'type':'action', 'action': _asset_open, 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_asset_compute('account.asset.compute')
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
asset_end_arch = '''<?xml version="1.0"?>
|
||||
<form string="Modify asset">
|
||||
<separator string="Asset properties to modify" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="method_delay"/>
|
||||
<field name="method_period"/>
|
||||
<separator string="Notes" colspan="4"/>
|
||||
<field name="note" nolabel="1" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
asset_end_fields = {
|
||||
'name': {'string':'Reason', 'type':'char', 'size':64, 'required':True},
|
||||
'method_delay': {'string':'Number of interval', 'type':'float'},
|
||||
'method_period': {'string':'Period per interval', 'type':'float'},
|
||||
'note': {'string':'Notes', 'type':'text'},
|
||||
}
|
||||
|
||||
def _asset_default(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
prop = pool.get('account.asset.property').browse(cr, uid, data['id'], context)
|
||||
return {
|
||||
'name': prop.name,
|
||||
'method_delay': prop.method_delay,
|
||||
'method_period': prop.method_period
|
||||
}
|
||||
|
||||
def _asset_modif(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
prop = pool.get('account.asset.property').browse(cr, uid, data['id'], context)
|
||||
print prop
|
||||
pool.get('account.asset.property.history').create(cr, uid, {
|
||||
'asset_property_id': data['id'],
|
||||
'name': prop.name,
|
||||
'method_delay': prop.method_delay,
|
||||
'method_period': prop.method_period,
|
||||
'note': data['form']['note'],
|
||||
}, context)
|
||||
pool.get('account.asset.property').write(cr, uid, [data['id']], {
|
||||
'name': data['form']['name'],
|
||||
'method_delay': data['form']['method_delay'],
|
||||
'method_period': data['form']['method_period'],
|
||||
}, context)
|
||||
return {}
|
||||
|
||||
|
||||
class wizard_asset_modify(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_asset_default],
|
||||
'result': {'type':'form', 'arch':asset_end_arch, 'fields':asset_end_fields, 'state':[
|
||||
('end','Cancel'),
|
||||
('asset_modify','Modify asset')
|
||||
]}
|
||||
},
|
||||
'asset_modify': {
|
||||
'actions': [_asset_modif],
|
||||
'result': {'type' : 'state', 'state': 'end'}
|
||||
}
|
||||
}
|
||||
wizard_asset_modify('account.asset.modify')
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_simulation
|
||||
import wizard
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name" : "Accounting simulation journal",
|
||||
"version" : "1.0",
|
||||
"depends" : ["account"],
|
||||
"author" : "Tiny",
|
||||
"description": """Accounting simulation plan.""",
|
||||
"website" : "http://tinyerp.com/module_account.html",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"init_xml" : [
|
||||
],
|
||||
"demo_xml" : [
|
||||
"account_simulation_demo.xml"
|
||||
],
|
||||
"update_xml" : [ "account_simulation_view.xml" ],
|
||||
# "translations" : {
|
||||
# "fr": "i18n/french_fr.csv"
|
||||
# },
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
class account_journal_simulation(osv.osv):
|
||||
_name = "account.journal.simulation"
|
||||
_description = "Simulation level"
|
||||
_columns = {
|
||||
'name': fields.char('Simulation name', size=32, required=True),
|
||||
'code': fields.char('Simulation code', size=8, required=True),
|
||||
}
|
||||
_sql_constraints = [
|
||||
('code_uniq', 'unique (code)', 'The code of the simulation must be unique !')
|
||||
]
|
||||
_order = "name"
|
||||
account_journal_simulation()
|
||||
|
||||
def _state_simul_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('account.journal.simulation')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['code', 'name'], context)
|
||||
return [('valid','Valid')]+ [(r['code'], r['name']) for r in res]
|
||||
|
||||
class account_journal(osv.osv):
|
||||
_inherit = "account.journal"
|
||||
_columns = {
|
||||
'state': fields.selection(_state_simul_get, 'State', required=True),
|
||||
'parent_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_src_id', 'journal_dest_id', 'Childs journal'),
|
||||
'child_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_dest_id', 'journal_src_id', 'Parent journal'),
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda self,cr,uid,context: 'valid'
|
||||
}
|
||||
account_journal()
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
_inherit = "account.move.line"
|
||||
def search(self, cr, uid, crit, offset=0, limit=None, order=None, context={}):
|
||||
if not 'fiscalyear' in context:
|
||||
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
ok = True
|
||||
for c in crit:
|
||||
if c[0]=='journal_id':
|
||||
ok = False
|
||||
break
|
||||
if ok:
|
||||
plus = ''
|
||||
for state in context.get('journal_state', []):
|
||||
plus+=",'"+state+"'"
|
||||
cr.execute("select id from account_journal where state in ('valid'"+plus+")")
|
||||
crit.append(('journal_id', 'in', map(lambda x: x[0], cr.fetchall())))
|
||||
res = super(account_move_line, self).search(cr, uid, crit, offset, limit, order, context)
|
||||
return res
|
||||
|
||||
def _query_get(self, cr, uid, obj='l', context={}):
|
||||
res = super(account_move_line, self)._query_get(cr, uid, obj, context)
|
||||
if context.get('journal_state', []):
|
||||
plus = " and (l.journal_id in (select id from account_journal where state in ('valid', "+','.join(map(lambda x: "'"+x+"'", context['journal_state']))+")))"
|
||||
else:
|
||||
plus = " and (l.journal_id in (select id from account_journal where state='valid'))"
|
||||
return res+plus
|
||||
account_move_line()
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
|
||||
<!--
|
||||
Journal Simulation
|
||||
-->
|
||||
|
||||
<record model="account.journal.simulation" id="journal_sim0">
|
||||
<field name="name">Simulation Level 0</field>
|
||||
<field name="code">sim0</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_simulation_tree">
|
||||
<field name="name">account.journal.simulation.tree</field>
|
||||
<field name="model">account.journal.simulation</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Journal simulation">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_simulation_form">
|
||||
<field name="name">account.journal.simulation.form</field>
|
||||
<field name="model">account.journal.simulation</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Journal simulation">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_view_account_journal_simulation_form">
|
||||
<field name="name">Journal simulations</field>
|
||||
<field name="res_model">account.journal.simulation</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Journal/"
|
||||
id="menu_action_view_account_journal_simulation_form"
|
||||
action="action_view_account_journal_simulation_form"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_form_inherit_simul">
|
||||
<field name="name">account.journal.simulation.form.inherit</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="update_posted" position="after">
|
||||
<field name="state"/>
|
||||
<separator string="Child journals" colspan="4"/>
|
||||
<field name="child_ids" colspan="4"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_tree">
|
||||
<field name="name">account.journal.tree</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Account Journal">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_journal_tree">
|
||||
<field name="name">Account Journal</field>
|
||||
<field name="res_model">account.journal</field>
|
||||
<field name="view_type">tree</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Journal/Journal architecture"
|
||||
id="menu_action_account_journal_tree"
|
||||
action="action_account_journal_tree"/>
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard_account_chart
|
||||
@@ -0,0 +1,81 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
class wizard_account_chart(wizard.interface):
|
||||
_account_chart_arch = '''<?xml version="1.0"?>
|
||||
<form string="Account charts">
|
||||
<field name="fiscalyear"/>
|
||||
<separator string="Simulations" colspan="4"/>
|
||||
<field name="states" colspan="4" nolabel="1"/>
|
||||
</form>'''
|
||||
|
||||
_account_chart_fields = {
|
||||
'fiscalyear': {'string': 'Fiscal year', 'type':'many2one','relation': 'account.fiscalyear', 'required': True },
|
||||
'states': {'string':'States', 'type':'many2many', 'relation':'account.journal.simulation'},
|
||||
}
|
||||
|
||||
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):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
mod_obj = pool.get('ir.model.data')
|
||||
act_obj = pool.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])[0]
|
||||
|
||||
ctx = {'fiscalyear': data['form']['fiscalyear']}
|
||||
|
||||
|
||||
if data['form']['states']:
|
||||
ctx['journal_state']=[]
|
||||
sim_obj = pooler.get_pool(cr.dbname).get('account.journal.simulation')
|
||||
for a in sim_obj.read(cr, uid, data['form']['states'][0][2], ['code'], context):
|
||||
ctx['journal_state'].append(a['code'])
|
||||
result['context'] = str(ctx)
|
||||
return result
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_defaults],
|
||||
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel'), ('open', 'Open Charts')]}
|
||||
},
|
||||
'open': {
|
||||
'actions': [],
|
||||
'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_account_chart('account.chart')
|
||||
@@ -145,7 +145,18 @@ class account_invoice_line(osv.osv):
|
||||
cur = inv.currency_id
|
||||
|
||||
for line in inv.invoice_line:
|
||||
res.append( {
|
||||
res.append( self.move_line_get_item(cr, uid, line, context))
|
||||
for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, (line.price_unit *(1.0-(line['discount'] or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id):
|
||||
if inv.type in ('out_invoice', 'in_invoice'):
|
||||
res[-1]['tax_code_id'] = tax['base_code_id']
|
||||
res[-1]['tax_amount'] = tax['price_unit'] * line['quantity'] * tax['base_sign']
|
||||
else:
|
||||
res[-1]['ta_code_id'] = tax['ref_base_code_id']
|
||||
res[-1]['tax_amount'] = tax['price_unit'] * line['quantity'] * tax['ref_base_sign']
|
||||
return res
|
||||
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
return {
|
||||
'type':'src',
|
||||
'name':line.name,
|
||||
'price_unit':line.price_unit,
|
||||
@@ -155,15 +166,7 @@ class account_invoice_line(osv.osv):
|
||||
'product_id': line.product_id.id,
|
||||
'uos_id':line.uos_id.id,
|
||||
'account_analytic_id':line.account_analytic_id.id,
|
||||
})
|
||||
for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, (line.price_unit *(1.0-(line['discount'] or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id):
|
||||
if inv.type in ('out_invoice', 'in_invoice'):
|
||||
res[-1]['tax_code_id'] = tax['base_code_id']
|
||||
res[-1]['tax_amount'] = tax['price_unit'] * line['quantity'] * tax['base_sign']
|
||||
else:
|
||||
res[-1]['ta_code_id'] = tax['ref_base_code_id']
|
||||
res[-1]['tax_amount'] = tax['price_unit'] * line['quantity'] * tax['ref_base_sign']
|
||||
return res
|
||||
}
|
||||
|
||||
def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context={}):
|
||||
if context.get('price_type', False) == 'tax_included':
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"category" : "Localisation/Europe",
|
||||
"website": "http://www.tinyerp.com",
|
||||
"depends" : ["base", "account", "account_cash_discount",],
|
||||
"init_xml" : ["dta/dta_data.xml", "vaudtax_data.xml", "zip_code_default.xml",],
|
||||
"init_xml" : ["dta/dta_data.xml", "vaudtax_data.xml"], #, "zip_code_default.xml",],
|
||||
"demo_xml" : ["vaudtax_data_demo.xml","dta/dta_demo.xml"],
|
||||
"update_xml" : [
|
||||
"dta/dta_view.xml","dta/dta_wizard.xml",
|
||||
|
||||
Reference in New Issue
Block a user