merge with #1527 trunk

bzr revid: jean-baptiste.aubort@camptocamp.com-20080829085204-0fi6v6wfnescqy3a
This commit is contained in:
Jean-Baptiste Aubort 2008-08-29 10:52:04 +02:00
commit 5fc89eae6b
553 changed files with 55654 additions and 2023 deletions

View File

@ -129,9 +129,11 @@ class account_tax(osv.osv):
account_tax()
class account_account(osv.osv):
_order = "code"
_order = "parent_left"
_parent_order = "code"
_name = "account.account"
_description = "Account"
_parent_store = True
def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
@ -139,6 +141,9 @@ class account_account(osv.osv):
context = {}
pos = 0
while pos<len(args):
if args[pos][0]=='code' and args[pos][1] in ('like','ilike'):
args[pos][1]='=like'
args[pos][2]=str(args[pos][2])+'%'
if args[pos][0]=='journal_id':
if not args[pos][2]:
del args[pos]
@ -155,89 +160,49 @@ class account_account(osv.osv):
return super(account_account,self).search(cr, uid, args, offset, limit,
order, context=context, count=count)
def _credit(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, " \
"SUM(COALESCE(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 + " " \
"AND a.active " \
"GROUP BY a.id") % (acc_set, ))
res2 = cr.fetchall()
res = {}
for id in ids:
res[id] = 0.0
for account_id, sum in res2:
res[account_id] += sum
return res
# def _credit(self, cr, uid, ids, field_name, arg, context={}):
# return self.__compute(cr, uid, ids, field_name, arg, context, 'COALESCE(SUM(l.credit), 0)')
#
# def _debit(self, cr, uid, ids, field_name, arg, context={}):
# return self.__compute(cr, uid, ids, field_name, arg, context, 'COALESCE(SUM(l.debit), 0)')
#
# def _balance(self, cr, uid, ids, field_name, arg, context={}):
# return self.__compute(cr, uid, ids, field_name, arg, context, 'COALESCE(SUM(l.debit) - SUM(l.credit), 0)')
def _debit(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, " \
"SUM(COALESCE(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 + " " \
"AND a.active " \
"GROUP BY a.id") % (acc_set, ))
res2 = cr.fetchall()
res = {}
for id in ids:
res[id] = 0.0
for account_id, sum in res2:
res[account_id] += sum
return res
def _balance(self, cr, uid, ids, field_name, arg, context={}):
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
mapping = {
'balance': "COALESCE(SUM(l.debit) - SUM(l.credit), 0) as balance ",
'debit': "COALESCE(SUM(l.debit), 0) as debit ",
'credit': "COALESCE(SUM(l.credit), 0) as credit "
}
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
ids2 = {}.fromkeys(ids + ids2).keys()
acc_set = ",".join(map(str, ids2))
query = self.pool.get('account.move.line')._query_get(cr, uid,
context=context)
cr.execute(("SELECT a.id, " \
"SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 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 + " " \
"AND a.active " \
"GROUP BY a.id") % (acc_set, ))
res = {}
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
cr.execute("SELECT a.id, a.company_id " \
"FROM account_account a " \
"WHERE id IN (%s)" % acc_set)
resc = dict(cr.fetchall())
cr.execute("SELECT id, currency_id FROM res_company")
rescur = dict(cr.fetchall())
accounts = {}
if ids2:
query = self.pool.get('account.move.line')._query_get(cr, uid,
context=context)
cr.execute(("SELECT l.account_id, " +\
' , '.join(map(lambda x: mapping[x], field_names)) +
"FROM " \
"account_move_line l " \
"WHERE " \
"l.account_id IN (%s) " \
"AND " + query + " " \
"GROUP BY l.account_id") % (acc_set, ))
for res in cr.fetchall():
accounts[res[0]] = res[1:]
res = {}
for id in ids:
ids3 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
to_currency_id = rescur[resc[id]]
for idx in ids3:
if idx <> id:
res.setdefault(id, 0.0)
if resc[idx]<>resc[id] and resc[idx] and resc[id]:
from_currency_id = rescur[resc[idx]]
res[id] += self.pool.get('res.currency').compute(cr,
uid, from_currency_id, to_currency_id,
res.get(idx, 0.0), context=context)
else:
res[id] += res.get(idx, 0.0)
for id in ids:
res[id] = round(res.get(id,0.0), 2)
res[id] = map(lambda x: 0.0, field_names)
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
for i in ids2:
for a in range(len(field_names)):
res[id][a] += accounts.get(i, (0.0,0.0,0.0))[a]
# TODO: if account.type is consolidation: compute all childs like before +
# currency conversion
return res
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
@ -267,15 +232,15 @@ class account_account(osv.osv):
'code': fields.char('Code', size=64),
'type': fields.selection(_code_get, 'Account Type', required=True),
# 'parent_id': fields.many2many('account.account', 'account_account_rel', 'child_id', 'parent_id', 'Parents'),
'parent_id': fields.many2one('account.account','Parent'),
'parent_id': fields.many2one('account.account','Parent', ondelete='cascade'),
'child_parent_ids':fields.one2many('account.account','parent_id','Children'),
'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children',domain=[('type','=','root'), ('type', '=', 'consolidation')]),
'child_id': fields.function(_get_child_ids, method=True, type='many2many',relation="account.account",string="Children Accounts"),
# 'child_id': fields.many2many('account.account', 'account_account_rel', 'parent_id', 'child_id', 'Children'),
'balance': fields.function(_balance, digits=(16,2), method=True, string='Balance'),
'credit': fields.function(_credit, digits=(16,2), method=True, string='Credit'),
'debit': fields.function(_debit, digits=(16,2), method=True, string='Debit'),
'balance': fields.function(__compute, digits=(16,2), method=True, string='Balance', multi='balance'),
'credit': fields.function(__compute, digits=(16,2), method=True, string='Credit', multi='balance'),
'debit': fields.function(__compute, digits=(16,2), method=True, string='Debit', multi='balance'),
'reconcile': fields.boolean('Reconcile', help="Check this account if the user can make a reconciliation of the entries in this account."),
'shortcut': fields.char('Shortcut', size=12),
'close_method': fields.selection([('none','None'), ('balance','Balance'), ('detail','Detail'),('unreconciled','Unreconciled')], 'Deferral Method', required=True, help="Tell Tiny ERP how to process the entries of this account when you close a fiscal year. None removes all entries to start with an empty account for the new fiscal year. Balance creates only one entry to keep the balance for the new fiscal year. Detail keeps the detail of all entries of the preceeding years. Unreconciled keeps the detail of unreconciled entries only."),
@ -285,6 +250,9 @@ class account_account(osv.osv):
'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Company Currency'),
'company_id': fields.many2one('res.company', 'Company', required=True),
'active': fields.boolean('Active', select=2),
'parent_left': fields.integer('Parent Left', select=1),
'parent_right': fields.integer('Parent Right', select=1),
}
def _default_company(self, cr, uid, context={}):
@ -378,7 +346,7 @@ class account_account(osv.osv):
res.append((record['id'],name ))
return res
def copy(self, cr, uid, id, default=None, context={}):
def copy(self, cr, uid, id, default={}, context={}):
account = self.browse(cr, uid, id, context=context)
new_child_ids = []
default['parent_id'] = False
@ -455,6 +423,7 @@ class account_journal(osv.osv):
'user_id': fields.many2one('res.users', 'User', help="The responsible user of this journal"),
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want that new account moves pass through the \'draft\' state and goes direclty to the \'posted state\' without any manual validation.'),
}
_defaults = {
'active': lambda *a: 1,
@ -494,7 +463,7 @@ class account_fiscalyear(osv.osv):
'date_start': fields.date('Start date', required=True),
'date_stop': fields.date('End date', required=True),
'period_ids': fields.one2many('account.period', 'fiscalyear_id', 'Periods'),
'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', redonly=True),
'state': fields.selection([('draft','Draft'), ('done','Done')], 'Status', redonly=True),
}
_defaults = {
@ -541,7 +510,7 @@ class account_period(osv.osv):
'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),
'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True)
'state': fields.selection([('draft','Draft'), ('done','Done')], 'Status', readonly=True)
}
_defaults = {
'state': lambda *a: 'draft',
@ -583,7 +552,7 @@ class account_journal_period(osv.osv):
'period_id': fields.many2one('account.period', 'Period', required=True, ondelete="cascade"),
'icon': fields.function(_icon_get, method=True, string='Icon', type='string'),
'active': fields.boolean('Active', required=True),
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'State', required=True, readonly=True)
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True)
}
def _check(self, cr, uid, ids, context={}):
@ -658,7 +627,7 @@ class account_move(osv.osv):
'ref': fields.char('Ref', size=64),
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}),
'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State', required=True, readonly=True),
'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'Status', required=True, readonly=True),
'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}),
}
_defaults = {
@ -747,6 +716,7 @@ class account_move(osv.osv):
vals['name'] = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
accnt_journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'])
if 'line_id' in vals:
c = context.copy()
c['novalidate'] = True
@ -1127,7 +1097,7 @@ class account_tax(osv.osv):
'ref_tax_sign': fields.float('Tax Code Sign', help="Usualy 1 or -1."),
'include_base_amount': fields.boolean('Include in base amount', help="Indicate if the amount of tax must be included in the base amount for the computation of the next taxes"),
'company_id': fields.many2one('res.company', 'Company', required=True),
'description': fields.char('Internal Name', 32),
'description': fields.char('Internal Name',size=32),
}
def name_get(self, cr, uid, ids, context={}):
@ -1477,7 +1447,7 @@ class account_subscription(osv.osv):
'period_total': fields.integer('Number of period', required=True),
'period_nbr': fields.integer('Period', required=True),
'period_type': fields.selection([('day','days'),('month','month'),('year','year')], 'Period Type', required=True),
'state': fields.selection([('draft','Draft'),('running','Running'),('done','Done')], 'State', required=True, readonly=True),
'state': fields.selection([('draft','Draft'),('running','Running'),('done','Done')], 'Status', required=True, readonly=True),
'lines_id': fields.one2many('account.subscription.line', 'subscription_id', 'Subscription Lines')
}
@ -1686,7 +1656,7 @@ class account_account_template(osv.osv):
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."),
'code': fields.char('Code', size=64),
'type': fields.selection(_code_get, 'Account Type', required=True),
'reconcile': fields.boolean('Reconcile', help="Check this option if the user can make a reconciliation of the entries in this account."),
'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if the user can make a reconciliation of the entries in this account."),
'shortcut': fields.char('Shortcut', size=12),
'note': fields.text('Note'),
}
@ -1813,5 +1783,59 @@ class account_chart_template(osv.osv):
account_chart_template()
class wizard_account_chart_duplicate(osv.osv_memory):
"""
Create a new account chart for a new company.
Wizards ask:
* an accuont chart (parent_id,=,False)
* a company
Then, the wizard:
* duplicates all accounts and assign to the right company
* duplicates all taxes, changing account assignations
* duplicate all accounting properties and assign correctly
"""
_name = 'wizard.account.chart.duplicate'
_columns = {
'name':fields.char('Name',size=64),
'account_id':fields.many2one('account.account','Account Chart',required=True,domain=[('parent_id','=',False)]),
'company_id':fields.many2one('res.company','Company',required=True),
}
def action_create(self, cr, uid,ids, context=None):
res=self.read(cr,uid,ids)[0]
if res.get('account_id',False) and res.get('company_id',False):
account_obj=self.pool.get('account.account')
account_tax_obj=self.pool.get('account.tax')
property_obj=self.pool.get('ir.property')
# duplicate all accounts
account_obj.copy(cr,uid,res['account_id'],default={'company_id':res['company_id']})
# duplicate all taxes
tax_ids=account_tax_obj.search(cr,uid,[])
for tax in account_tax_obj.browse(cr,uid,tax_ids):
val={'company_id':res['company_id']}
if tax.account_collected_id:
new_invoice_account_ids=account_obj.search(cr,uid,[('name','=',tax.account_collected_id.name),('company_id','=',res['company_id'])])
val['account_collected_id']=len(new_invoice_account_ids) and new_invoice_account_ids[0] or False
if tax.account_paid_id:
new_refund_account_ids=account_obj.search(cr,uid,[('name','=',tax.account_paid_id.name),('company_id','=',res['company_id'])])
val['account_paid_id']=len(new_refund_account_ids) and new_refund_account_ids[0] or False
account_tax_obj.copy(cr,uid,tax.id,default=val)
# duplicate all accouting properties
property_ids=property_obj.search(cr,uid,[('value','=like','account.account,%')])
for property in property_obj.browse(cr,uid,property_ids):
account=account_obj.browse(cr,uid,property.value[1])
if account:
new_account_ids=account_obj.search(cr,uid,[('name','=',account.name),('company_id','=',res['company_id'])])
if len(new_account_ids):
property_obj.copy(cr,uid,property.id,default={
'value':'account.account,'+str(new_account_ids[0]),
'company_id':res['company_id']
})
return {'type':'ir.actions.act_window_close'}
wizard_account_chart_duplicate()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -46,9 +46,9 @@ class account_analytic_line(osv.osv):
'product_uom_id' : fields.many2one('product.uom', 'UoM'),
'product_id' : fields.many2one('product.product', 'Product'),
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
'general_account_id' : fields.many2one('account.account', 'General account', required=True, ondelete='cascade'),
'move_id' : fields.many2one('account.move.line', 'General entry', ondelete='cascade', select=True),
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic journal', required=True, ondelete='cascade', select=True),
'general_account_id' : fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'),
'move_id' : fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True),
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True),
'code' : fields.char('Code', size=8),
'user_id' : fields.many2one('res.users', 'User',),
'ref': fields.char('Ref.', size=32),

View File

@ -138,7 +138,7 @@ class account_bank_statement(osv.osv):
'currency': fields.function(_currency, method=True, string='Currency',
type='many2one', relation='res.currency'),
}
_defaults = {
'name': lambda self, cr, uid, context=None: \
self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement'),
@ -289,6 +289,8 @@ class account_bank_statement(osv.osv):
except:
raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount))
if st.journal_id.entry_posted:
account_move_obj.write(cr, uid, [move_id], {'state':'posted'})
done.append(st.id)
self.write(cr, uid, done, {'state':'confirm'}, context=context)
return True
@ -435,7 +437,7 @@ class account_bank_statement_reconcile(osv.osv):
td = 'P '
else:
currency_id = company_currency_id
res.append((o.id, '%s[%.2f/%.2f]' % (td,
res.append((o.id, '%s[%.2f-%.2f]' % (td,
res_currency_obj.compute(cursor, user, company_currency_id,
currency_id, o.total_entry, context=context),
res_currency_obj.compute(cursor, user, company_currency_id,

View File

@ -112,12 +112,12 @@
<field name="priority">2</field>
<field name="arch" type="xml">
<form string="Supplier invoice">
<notebook>
<field domain="[('type', '=', 'purchase')]" name="journal_id" select="2"/>
<field name="type" readonly="1" select="2"/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank)" select="1"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<notebook colspan="4">
<page string="Invoice">
<field domain="[('type', '=', 'purchase')]" name="journal_id" select="2"/>
<field name="type" readonly="1" select="2"/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank)" select="1"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', company_id),('journal_id','=',journal_id)]" name="account_id"/>
<field name="date_due" select="1"/>
<field domain="[('partner_id', '=', partner_id)]" name="partner_bank" on_change="onchange_partner_bank(partner_bank)" select="2"/>
@ -164,6 +164,7 @@
<button name="invoice_open" states="draft,proforma" string="Validate"/>
<button name="invoice_cancel" states="draft,proforma,sale,open" string="Cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid'/>
</group>
</group>
</page>
@ -195,12 +196,12 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invoice">
<notebook>
<field name="journal_id" select="2"/>
<field name="type" readonly="1" select="2"/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term)" select="1"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<notebook colspan="4">
<page string="Invoice">
<field name="journal_id" select="2"/>
<field name="type" readonly="1" select="2"/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term)" select="1"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', company_id),('journal_id','=',journal_id)]" name="account_id"/>
<field name="payment_term" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)"/>
<field name="name" select="2"/>
@ -232,6 +233,7 @@
<button name="invoice_open" states="draft,proforma" string="Create"/>
<button name="invoice_cancel" states="draft,proforma,sale,open" string="Cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid'/>
</group>
</group>
</page>
@ -405,10 +407,10 @@
<menuitem action="action_invoice_tree6" id="menu_action_invoice_tree6" parent="menu_action_invoice_tree1"/>
<record id="action_invoice_tree7" model="ir.actions.act_window">
<field name="name">Open Customer Invoices</field>
<field name="name">Unpaid Customer Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="domain">[('state','=','open'),('type','=','out_invoice')]</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
<record id="action_invoice_tree7_view1" model="ir.actions.act_window.view">
@ -447,10 +449,10 @@
<menuitem action="action_invoice_tree8" id="menu_action_invoice_tree8" parent="menu_action_invoice_tree2"/>
<record id="action_invoice_tree9" model="ir.actions.act_window">
<field name="name">Open Supplier Invoices</field>
<field name="name">Unpaid Supplier Invoices</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="domain">[('state','=','open'),('type','=','in_invoice')]</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice'}</field>
</record>
<record id="action_invoice_tree9_view1" model="ir.actions.act_window.view">
@ -489,10 +491,10 @@
<menuitem action="action_invoice_tree10" id="menu_action_invoice_tree10" parent="menu_action_invoice_tree3"/>
<record id="action_invoice_tree11" model="ir.actions.act_window">
<field name="name">Open Customer Refunds</field>
<field name="name">Unpaid Customer Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="domain">[('state','=','open'),('type','=','out_refund')]</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund'}</field>
</record>
<record id="action_invoice_tree11_view1" model="ir.actions.act_window.view">
@ -531,10 +533,10 @@
<menuitem action="action_invoice_tree12" id="menu_action_invoice_tree12" parent="menu_action_invoice_tree4"/>
<record id="action_invoice_tree13" model="ir.actions.act_window">
<field name="name">Open Supplier Refunds</field>
<field name="name">Unpaid Supplier Refunds</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="domain">[('state','=','open'),('type','=','in_refund')]</field>
<field name="domain">[('state','!=','draft'),('reconciled','=',False),('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund'}</field>
</record>
<record id="action_invoice_tree13_view1" model="ir.actions.act_window.view">
@ -551,9 +553,9 @@
<menuitem action="action_invoice_tree13" id="menu_action_invoice_tree13" parent="menu_action_invoice_tree4"/>
<act_window domain="[('partner_id', '=', active_id),('state', '=', 'open')]" id="act_res_partner_2_account_invoice_opened" name="Open invoices" res_model="account.invoice" src_model="res.partner"/>
<act_window domain="[('partner_id','=',active_id),('state','!=','draft'),('reconciled','=',False)]" id="act_res_partner_2_account_invoice_opened" name="Unpaid invoices" res_model="account.invoice" src_model="res.partner"/>
<act_window domain="[('journal_id', '=', active_id),('state', '=', 'open')]" id="act_account_journal_2_account_invoice_opened" name="Open invoices" res_model="account.invoice" src_model="account.journal"/>
<act_window domain="[('journal_id','=',active_id),('state','!=','draft'),('reconciled','=',False)]" id="act_account_journal_2_account_invoice_opened" name="Unpaid invoices" res_model="account.invoice" src_model="account.journal"/>
<act_window domain="[('account_analytic_id', '=', active_id)]" id="act_account_analytic_account_2_account_invoice_line" name="Invoice lines" res_model="account.invoice.line" src_model="account.analytic.account"/>

View File

@ -6,7 +6,7 @@
<field name="osv">account.invoice</field>
<field name="on_create">True</field>
</record>
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="flow_start">True</field>
@ -31,10 +31,16 @@ action_number()
write({'state':'open'})</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_open_test">
<field name="wkf_id" ref="wkf"/>
<field name="name">open</field>
<field name="action">write({'state':'open'})</field>
<field name="kind">function</field>
</record>
<record id="act_paid" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">paid</field>
<field name="flow_stop">True</field>
<!--<field name="flow_stop">True</field>-->
<field name="action">write({'state':'paid'})</field>
<field name="kind">function</field>
</record>
@ -46,14 +52,14 @@ write({'state':'open'})</field>
write({'state':'cancel'})</field>
<field name="kind">function</field>
</record>
<!--
<record model="workflow.transition" id="t1">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_confirm"/>
</record>
-->
<record id="t3" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_proforma"/>
@ -98,5 +104,15 @@ write({'state':'cancel'})</field>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record id="t13" model="workflow.transition">
<field name="act_from" ref="act_paid"/>
<field name="act_to" ref="act_open_test"/>
<field name="signal">open_test</field>
</record>
<record id="t14" model="workflow.transition">
<field name="act_from" ref="act_open_test"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
</data>
</terp>

View File

@ -49,9 +49,9 @@ class account_move_line(osv.osv):
if state:
if state.lower() not in ['all']:
where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
if context.get('periods', False):
ids = ','.join([str(x) for x in context['periods']])
ids = ','.join([str(x) for x in context['periods']])
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
else:
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
@ -71,6 +71,7 @@ class account_move_line(osv.osv):
return data
period_obj = self.pool.get('account.period')
tax_obj=self.pool.get('account.tax')
# Compute the current move
move_id = False
@ -86,6 +87,7 @@ class account_move_line(osv.osv):
(context['journal_id'], context['period_id'], uid, 'draft'))
res = cr.fetchone()
move_id = (res and res[0]) or False
if not move_id:
return data
else:
@ -111,102 +113,39 @@ class account_move_line(osv.osv):
total = 0
ref_id = False
taxes = {}
move = self.pool.get('account.move').browse(cr, uid, move_id, context)
for l in move.line_id:
partner_id = partner_id or l.partner_id.id
ref_id = ref_id or l.ref
total += (l.debit - l.credit)
for tax in l.account_id.tax_ids:
if move.journal_id.type == 'sale':
if l.debit:
code = tax.ref_tax_code_id.id
acc = tax.account_paid_id.id
else:
code = tax.tax_code_id.id
acc = tax.account_collected_id.id
else:
if l.debit:
code = tax.tax_code_id.id
acc = tax.account_collected_id.id
else:
code = tax.ref_tax_code_id.id
acc = tax.account_paid_id.id
taxes.setdefault((acc, code), False)
taxes[(l.account_id.id, l.tax_code_id.id)] = True
total += (l.debit or 0.0) - (l.credit or 0.0)
if 'name' in fields:
data.setdefault('name', l.name)
data.setdefault('name', l.name)
if 'ref' in fields:
data['ref'] = ref_id
if 'partner_id' in fields:
data['partner_id'] = partner_id
if move.journal_id.type in ('purchase', 'sale'):
for t in taxes:
if not taxes[t] and t[0]:
s = 0
tax_amount = 0
for l in move.line_id:
if move.journal_id.type == 'sale':
if l.debit:
field_base = 'ref_'
key = 'account_paid_id'
else:
field_base = ''
key = 'account_collected_id'
else:
if l.debit:
field_base = ''
key = 'account_collected_id'
else:
field_base = 'ref_'
key = 'account_paid_id'
for tax in self.pool.get('account.tax').compute(cr, uid,
l.account_id.tax_ids, l.debit or l.credit, 1, False):
if (tax[key] == t[0]) \
and (tax[field_base + 'tax_code_id'] == t[1]):
if l.debit:
s += tax['amount']
else:
s -= tax['amount']
tax_amount += tax['amount'] * \
tax[field_base + 'tax_sign']
if ('debit' in fields) or ('credit' in fields):
data['debit'] = s>0 and s or 0.0
data['credit'] = s<0 and -s or 0.0
if 'tax_code_id' in fields:
data['tax_code_id'] = t[1]
if 'account_id' in fields:
data['account_id'] = t[0]
if 'tax_amount' in fields:
data['tax_amount'] = tax_amount
#
# Compute line for tax T
#
return data
#
# Compute latest line
#
if ('debit' in fields) or ('credit' in fields):
data['credit'] = total>0 and total
data['debit'] = total<0 and -total
if 'account_id' in fields:
if total >= 0:
data['account_id'] = move.journal_id.default_credit_account_id.id or False
if move.journal_id.type == 'purchase':
if total>0:
account = move.journal_id.default_credit_account_id
else:
data['account_id'] = move.journal_id.default_debit_account_id.id or False
if 'account_id' in fields and data['account_id']:
account = self.pool.get('account.account').browse(cr, uid, data['account_id'])
data['tax_code_id'] = self._default_get_tax(cr, uid, account )
return data
account = move.journal_id.default_debit_account_id
else:
if total>0:
account = move.journal_id.default_credit_account_id
else:
account = move.journal_id.default_debit_account_id
def _default_get_tax(self, cr, uid, account, debit=0, credit=0, context={}):
if account.tax_ids:
return account.tax_ids[0].base_code_id.id
return False
data['account_id'] = account.id
if account and account.tax_ids:
for tax in self.pool.get('account.tax').compute_inv(cr,uid,[account.tax_ids[0]],total,1.00):
total -= tax['amount']
data['account_tax_id'] = account.tax_ids[0].id
s = -total
data['debit'] = s>0 and s or 0.0
data['credit'] = s<0 and -s or 0.0
return data
def _on_create_write(self, cr, uid, id, context={}):
ml = self.browse(cr, uid, id, context)
@ -307,7 +246,6 @@ class account_move_line(osv.osv):
'debit': fields.float('Debit', digits=(16,2)),
'credit': fields.float('Credit', digits=(16,2)),
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly',True)]}, help="The move of this entry line.", select=2),
'ref': fields.char('Ref.', size=32),
@ -317,8 +255,8 @@ class account_move_line(osv.osv):
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optionnal other currency if it is a multi-currency entry."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optionnal other currency if it is a multi-currency entry."),
'period_id': fields.many2one('account.period', 'Period', required=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'period_id': fields.many2one('account.period', 'Period', required=True, select=2),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1),
'blocked': fields.boolean('Litigation', help="You can check this box to mark the entry line as a litigation with the associated partner"),
'partner_id': fields.many2one('res.partner', 'Partner Ref.'),
@ -329,11 +267,15 @@ class account_move_line(osv.osv):
'centralisation': fields.selection([('normal','Normal'),('credit','Credit Centralisation'),('debit','Debit Centralisation')], 'Centralisation', size=6),
'balance': fields.function(_balance, method=True, string='Balance'),
'active': fields.boolean('Active'),
'state': fields.selection([('draft','Draft'), ('valid','Valid')], 'State', readonly=True),
'state': fields.selection([('draft','Draft'), ('valid','Valid')], 'Status', readonly=True),
'tax_code_id': fields.many2one('account.tax.code', 'Tax Account'),
'tax_amount': fields.float('Tax/Base Amount', digits=(16,2), select=True),
'invoice': fields.function(_invoice, method=True, string='Invoice',
type='many2one', relation='account.invoice', fnct_search=_invoice_search),
'account_tax_id':fields.many2one('account.tax', 'Tax'),
'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'),
#TODO: remove this
'amount_taxed':fields.float("Taxed Amount",digits=(16,2)),
}
def _get_date(self, cr, uid, context):
@ -394,34 +336,22 @@ class account_move_line(osv.osv):
(_check_no_closed, 'You can not create move line on closed account.', ['account_id']),
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, journal=False):
if (not partner_id) or account_id:
return {}
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
id1 = part.property_account_payable.id
id2 = part.property_account_receivable.id
cr.execute('select sum(debit-credit) from account_move_line where (reconcile_id is null) and partner_id=%d and account_id=%d', (partner_id, id2))
balance = cr.fetchone()[0] or 0.0
val = {}
if (not debit) and (not credit):
if abs(balance)>0.01:
val['credit'] = ((balance>0) and balance) or 0
val['debit'] = ((balance<0) and -balance) or 0
val['account_id'] = id2
else:
cr.execute('select sum(debit-credit) from account_move_line where (reconcile_id is null) and partner_id=%d and account_id=%d', (partner_id, id1))
balance = cr.fetchone()[0] or 0.0
val['credit'] = ((balance>0) and balance) or 0
val['debit'] = ((balance<0) and -balance) or 0
val['account_id'] = id1
else:
val['account_id'] = (debit>0) and id2 or id1
if journal:
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
if jt=='sale':
val['account_id'] = id2
elif jt=='purchase':
val['account_id'] = id1
# Compute Maturity Date in val !
return {'value':val}
#
@ -474,7 +404,11 @@ class account_move_line(osv.osv):
account_id = line['account_id']['id']
partner_id = (line['partner_id'] and line['partner_id']['id']) or False
writeoff = debit - credit
date = time.strftime('%Y-%m-%d')
# Ifdate_p in context => take this date
if context.has_key('date_p') and context['date_p']:
date=context['date_p']
else:
date = time.strftime('%Y-%m-%d')
cr.execute('SELECT account_id, reconcile_id \
FROM account_move_line \
@ -505,9 +439,15 @@ class account_move_line(osv.osv):
self_credit = 0.0
self_debit = -writeoff
# If comment exist in context, take it
if context['comment']:
libelle=context['comment']
else:
libelle='Write-Off'
writeoff_lines = [
(0, 0, {
'name':'Write-Off',
'name':libelle,
'debit':self_debit,
'credit':self_credit,
'account_id':account_id,
@ -517,7 +457,7 @@ class account_move_line(osv.osv):
'amount_currency': account.currency_id.id and -currency or 0.0
}),
(0, 0, {
'name':'Write-Off',
'name':libelle,
'debit':debit,
'credit':credit,
'account_id':writeoff_acc_id,
@ -558,6 +498,11 @@ class account_move_line(osv.osv):
return r_id
def view_header_get(self, cr, user, view_id, view_type, context):
if context.get('account_id', False):
cr.execute('select code from account_account where id=%d', (context['account_id'],))
res = cr.fetchone()
res = _('Entries: ')+ (res[0] or '')
return res
if (not context.get('journal_id', False)) or (not context.get('period_id', False)):
return False
cr.execute('select code from account_journal where id=%d', (context['journal_id'],))
@ -565,8 +510,8 @@ class account_move_line(osv.osv):
cr.execute('select code from account_period where id=%d', (context['period_id'],))
p = cr.fetchone()[0] or ''
if j or p:
return j+':'+p
return 'Journal'
return j+(p and (':'+p) or '')
return False
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False):
result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context)
@ -632,7 +577,19 @@ class account_move_line(osv.osv):
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
if not context:
context={}
raise_ex=False
account_obj = self.pool.get('account.account')
acc=account_obj.browse(cr,uid,ids)[0]
if ('debit' in vals and 'credit' in vals) and not vals['debit'] and not vals['credit']:
raise_ex=True
if ('debit' in vals and 'credit' not in vals) and not vals['debit'] and not acc.credit:
raise_ex=True
if ('credit' in vals and 'debit' not in vals) and not vals['credit'] and not acc.debit:
raise_ex=True
if raise_ex:
raise osv.except_osv(_('Wrong Accounting Entry!'), _('Both Credit and Debit cannot be zero!'))
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
@ -680,7 +637,9 @@ class account_move_line(osv.osv):
def create(self, cr, uid, vals, context=None, check=True):
if not context:
context={}
account_obj = self.pool.get('account.account')
tax_obj=self.pool.get('account.tax')
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
@ -692,7 +651,9 @@ class account_move_line(osv.osv):
m = self.pool.get('account.move').browse(cr, uid, vals['move_id'])
context['journal_id'] = m.journal_id.id
context['period_id'] = m.period_id.id
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
move_id = vals.get('move_id', False)
journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id'])
if not move_id:
@ -743,9 +704,50 @@ class account_move_line(osv.osv):
vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx)
if not ok:
raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !'))
result = super(osv.osv, self).create(cr, uid, vals, context)
if 'analytic_account_id' in vals and vals['analytic_account_id']:
if journal.analytic_journal_id:
vals['analytic_lines'] = [(0,0, {
'name': vals['name'],
'date': vals['date'],
'account_id': vals['analytic_account_id'],
'unit_amount': vals['quantity'],
'amount': vals['debit'] or vals['credit'],
'general_account_id': vals['account_id'],
'journal_id': journal.analytic_journal_id.id,
'ref': vals['ref'],
})]
# CREATE Taxes
if 'account_tax_id' in vals and vals['account_tax_id']:
tax_id=tax_obj.browse(cr,uid,vals['account_tax_id'])
total = vals['credit'] or (-vals['debit'])
for tax in tax_obj.compute(cr,uid,[tax_id],total,1.00):
self.write(cr, uid,[result], {
'tax_code_id': tax['base_code_id'],
'tax_amount': tax['base_sign'] * total
})
data = {
'move_id': vals['move_id'],
'journal_id': vals['journal_id'],
'period_id': vals['period_id'],
'name': vals['name']+' '+tax['name'],
'date': vals['date'],
'partner_id': vals.get('partner_id',False),
'ref': vals.get('ref',False),
'account_tax_id': False,
'tax_code_id': tax['tax_code_id'],
'tax_amount': tax['tax_sign'] * tax['amount'],
'account_id': tax['account_paid_id'], # or collected ?
'credit': tax['amount']>0 and tax['amount'] or 0.0,
'debit': tax['amount']<0 and -tax['amount'] or 0.0,
}
self.create(cr, uid, data, context)
if check:
self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context)
tmp = self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context)
if journal.entry_posted and tmp:
self.pool.get('account.move').write(cr,uid, [vals['move_id']],{'state':'posted'})
return result
account_move_line()
@ -757,7 +759,5 @@ class account_bank_statement_reconcile(osv.osv):
}
account_bank_statement_reconcile()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -111,22 +111,23 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account">
<notebook>
<group col="6" colspan="4">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="type" select="1"/>
<field name="company_id" select="2"/>
<field name="parent_id"/>
<field name="active"/>
</group>
<notebook colspan="4">
<page string="General Information">
<field colspan="4" name="name" select="1"/>
<field name="company_id" select="2"/>
<field name="active"/>
<newline/>
<field name="type" select="1"/>
<field name="code" select="1"/>
<field name="shortcut"/>
<field name="sign"/>
<field name="currency_id" select="2"/>
<field name="close_method"/>
<field name="reconcile"/>
<newline/>
<field name="parent_id"/>
<newline/>
<field name="child_consol_ids" colspan="4"/>
<field colspan="4" name="tax_ids"/>
@ -172,27 +173,6 @@
</record>
<menuitem action="action_account_tree" id="menu_action_account_tree" parent="account.account_account_menu"/>
<record id="view_account_list" model="ir.ui.view">
<field name="name">account.account.list</field>
<field name="model">account.account</field>
<field name="type">tree</field>
<field name="field_parent">child_id</field>
<field eval="6" name="priority"/>
<field name="arch" type="xml">
<tree string="Chart of Accounts">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<record id="action_account_tree2" model="ir.actions.act_window">
<field name="name">Fast Chart of Accounts</field>
<field name="res_model">account.account</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_account_list"/>
<field name="domain">[('code','=','0')]</field>
</record>
<!--
Journal
@ -262,12 +242,12 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Journal">
<notebook>
<field name="name" select="1"/>
<field name="active" select="1"/>
<field name="code" select="1"/>
<field name="type"/>
<notebook colspan="4">
<page string="General Information">
<field name="name" select="1"/>
<field name="active" select="1"/>
<field name="code" select="1"/>
<field name="type"/>
<field name="view_id"/>
<field name="sequence_id"/>
<field name="default_debit_account_id"/>
@ -277,6 +257,7 @@
<newline/>
<field name="centralisation"/>
<field name="update_posted"/>
<field name="entry_posted"/>
</page>
<page string="Entry Controls">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>
@ -332,7 +313,7 @@
<notebook colspan="4">
<page string="Entry encoding">
<field colspan="4" name="line_ids" nolabel="1">
<tree colors="red:amount!=reconcile_amount and reconcile_id" editable="bottom" string="Statement lines">
<tree editable="bottom" string="Statement lines">
<field name="date"/>
<field name="ref"/>
<field name="name"/>
@ -573,14 +554,16 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Tax">
<notebook>
<group colspan="4" col="6">
<field name="name" select="1"/>
<field name="company_id"/>
<field name="description" select="1"/>
<field name="active" select="2"/>
<field name="tax_group" select="1"/>
<field name="type"/>
</group>
<notebook colspan="4">
<page string="Tax Definition">
<field name="name" select="1"/>
<field name="company_id"/>
<field name="description" select="1"/>
<field name="tax_group" select="1"/>
<field name="active" select="2"/>
<field name="type"/>
<field name="applicable_type"/>
<field name="amount" select="2" attrs="{'readonly':[('type','=','none'),('type','=','code')]}"/>
<field groups="base.group_extended" name="include_base_amount"/>
@ -674,6 +657,8 @@
<field name="journal_id"/>
<field name="debit" sum="Total debit"/>
<field name="credit" sum="Total credit"/>
<field name="account_tax_id"/>
<field name="analytic_account_id"/>
<field name="amount_currency"/>
<field name="currency_id"/>
<field name="state"/>
@ -716,6 +701,9 @@
<newline/>
<field name="tax_code_id"/>
<field name="tax_amount"/>
<newline/>
<field name="account_tax_id"/>
<field name="analytic_account_id"/>
<separator colspan="4" string="State"/>
<field name="journal_id" select="2"/>
@ -764,6 +752,9 @@
<field name="date_created"/>
<field name="date_created"/>
<field name="blocked" select="3"/>
<newline/>
<field name="account_tax_id"/>
<field name="analytic_account_id"/>
<separator colspan="4" string="State"/>
<newline/>
@ -900,9 +891,8 @@
<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"/>
<wizard id="wizard_account_chart" menu="False" model="account.account" name="account.chart" string="Accounts Charts"/>
<wizard id="wizard_account_chart" menu="False" model="account.account" name="account.chart" string="Chart of Accounts"/>
<menuitem action="wizard_account_chart" id="menu_action_account_tree2" parent="account.menu_finance_charts" type="wizard"/>
<menuitem action="action_account_tree2" id="menu_action_account_tree3" parent="account.menu_action_account_tree2"/>
@ -1332,17 +1322,18 @@
</record>
<record id="action_move_line_tree1" model="ir.actions.act_window">
<field name="name">Move line select</field>
<field name="name">Entries</field>
<field name="res_model">account.move.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('account_id','child_of', [active_id]),('state','&lt;&gt;','draft')]</field>
<field name="context">{'account_id':active_id}</field>
</record>
<wizard id="wizard_move_line_select" menu="False" model="account.move.line" name="account.move.line.select" string="Move line select"/>
<record id="ir_open_account_account" model="ir.values">
<field eval="'tree_but_open'" name="key2"/>
<field eval="'account.account'" name="model"/>
<field name="name">Open all entries lines</field>
<field name="name">Account Entries</field>
<field eval="'ir.actions.wizard,%d'%wizard_move_line_select" name="value"/>
<field eval="True" name="object"/>
</record>
@ -1365,6 +1356,8 @@
<field name="tax_amount"/>
<field name="debit" sum="Total debit"/>
<field name="credit" sum="Total credit"/>
<field name="account_tax_id"/>
<field name="analytic_account_id"/>
<field name="state"/>
</tree>
</field>
@ -1525,14 +1518,14 @@
<menuitem id="account_account_template_menu" name="Templates" parent="account.menu_finance_configuration"/>
<menuitem action="action_account_template_form" id="menu_action_account_template_form" parent="account_account_template_menu"/>
<!-- Account Chart Templates -->
<!-- Chart of Accounts Templates -->
<record id="view_account_chart_template_form" model="ir.ui.view">
<field name="name">account.chart.template.form</field>
<field name="model">account.chart.template</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Chart Template">
<form string="Chart of Accounts Template">
<field colspan="4" name="name" select="1"/>
<newline/>
<field name="account_root_id" select="1"/>
@ -1549,7 +1542,7 @@
<field name="model">account.chart.template</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Account Chart Template">
<tree string="Chart of Accounts Template">
<field name="name"/>
<field name="account_root_id"/>
<field name="bank_account_view_id"/>
@ -1557,7 +1550,7 @@
</field>
</record>
<record id="action_account_chart_template_form" model="ir.actions.act_window">
<field name="name">Account Chart Templates</field>
<field name="name">Chart of Accounts Templates</field>
<field name="res_model">account.chart.template</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@ -1603,5 +1596,33 @@
<menuitem action="action_account_tax_template_form" id="menu_action_account_tax_template_form" parent="account_account_template_menu"/>
<!-- wizard account duplicate chart -->
<record id="view_wizard_account_duplicate_chart" model="ir.ui.view">
<field name="name">wizard.account.chart.duplicate.form</field>
<field name="model">wizard.account.chart.duplicate</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Duplicate Chart of Accounts">
<field name="account_id"/>
<field name="company_id"/>
<newline/>
<group colspan="4">
<button icon="gtk-cancel" special="cancel" type="object" string="Cancel"/>
<button icon="gtk-ok" name="action_create" string="Create" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_wizard_account_duplicate_chart_form" model="ir.actions.act_window">
<field name="name">Duplicate Chart of Accounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.account.chart.duplicate</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem action="action_wizard_account_duplicate_chart_form" id="menu_action_wizard_account_duplicate_chart_form" parent="account_account_menu"/>
</data>
</terp>

View File

@ -77,5 +77,7 @@
<wizard string="Use Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>
<menuitem action="wizard_account_use_model" type="wizard" parent="account.menu_finance_periodical_processing" id="menu_account_use_model"/>
<!-- account.invoice -->
<wizard string="Open State" model="account.invoice" name="account.wizard_paid_open" menu="False" id="wizard_paid_open"/>
</data>
</terp>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<terp>
<data noupdate="1">
<!--
Payment term
-->
-->
<record id="account_payment_term" model="account.payment.term">
<field name="name">30 Days Net</field>
</record>
@ -15,7 +15,7 @@
<field name="condition">net days</field>
<field eval="account_payment_term" name="payment_id"/>
</record>
<!--
Account Journal View
-->
@ -74,6 +74,18 @@
<field name="field">credit</field>
<field eval="11" name="sequence"/>
</record>
<record id="bank_col11" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Tax</field>
<field name="field">account_tax_id</field>
<field eval="12" name="sequence"/>
</record>
<record id="bank_col12" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Analytic Account</field>
<field name="field">analytic_account_id</field>
<field eval="13" name="sequence"/>
</record>
<record id="bank_col3" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Ref</field>
@ -84,9 +96,9 @@
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">State</field>
<field name="field">state</field>
<field eval="12" name="sequence"/>
<field eval="14" name="sequence"/>
</record>
<record id="account_journal_bank_view_multi" model="account.journal.view">
<field name="name">Multi-Currency Cash Journal View</field>
</record>
@ -142,17 +154,29 @@
<field name="field">credit</field>
<field eval="11" name="sequence"/>
</record>
<record id="bank_col11_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Tax</field>
<field name="field">account_tax_id</field>
<field eval="12" name="sequence"/>
</record>
<record id="bank_col12_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Analytic Account</field>
<field name="field">analytic_account_id</field>
<field eval="13" name="sequence"/>
</record>
<record id="bank_col17_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Currency Amt.</field>
<field name="field">amount_currency</field>
<field eval="12" name="sequence"/>
<field eval="14" name="sequence"/>
</record>
<record id="bank_col18_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Currency</field>
<field name="field">currency_id</field>
<field eval="13" name="sequence"/>
<field eval="15" name="sequence"/>
</record>
<record id="bank_col3_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
@ -164,10 +188,10 @@
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">State</field>
<field name="field">state</field>
<field eval="14" name="sequence"/>
<field eval="16" name="sequence"/>
</record>
<record id="account_journal_view" model="account.journal.view">
<field name="name">Journal View</field>
</record>
@ -229,30 +253,42 @@
<field name="field">credit</field>
<field eval="9" name="sequence"/>
</record>
<record id="journal_col10" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Tax</field>
<field name="field">account_tax_id</field>
<field eval="10" name="sequence"/>
</record>
<record id="journal_col11" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Analytic Account</field>
<field name="field">analytic_account_id</field>
<field eval="11" name="sequence"/>
</record>
<record id="journal_col25" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Tax Acc.</field>
<field name="field">tax_code_id</field>
<field eval="10" name="sequence"/>
<field eval="12" name="sequence"/>
</record>
<record id="journal_col26" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Tax</field>
<field name="field">tax_amount</field>
<field eval="11" name="sequence"/>
<field eval="13" name="sequence"/>
</record>
<record id="journal_col24" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">State</field>
<field name="field">state</field>
<field eval="12" name="sequence"/>
<field eval="14" name="sequence"/>
</record>
<!--
Account Journal Sequences
-->
<record id="sequence_journal_type" model="ir.sequence.type">
<field name="name">Account Journal</field>
<field name="code">account.journal</field>
@ -262,11 +298,11 @@
<field name="code">account.journal</field>
<field name="prefix"/>
</record>
<!--
Account Statement Sequences
-->
<record id="sequence_reconcile" model="ir.sequence.type">
<field name="name">Account reconcile sequence</field>
<field name="code">account.reconcile</field>
@ -278,8 +314,8 @@
<field eval="1" name="number_next"/>
<field eval="1" name="number_increment"/>
</record>
<record id="sequence_statement_type" model="ir.sequence.type">
<field name="name">Bank Statement</field>
<field name="code">account.bank.statement</field>
@ -291,11 +327,11 @@
<field eval="0" name="number_next"/>
<field eval="1" name="number_increment"/>
</record>
<!--
Account Journal
-->
<record id="sales_journal" model="account.journal">
<field name="name">Sales Journal</field>
<field name="code">SAJ</field>
@ -316,7 +352,7 @@
<field model="account.account" name="default_credit_account_id" search="[('type','=','payable')]"/>
<field name="user_id" ref="base.user_root"/>
</record>
<record id="bank_journal" model="account.journal">
<field name="name">Bank Journal</field>
<field name="code">BNK</field>
@ -327,7 +363,7 @@
<field model="account.account" name="default_credit_account_id" search="[('type','=','cash')]"/>
<field name="user_id" ref="base.user_root"/>
</record>
<record forcecreate="1" id="stock_journal" model="account.journal">
<field name="name">Stock Journal</field>
<field name="code">STJ</field>
@ -336,6 +372,6 @@
<field name="sequence_id" ref="sequence_journal"/>
<field name="user_id" ref="base.user_root"/>
</record>
</data>
</terp>

View File

@ -122,7 +122,7 @@ class account_invoice(osv.osv):
('draft','Draft'),
('proforma','Pro-forma'),
('open','Open'),
('paid','Paid'),
('paid','Done'),
('cancel','Canceled')
],'State', select=True, readonly=True),
@ -149,9 +149,9 @@ class account_invoice(osv.osv):
'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True),
'check_total': fields.float('Total', digits=(16,2), states={'open':[('readonly',True)],'close':[('readonly',True)]}),
'reconciled': fields.function(_reconciled, method=True, string='Reconciled', type='boolean'),
'reconciled': fields.function(_reconciled, method=True, string='Paid/Reconciled', type='boolean'),
'partner_bank': fields.many2one('res.partner.bank', 'Bank Account',
help='The bank account to pay or to be paid'),
help='The bank account to pay to or to be paid from'),
}
_defaults = {
'type': _get_type,
@ -499,14 +499,18 @@ class account_invoice(osv.osv):
_('Can not create invoice move on centralized journal'))
move = {'name': name, 'line_id': line, 'journal_id': journal_id}
if inv.period_id:
move['period_id'] = inv.period_id.id
period_id=inv.period_id and inv.period_id.id or False
if not period_id:
period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice),('date_stop','>=',inv.date_invoice)])
if len(period_ids):
period_id=period_ids[0]
if period_id:
move['period_id'] = period_id
for i in line:
i[2]['period_id'] = inv.period_id.id
i[2]['period_id'] = period_id
move_id = self.pool.get('account.move').create(cr, uid, move)
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id})
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id})
self.pool.get('account.move').post(cr, uid, [move_id])
self._log_event(cr, uid, ids)
return True
@ -681,20 +685,30 @@ class account_invoice(osv.osv):
invoice = self.browse(cr, uid, ids[0])
src_account_id = invoice.account_id.id
journal = self.pool.get('account.journal').browse(cr, uid, pay_journal_id)
if not name:
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.'))
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.'))
# Take the seq as name for move
if journal.sequence_id:
seq = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv('No piece number !', 'Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')
types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
direction = types[invoice.type]
#take the choosen date
if context.has_key('date_p') and context['date_p']:
date=context['date_p']
else:
date=time.strftime('%Y-%m-%d')
l1 = {
'name': name,
'debit': direction * pay_amount>0 and direction * pay_amount,
'credit': direction * pay_amount<0 and - direction * pay_amount,
'account_id': src_account_id,
'partner_id': invoice.partner_id.id,
'date': time.strftime('%Y-%m-%d'),
'date': date,
'ref':invoice.number,
}
l2 = {
'name':name,
@ -702,11 +716,12 @@ class account_invoice(osv.osv):
'credit': direction * pay_amount>0 and direction * pay_amount,
'account_id': pay_account_id,
'partner_id': invoice.partner_id.id,
'date': time.strftime('%Y-%m-%d'),
'date': date,
'ref':invoice.number,
}
lines = [(0, 0, l1), (0, 0, l2)]
move = {'name': name, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id}
move = {'name': seq, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id}
move_id = self.pool.get('account.move').create(cr, uid, move)
line_ids = []
@ -790,9 +805,9 @@ class account_invoice_line(osv.osv):
taxep=None
if partner_id:
lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang']
taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax
tax_obj = self.pool.get('account.tax')
if type in ('out_invoice', 'out_refund'):
taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_supplier_tax
if not taxep or not taxep.id:
tax_id = map(lambda x: x.id, res.taxes_id)
else:
@ -801,6 +816,7 @@ class account_invoice_line(osv.osv):
if not t.tax_group==taxep.tax_group:
tax_id.append(t.id)
else:
taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax
if not taxep or not taxep.id:
tax_id = map(lambda x: x.id, res.supplier_taxes_id)
else:

View File

@ -35,20 +35,33 @@ class res_partner(osv.osv):
_name = 'res.partner'
_inherit = 'res.partner'
_description = 'Partner'
def _credit_get(self, cr, uid, ids, name, arg, context):
res={}
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context):
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
for id in ids:
cr.execute("select sum(debit-credit) from account_move_line as l where account_id in (select id from account_account where type = %s and active) and partner_id=%d and reconcile_id is null and "+query, ('receivable', id))
res[id]=cr.fetchone()[0] or 0.0
return res
def _debit_get(self, cr, uid, ids, name, arg, context):
res={}
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
for id in ids:
cr.execute("select sum(debit-credit) from account_move_line as l where account_id in (select id from account_account where type = %s and active) and partner_id=%d and reconcile_id is null and "+query, ('payable', id))
res[id]=cr.fetchone()[0] or 0.0
cr.execute(("""select
l.partner_id, a.type, sum(l.debit-l.credit)
from
account_move_line l
left join
account_account a on (l.account_id=a.id)
where
a.type in ('receivable','payable') and
l.partner_id in (%s) and
l.reconcile_id is null and
""" % (','.join(map(str, ids)),))+query+"""
group by
l.partner_id, a.type
""")
tinvert = {
'credit': 'receivable',
'debit': 'payable'
}
maps = {}
for i in range(len(field_names)):
maps[{'credit': 'receivable', 'debit': 'payable' }[field_names[i]]] = i
res = {}.fromkeys(ids, map(lambda x: 0.0, field_names))
for pid,type,val in cr.fetchall():
if type in maps:
res[pid][maps[type]] = val
return res
def _credit_search(self, cr, uid, obj, name, args):
@ -74,8 +87,8 @@ class res_partner(osv.osv):
return [('id','in',map(lambda x:x[0], res))]
_columns = {
'credit': fields.function(_credit_get, fnct_search=_credit_search, method=True, string='Total Receivable'),
'debit': fields.function(_debit_get, fnct_search=_debit_search, method=True, string='Total Payable'),
'credit': fields.function(_credit_debit_get, fnct_search=_credit_search, method=True, string='Total Receivable', multi='dc'),
'debit': fields.function(_credit_debit_get, fnct_search=_debit_search, method=True, string='Total Payable', multi='dc'),
'debit_limit': fields.float('Payable Limit'),
'property_account_payable': fields.property(
'account.account',
@ -84,7 +97,6 @@ class res_partner(osv.osv):
string="Account Payable",
method=True,
view_load=True,
group_name="Accounting Properties",
domain="[('type', '=', 'payable')]",
help="This account will be used, instead of the default one, as the payable account for the current partner",
required=True),
@ -95,10 +107,17 @@ class res_partner(osv.osv):
string="Account Receivable",
method=True,
view_load=True,
group_name="Accounting Properties",
domain="[('type', '=', 'receivable')]",
help="This account will be used, instead of the default one, as the receivable account for the current partner",
required=True),
'property_account_supplier_tax': fields.property(
'account.tax',
type='many2one',
relation='account.tax',
string="Default Supplier Tax",
method=True,
view_load=True,
help="This tax will be used, instead of the default one for supplier invoices."),
'property_account_tax': fields.property(
'account.tax',
type='many2one',
@ -106,8 +125,7 @@ class res_partner(osv.osv):
string="Default Tax",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This tax will be used, instead of the default one."),
help="This tax will be used, instead of the default one for customers."),
'property_payment_term': fields.property(
'account.payment.term',
type='many2one',
@ -115,7 +133,6 @@ class res_partner(osv.osv):
string ='Payment Term',
method=True,
view_load=True,
group_name="Accounting Properties",
help="This payment term will be used, instead of the default one, for the current partner"),
'ref_companies': fields.one2many('res.company', 'partner_id',
'Companies that refers to partner'),

View File

@ -2,21 +2,68 @@
<terp>
<data>
<!--
Partners Extension
-->
Partners Extension
-->
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.form.inherit</field>
<record id="view_partner_property_form" model="ir.ui.view">
<field name="name">res.partner.property.form.inherit</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="priority">2</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="credit_limit" position="after">
<field name="credit" select="2"/>
<field name="debit" select="2"/>
<newline/>
</field>
<notebook>
<page string="Accounting" position="inside">
<group col="2" colspan="2">
<separator string="Customer Accounting Properties" colspan="2"/>
<field name="property_account_receivable"/>
<field name="property_account_tax"/>
<field name="property_payment_term"/>
</group>
<group col="2" colspan="2">
<separator string="Supplier Accounting Properties" colspan="2"/>
<field name="property_account_payable"/>
<field name="property_account_supplier_tax"/>
</group>
<group col="2" colspan="2">
<separator string="Customer Credit" colspan="2"/>
<field name="credit" select="2"/>
<field name="credit_limit" select="2"/>
</group>
<group col="2" colspan="2">
<separator string="Supplier Debit" colspan="2"/>
<field name="debit" select="2"/>
</group>
<field colspan="4" context="address=address" name="bank_ids" nolabel="1">
<form string="Bank account">
<field name="state" select="2"/>
<newline/>
<field name="acc_number" select="1"/>
<newline/>
<field name="bank"/>
<newline/>
<field name="sequence"/>
<field colspan="4" name="name" select="2"/>
<separator colspan="4" string="Bank account owner"/>
<field colspan="4" name="owner_name"/>
<field colspan="4" name="street"/>
<newline/>
<field name="zip"/>
<field name="city"/>
<newline/>
<field completion="1" name="country_id"/>
<field name="state_id"/>
</form>
<tree string="Bank Details">
<field name="state"/>
<field name="owner_name"/>
<field name="acc_number"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>
</data>
</terp>
</terp>

View File

@ -42,7 +42,6 @@ class product_category(osv.osv):
string="Income Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value incoming stock for the current product category"),
'property_account_expense_categ': fields.property(
'account.account',
@ -51,7 +50,6 @@ class product_category(osv.osv):
string="Expense Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value outgoing stock for the current product category"),
}
product_category()
@ -75,7 +73,6 @@ class product_template(osv.osv):
string="Income Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value incoming stock for the current product"),
'property_account_expense': fields.property(
'account.account',
@ -84,7 +81,6 @@ class product_template(osv.osv):
string="Expense Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value outgoing stock for the current product"),
}
product_template()

View File

@ -7,28 +7,58 @@
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="product_manager" position="after">
<newline/>
<field colspan="4" name="supplier_taxes_id"/>
<field colspan="4" name="taxes_id"/>
<newline/>
</field>
<notebook position="inside">
<page string="Accounting">
<separator string="Sales" colspan="2"/>
<separator string="Purchases" colspan="2"/>
<field name="property_account_income"/>
<field name="property_account_expense"/>
<separator string="Sale Taxes" colspan="2"/>
<separator string="Purchase Taxes" colspan="2"/>
<field name="taxes_id" nolabel="1" colspan="2"/>
<field name="supplier_taxes_id" nolabel="1" colspan="2"/>
</page>
</notebook>
</field>
</record>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.product.form.inherit</field>
<field name="model">product.template</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="cost_method" position="after">
<newline/>
<field colspan="4" name="supplier_taxes_id"/>
<field colspan="4" name="taxes_id"/>
<newline/>
</field>
<notebook position="inside">
<page string="Accounting">
<separator string="Sales" colspan="2"/>
<separator string="Purchases" colspan="2"/>
<field name="property_account_income"/>
<field name="property_account_expense"/>
<field name="supplier_taxes_id"/>
<field name="taxes_id"/>
</page>
</notebook>
</field>
</record>
<record id="view_category_property_form" model="ir.ui.view">
<field name="name">product.category.property.form.inherit</field>
<field name="model">product.category</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<form position="inside">
<group col="2" colspan="2">
<separator string="Accounting Properties" colspan="2"/>
<field name="property_account_income_categ"/>
<field name="property_account_expense_categ"/>
</group>
</form>
</field>
</record>
</data>
</terp>
</terp>

View File

@ -35,7 +35,7 @@ from osv import fields
from osv import osv
#
# Model definition
# Object definition
#
class account_analytic_account(osv.osv):
@ -237,6 +237,14 @@ class account_analytic_journal(osv.osv):
}
account_analytic_journal()
class account_journal(osv.osv):
_inherit="account.journal"
_columns = {
'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal'),
}
account_journal()
# ---------------------------------------------------------
# Budgets

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<terp>
<data>
<record id="view_account_analytic_account_list" model="ir.ui.view">
<field name="name">account.analytic.account.list</field>
<field name="model">account.analytic.account</field>
@ -17,7 +17,7 @@
</tree>
</field>
</record>
<record id="view_account_analytic_account_tree" model="ir.ui.view">
<field name="name">account.analytic.account.tree</field>
<field name="model">account.analytic.account</field>
@ -37,22 +37,23 @@
</tree>
</field>
</record>
<record id="view_account_analytic_account_form" model="ir.ui.view">
<field name="name">account.analytic.account.form</field>
<field name="model">account.analytic.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic account">
<notebook>
<group colspan="4" col="6">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="parent_id" on_change="on_change_parent(parent_id)"/>
<field name="company_id" select="2"/>
<field name="type" select="2"/>
<field name="partner_id" select="1"/>
</group>
<notebook colspan="4">
<page string="Account Data">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="parent_id" on_change="on_change_parent(parent_id)"/>
<field name="company_id" select="2"/>
<field name="type" select="2"/>
<field name="partner_id" select="1"/>
<newline/>
<field name="date_start"/>
<field name="date" select="2"/>
<field name="active" select="2"/>
@ -66,7 +67,7 @@
</form>
</field>
</record>
<record id="action_account_analytic_account_form" model="ir.actions.act_window">
<field name="name">Analytic Accounts</field>
<field name="type">ir.actions.act_window</field>
@ -75,10 +76,10 @@
<field name="view_id" ref="view_account_analytic_account_tree"/>
</record>
<menuitem id="next_id_39" name="Analytic Accounts" parent="account.menu_finance_configuration"/>
<menuitem action="action_account_analytic_account_form" id="account_analytic_def_account" parent="next_id_39"/>
<menuitem action="action_account_analytic_account_form" id="account_analytic_def_account" parent="next_id_39"/>
<record id="action_account_analytic_account_tree2" model="ir.actions.act_window">
<field name="name">Analytic Charts of Accounts</field>
<field name="name">Analytic Chart of Accounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.analytic.account</field>
<field name="domain">[('parent_id','=',False)]</field>
@ -86,13 +87,13 @@
<field name="view_id" ref="view_account_analytic_account_tree"/>
</record>
<menuitem
action="action_account_analytic_account_tree2"
id="account_analytic_def_chart"
parent="account.next_id_39"/>
action="action_account_analytic_account_tree2"
id="account_analytic_def_chart"
parent="account.next_id_39"/>
<menuitem action="action_account_analytic_account_tree2" id="account_analytic_chart" parent="account.menu_finance_charts"/>
<menuitem id="next_id_40" name="Analytic" parent="account.menu_finance_reporting"/><menuitem action="action_account_analytic_account_tree2" id="account_analytic_chart_balance" parent="next_id_40"/>
<record id="view_account_analytic_line_form" model="ir.ui.view">
<field name="name">account.analytic.line.form</field>
<field name="model">account.analytic.line</field>
@ -141,8 +142,8 @@
<field name="view_id" ref="view_account_analytic_line_tree"/>
</record>
<menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/><menuitem action="action_account_analytic_line_form" id="account_entries_analytic_entries" parent="next_id_41"/>
<record id="action_account_tree1" model="ir.actions.act_window">
<field name="name">action.account.tree1</field>
<field name="res_model">account.analytic.line</field>
@ -157,7 +158,7 @@
<field eval="'ir.actions.act_window,%d'%action_account_tree1" name="value"/>
<field eval="True" name="object"/>
</record>
<record id="account_analytic_line_extended_form" model="ir.ui.view">
<field name="name">account.analytic.line.extended_form</field>
<field name="model">account.analytic.line</field>
@ -183,11 +184,11 @@
<field name="view_type">form</field>
<field name="view_id" ref="account_analytic_line_extended_form"/>
</record>
#
# Analytic Journal
#
<record id="view_account_analytic_journal_tree" model="ir.ui.view">
<field name="name">account.analytic.journal.tree</field>
<field name="model">account.analytic.journal</field>
@ -200,7 +201,7 @@
</tree>
</field>
</record>
<record id="view_account_analytic_journal_form" model="ir.ui.view">
<field name="name">account.analytic.journal.form</field>
<field name="model">account.analytic.journal</field>
@ -221,11 +222,11 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_analytic_journal_form" id="account_def_analytic_journal" parent="account.next_id_25"/>
#
# Open journal entries
#
<record id="action_account_analytic_journal_open_form" model="ir.actions.act_window">
<field name="name">account.analytic.journal.open.form</field>
<field name="res_model">account.analytic.line</field>
@ -240,19 +241,19 @@
<field eval="'ir.actions.act_window,%d'%action_account_analytic_journal_open_form" name="value"/>
<field eval="True" name="object"/>
</record>
#
# Reporting
#
<record id="action_account_analytic_journal_tree" model="ir.actions.act_window">
<field name="name">Print Analytic Journals</field>
<field name="res_model">account.analytic.journal</field>
<field name="view_type">tree</field>
</record>
<menuitem action="action_account_analytic_journal_tree" id="account_analytic_journal_print" parent="account.next_id_40"/>
<record id="action_account_analytic_journal_tree2" model="ir.actions.act_window">
<field name="name">Analytic Entries by Journal</field>
<field name="res_model">account.analytic.journal</field>
@ -260,11 +261,11 @@
<field name="view_id" ref="view_account_analytic_journal_tree"/>
</record>
<menuitem action="action_account_analytic_journal_tree2" id="account_analytic_journal_entries" parent="account.next_id_41"/>
#
# Statistics
#
<record id="report_hr_timesheet_invoice_journal_form" model="ir.ui.view">
<field name="name">report.hr.timesheet.invoice.journal.form</field>
<field name="model">report.hr.timesheet.invoice.journal</field>
@ -277,8 +278,8 @@
</form>
</field>
</record>
<record id="report_hr_timesheet_invoice_journal_tree" model="ir.ui.view">
<field name="name">report.hr.timesheet.invoice.journal.tree</field>
<field name="model">report.hr.timesheet.invoice.journal</field>
@ -294,7 +295,7 @@
</tree>
</field>
</record>
<record id="report_hr_timesheet_invoice_journal_graph" model="ir.ui.view">
<field name="name">report.hr.timesheet.invoice.journal.graph</field>
<field name="model">report.hr.timesheet.invoice.journal</field>
@ -308,7 +309,7 @@
</graph>
</field>
</record>
<record id="report_account_analytic_journal_tree" model="ir.actions.act_window">
<field name="name">Account cost and revenue by journal</field>
<field name="res_model">report.hr.timesheet.invoice.journal</field>
@ -316,7 +317,7 @@
<field name="view_mode">tree,graph</field>
</record>
<menuitem id="next_id_42" name="All Months" parent="account.next_id_40"/><menuitem action="report_account_analytic_journal_tree" id="report_account_analytic_journal_print" parent="next_id_42"/>
<record id="report_account_analytic_journal_tree_month" model="ir.actions.act_window">
<field name="name">Account cost and revenue by journal (This Month)</field>
<field name="res_model">report.hr.timesheet.invoice.journal</field>
@ -325,11 +326,23 @@
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
</record>
<menuitem id="next_id_43" name="This Month" parent="account.next_id_40"/><menuitem action="report_account_analytic_journal_tree_month" id="report_account_analytic_journal_print_month" parent="next_id_43"/>
<act_window domain="[('account_id', '=', active_id)]" id="act_acc_analytic_acc_5_report_hr_timesheet_invoice_journal" name="All Analytic Entries" res_model="account.analytic.line" src_model="account.analytic.account" view_mode="tree,form" view_type="form"/>
<act_window domain="[('account_id', '=', active_id)]" id="act_acc_analytic_acc_2_report_hr_timesheet_invoice_journal" name="Costs &amp; Revenues" res_model="report.hr.timesheet.invoice.journal" src_model="account.analytic.account" view_mode="graph,tree,form" view_type="form"/>
<record id="view_account_journal_1" model="ir.ui.view">
<field name="name">account.journal.form.1</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="currency" position="after">
<field name="analytic_journal_id"/>
</field>
</field>
</record>
</data>
</terp>

View File

@ -61,7 +61,11 @@ import wizard_account_chart
import wizard_move_line_select
import wizard_validate_account_move
import wizard_use_model# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import wizard_use_model
import wizard_state_open
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -42,7 +42,7 @@ dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
}
class wizard_report(wizard.interface):

View File

@ -58,7 +58,7 @@ _aged_trial_fields = {
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
'sorting_on':{'string': 'Sorting On', 'type': 'selection', 'selection': [('partner','By Partner Name (asc)'), ('amount','By Amount (desc)')],'required': True, 'default': lambda *a:'partner'},
'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"},
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
}
def _calc_dates(self, cr, uid, data, context):

View File

@ -42,7 +42,7 @@ dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
}
class wizard_report(wizard.interface):

View File

@ -52,7 +52,10 @@ class wizard_move_line_select(wizard.interface):
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_tree1')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
result['context'] = str({'fiscalyear': context.get('fiscalyear', False)})
result['context'] = {
'fiscalyear': context.get('fiscalyear', False),
'account_id': data['id']
}
result['domain']=result['domain'][0:-1]+','+domain+result['domain'][-1]
return result

View File

@ -50,7 +50,7 @@ dates_fields = {
'help': 'Keep empty for all open fiscal year'},
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
}
class wizard_report(wizard.interface):

View File

@ -68,6 +68,13 @@ def _pay_and_reconcile(self, cr, uid, data, context):
ctx = {'date':data['form']['date']}
amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
# Take the choosen date
if form.has_key('comment'):
context={'date_p':form['date'],'comment':form['comment']}
else:
context={'date_p':form['date'],'comment':False}
acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
if not acc_id:
raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.'))
@ -80,7 +87,9 @@ def _wo_check(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
if invoice.company_id.currency_id.id<>journal.currency.id:
if invoice.company_id.currency_id.id <> invoice.currency_id.id:
return 'addendum'
if journal.currency and (journal.currency.id <> invoice.currency_id.id):
return 'addendum'
if pool.get('res.currency').is_zero(cr, uid, invoice.currency_id,
(data['form']['amount'] - invoice.amount_total)):
@ -92,11 +101,13 @@ _transaction_add_form = '''<?xml version="1.0"?>
<separator string="Write-Off Move" colspan="4"/>
<field name="writeoff_acc_id"/>
<field name="writeoff_journal_id"/>
<field name="comment"/>
</form>'''
_transaction_add_fields = {
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'comment': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
}
def _get_value_addendum(self, cr, uid, data, context={}):

View File

@ -0,0 +1,64 @@
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# #
# 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
import netsvc
form = '''<?xml version="1.0"?>
<form string="Open Invoice">
<label string="Are you sure you want to open this invoice ?"/>
<newline/>
<label string="(Invoice should be unreconciled if you want to open it)"/>
</form>'''
fields = {
}
def _change_inv_state(self, cr, uid, data, context):
pool_obj = pooler.get_pool(cr.dbname)
data_inv = pool_obj.get('account.invoice').browse(cr, uid, data['ids'][0])
if data_inv.reconciled:
raise wizard.except_wizard('Warning', 'Invoice is already reconciled')
wf_service = netsvc.LocalService("workflow")
res = wf_service.trg_validate(uid, 'account.invoice', data['ids'][0], 'open_test', cr)
return {}
class wiz_state_open(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('yes','Yes'),('end','No')]}
},
'yes': {
'actions': [_change_inv_state],
'result': {'type':'state', 'state':'end'}
}
}
wiz_state_open('account.wizard_paid_open')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -49,7 +49,7 @@ dates_fields = {
'help': 'Keep empty for all open fiscal year'},
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
}
class wizard_report(wizard.interface):

View File

@ -1,9 +1,8 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
# 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
@ -25,19 +24,11 @@
# 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.
###############################################################################
{
"name" : "Multi company base module",
"version" : "0.1",
"author" : "Tiny",
"depends" : ["base"],
"category" : "Generic Modules/Base",
"init_xml" : [],
"demo_xml" : ["multi_company_demo.xml",],
"update_xml" : [],
"active": False,
"installable": True
}
#
##############################################################################
import account_analytic_plans
import wizard
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,48 @@
# -*- encoding: utf-8 -*-
{
"name" : "Multiple-plans management in analytic accounting",
"version" : "1.0",
"depends" : ["account", "base","product_analytic_default"],
"author" : "Tiny",
"description": """The goal is to allow several analytic plans, according to the general journal,
so that multiple analytic lines are created when the invoice is confirmed.
Second goal is to allow creating automatic analytic entries when writing general entries manually
through: Finance > Entries > By Journal.
For example, the analytic structure:
Projects
»···Project 1
»···»···SubProj 1.1
»···»···SubProj 1.2
»···Project 2
Salesman
»···Eric
»···Fabien
Here, we have two plans: Projects and Salesman. An invoice line must
be able to write analytic entries in the 2 plans: SubProj 1.1 and
Fabien. The amount can also be splitted, example:
Plan1:
SubProject 1.1 : 50%
SubProject 1.2 : 50%
Plan2:
Eric: 100%
So when this line of invoice will be confirmed, It must generate 3
analytic lines.
""",
"website" : "http://tinyerp.com/module_account.html",
"category" : "Generic Modules/Accounting",
"init_xml" : [
],
"demo_xml" : [
],
"update_xml" : ["model_wizard.xml","account_analytic_plans_view.xml",
"account_analytic_plans_report.xml"],
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,397 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# 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 xml import dom
from mx import DateTime
from mx.DateTime import now
import time
import netsvc
from osv import fields, osv,orm
import ir
import tools
class one2many_mod2(fields.one2many):
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
if not context:
context = {}
res = {}
for id in ids:
res[id] = []
ids2 = None
if 'journal_id' in context:
journal = obj.pool.get('account.journal').browse(cr, user, context['journal_id'], context)
pnum = int(name[7]) -1
plan = journal.plan_id
if plan and len(plan.plan_ids)>pnum:
acc_id = plan.plan_ids[pnum].root_analytic_id.id
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids),('analytic_account_id','child_of',[acc_id])], limit=self._limit)
if ids2 is None:
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids)], limit=self._limit)
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
res[r[self._fields_id]].append( r['id'] )
return res
class account_analytic_plan(osv.osv):
_name = "account.analytic.plan"
_description = "Analytic Plans"
_columns = {
'name': fields.char('Analytic Plan', size=64, required=True, select=True,),
'plan_ids': fields.one2many('account.analytic.plan.line','plan_id','Analytic Plans'),
}
account_analytic_plan()
class account_analytic_plan_line(osv.osv):
_name = "account.analytic.plan.line"
_description = "Analytic Plan Lines"
_columns = {
'plan_id':fields.many2one('account.analytic.plan','Analytic Plan'),
'name': fields.char('Plan Name', size=64, required=True, select=True),
'sequence':fields.integer('Sequence'),
'root_analytic_id': fields.many2one('account.analytic.account','Root Account',help="Root account of this plan.",required=True),
'min_required': fields.float('Minimum Allowed (%)'),
'max_required': fields.float('Maximum Allowed (%)'),
}
_defaults = {
'min_required': lambda *args: 100.0,
'max_required': lambda *args: 100.0,
}
_order = "sequence,id"
account_analytic_plan_line()
class account_analytic_plan_instance(osv.osv):
_name='account.analytic.plan.instance'
_description = 'Object for create analytic entries from invoice lines'
_columns={
'name':fields.char('Analytic Distribution',size=64),
'code':fields.char('Distribution Code',size=16),
'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True),
'account_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account Id'),
'account1_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account1 Id'),
'account2_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account2 Id'),
'account3_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account3 Id'),
'account4_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account4 Id'),
'account5_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account5 Id'),
'account6_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account6 Id'),
'plan_id':fields.many2one('account.analytic.plan', "Model's Plan"),
}
def copy(self, cr, uid, id, default=None, context=None):
if not default:
default = {}
default.update({'account1_ids':False, 'account2_ids':False, 'account3_ids':False,
'account4_ids':False, 'account5_ids':False, 'account6_ids':False})
return super(account_analytic_plan_instance, self).copy(cr, uid, id, default, context)
_defaults = {
'plan_id': lambda *args: False,
}
def name_get(self, cr, uid, ids, context={}):
res = []
for inst in self.browse(cr, uid, ids, context):
name = inst.name or '/'
if name and inst.code:
name=name+' ('+inst.code+')'
res.append((inst.id, name))
return res
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=80):
args= args or []
if name:
ids = self.search(cr, uid, [('code', '=', name)] + args, limit=limit, context=context or {})
if not ids:
ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context or {})
else:
ids = self.search(cr, uid, args, limit=limit, context=context or {})
return self.name_get(cr, uid, ids, context or {})
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False):
wiz_id = self.pool.get('ir.actions.wizard').search(cr, uid, [("wiz_name","=","create.model")])
res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar)
if (res['type']=='form'):
plan_id = False
if context.get('journal_id',False):
plan_id = self.pool.get('account.journal').browse(cr, uid, int(context['journal_id']), context).plan_id
elif context.get('plan_id',False):
plan_id = self.pool.get('account.analytic.plan').browse(cr, uid, int(context['plan_id']), context).plan_id
if plan_id:
i=1
res['arch'] = """<form string="%s">
<field name="name"/>
<field name="code"/>
<field name="journal_id"/>
<button name="%d" string="Save This Distribution as a Model" type="action" colspan="2"/>
"""% (tools.to_xml(plan_id.name), wiz_id[0])
for line in plan_id.plan_ids:
res['arch']+="""
<field name="account%d_ids" string="%s" colspan="4">
<tree string="%s" editable="bottom">
<field name="rate"/>
<field name="analytic_account_id" domain="[('parent_id','child_of',[%d])]"/>
</tree>
</field>
<newline/>"""%(i,tools.to_xml(line.name),tools.to_xml(line.name),line.root_analytic_id and line.root_analytic_id.id or 0)
i+=1
res['arch'] += "</form>"
doc = dom.minidom.parseString(res['arch'])
xarch, xfields = self._view_look_dom_arch(cr, uid, doc, context=context)
res['arch'] = xarch
res['fields'] = xfields
return res
else:
return res
def create(self, cr, uid, vals, context=None):
if context and 'journal_id' in context:
journal= self.pool.get('account.journal').browse(cr,uid,context['journal_id'])
pids = self.pool.get('account.analytic.plan.instance').search(cr, uid, [('name','=',vals['name']),('code','=',vals['code']),('plan_id','<>',False)])
if pids:
raise osv.except_osv('Error', 'A model having this name and code already exists !')
res = self.pool.get('account.analytic.plan.line').search(cr,uid,[('plan_id','=',journal.plan_id.id)])
for i in res:
total_per_plan = 0
item = self.pool.get('account.analytic.plan.line').browse(cr,uid,i)
temp_list=['account1_ids','account2_ids','account3_ids','account4_ids','account5_ids','account6_ids']
for l in temp_list:
if vals.has_key(l):
for tempo in vals[l]:
if self.pool.get('account.analytic.account').search(cr,uid,[('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]):
total_per_plan += tempo[2]['rate']
if total_per_plan < item.min_required or total_per_plan > item.max_required:
raise osv.except_osv("Value Error" ,"The Total Should be Between " + str(item.min_required) + " and " + str(item.max_required))
return super(account_analytic_plan_instance, self).create(cr, uid, vals, context)
def write(self, cr, uid, ids, vals, context={}, check=True, update_check=True):
this = self.browse(cr,uid,ids[0])
if this.plan_id and not vals.has_key('plan_id'):
#this instance is a model, so we have to create a new plan instance instead of modifying it
#copy the existing model
temp_id = self.copy(cr, uid, this.id, None, context)
#get the list of the invoice line that were linked to the model
list = self.pool.get('account.invoice.line').search(cr,uid,[('analytics_id','=',this.id)])
#make them link to the copy
self.pool.get('account.invoice.line').write(cr, uid, list, {'analytics_id':temp_id}, context)
#and finally modify the old model to be not a model anymore
vals['plan_id'] = False
if not vals.has_key['name']:
vals['name'] = this.name+'*'
if not vals.has_key['code']:
vals['code'] = this.code+'*'
return self.write(cr, uid, [this.id],vals, context)
else:
#this plan instance isn't a model, so a simple write is fine
return super(account_analytic_plan_instance, self).write(cr, uid, ids, vals, context)
account_analytic_plan_instance()
class account_analytic_plan_instance_line(osv.osv):
_name='account.analytic.plan.instance.line'
_description = 'Object for create analytic entries from invoice lines'
_columns={
'plan_id':fields.many2one('account.analytic.plan.instance','Plan Id'),
'analytic_account_id':fields.many2one('account.analytic.account','Analytic Account', required=True),
'rate':fields.float('Rate (%)', required=True),
}
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
return []
reads = self.read(cr, uid, ids, ['analytic_account_id'], context)
res = []
for record in reads:
res.append((record['id'], record['analytic_account_id']))
return res
account_analytic_plan_instance_line()
class account_journal(osv.osv):
_inherit='account.journal'
_name='account.journal'
_columns = {
'plan_id':fields.many2one('account.analytic.plan','Analytic Plans'),
}
account_journal()
class account_invoice_line(osv.osv):
_inherit='account.invoice.line'
_name='account.invoice.line'
_columns = {
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'),
}
def create(self, cr, uid, vals, context=None):
if 'analytics_id' in vals and isinstance(vals['analytics_id'],tuple):
vals['analytics_id'] = vals['analytics_id'][0]
return super(account_invoice_line, self).create(cr, uid, vals, context)
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 ['analytics_id']=line.analytics_id and line.analytics_id.id or False
return res
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, context={}):
res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, price_unit, address_invoice_id, context)
if product:
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
res_prod['value'].update({'analytics_id':res.property_account_distribution.id})
return res_prod
account_invoice_line()
class account_move_line(osv.osv):
_inherit='account.move.line'
_name='account.move.line'
_columns = {
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'),
}
# def _analytic_update(self, cr, uid, ids, context):
# for line in self.browse(cr, uid, ids, context):
# if line.analytics_id:
# print "line.analytics_id",line,"now",line.analytics_id
# toremove = self.pool.get('account.analytic.line').search(cr, uid, [('move_id','=',line.id)], context=context)
# print "toremove",toremove
# if toremove:
# obj_line=self.pool.get('account.analytic.line')
# self.pool.get('account.analytic.line').unlink(cr, uid, toremove, context=context)
# for line2 in line.analytics_id.account_ids:
# val = (line.debit or 0.0) - (line.credit or 0.0)
# amt=val * (line2.rate/100)
# al_vals={
# 'name': line.name,
# 'date': line.date,
# 'unit_amount':1,
# 'product_id':12,
# 'account_id': line2.analytic_account_id.id,
# 'amount': amt,
# 'general_account_id': line.account_id.id,
# 'move_id': line.id,
# 'journal_id': line.analytics_id.journal_id.id,
# 'ref': line.ref,
# }
# ali_id=self.pool.get('account.analytic.line').create(cr,uid,al_vals)
# return True
#
# def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
# result = super(account_move_line, self).write(cr, uid, ids, vals, context, check, update_check)
# self._analytic_update(cr, uid, ids, context)
# return result
#
# def create(self, cr, uid, vals, context=None, check=True):
# result = super(account_move_line, self).create(cr, uid, vals, context, check)
# self._analytic_update(cr, uid, [result], context)
# return result
account_move_line()
class account_invoice(osv.osv):
_name = "account.invoice"
_inherit="account.invoice"
def line_get_convert(self, cr, uid, x, part, date, context={}):
res=super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context)
res['analytics_id']=x.get('analytics_id',False)
return res
def _get_analityc_lines(self, cr, uid, id):
inv = self.browse(cr, uid, [id])[0]
cur_obj = self.pool.get('res.currency')
company_currency = inv.company_id.currency_id.id
if inv.type in ('out_invoice', 'in_refund'):
sign = 1
else:
sign = -1
iml = self.pool.get('account.invoice.line').move_line_get(cr, uid, inv.id)
for il in iml:
if il['analytics_id']:
if inv.type in ('in_invoice', 'in_refund'):
ref = inv.reference
else:
ref = self._convert_ref(cr, uid, inv.number)
obj_move_line=self.pool.get('account.analytic.plan.instance').browse(cr,uid,il['analytics_id'])
amount_calc=cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, il['price'], context={'date': inv.date_invoice}) * sign
qty=il['quantity']
il['analytic_lines']=[]
for line2 in obj_move_line.account_ids:
amt=amount_calc * (line2.rate/100)
qtty=qty* (line2.rate/100)
al_vals={
'name': il['name'],
'date': inv['date_invoice'],
'unit_amount':qtty,
'product_id':il['product_id'],
'account_id': line2.analytic_account_id.id,
'amount': amt,
'product_uom_id': il['uos_id'],
'general_account_id': il['account_id'],
'journal_id': self._get_journal_analytic(cr, uid, inv.type),
'ref': ref,
}
il['analytic_lines'].append((0,0,al_vals))
return iml
account_invoice()
class account_analytic_plan(osv.osv):
_inherit = "account.analytic.plan"
_columns = {
'default_instance_id': fields.many2one('account.analytic.plan.instance', 'Default Entries'),
}
account_analytic_plan()
class product_product(osv.osv):
_name = 'product.product'
_inherit = 'product.product'
_description = 'Product'
_columns = {
'property_account_distribution': fields.property(
'account.analytic.plan.instance',
type='many2one',
relation='account.analytic.plan.instance',
string="Analytic Distribution",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This Analytic Distribution will be use in sale order line and invoice lines",
),
}
product_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<terp>
<data>
<report
id="account_analytic_account_crossovered_analytic"
string="Crossovered Analytic"
model="account.analytic.account"
name="account.analytic.account.crossovered.analytic"
rml="account_analytic_plans/report/crossovered_analytic.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_inverted_balance_report"
string="Crossovered Analytic"
model="account.analytic.account"
name="wizard.crossovered.analytic"
keyword="client_print_multi"/>
</data>
</terp>

View File

@ -0,0 +1,248 @@
<?xml version="1.0"?>
<terp>
<data>
<!-- Add plan_id after user_id in account.journal many2one with account.analytic.plan -->
<record model="ir.ui.view" id="view_account_journal_form_inherit">
<field name="name">account.journal.form.inherit</field>
<field name="model">account.journal</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="arch" type="xml">
<field name="centralisation" position="before">
<field name="plan_id" />
</field>
</field>
</record>
<record model="ir.ui.view" id="view_move_line_form_inherit">
<field name="name">account.move.line.form.inherit</field>
<field name="model">account.move.line</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_move_line_form"/>
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="analytics_id" />
</field>
</field>
</record>
<record model="ir.ui.view" id="view_move_line_tree_inherit">
<field name="name">account.move.line.tree.inherit</field>
<field name="model">account.move.line</field>
<field name="type">tree</field>
<field name="inherit_id" ref="account.view_move_line_tree"/>
<field name="arch" type="xml">
<field name="move_id" position="after">
<field name="analytics_id" />
</field>
</field>
</record>
<!-- Replace analytic_id with analytics_id in account.invoice.line -->
<record model="ir.ui.view" id="view_invoice_line_form_inherit">
<field name="name">account.invoice.line.form.inherit</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="account_analytic_id" position="replace">
<field name="analytics_id" context="{'journal_id':parent.journal_id}" domain="[('plan_id','&lt;&gt;',False)]"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="invoice_supplier_form_inherit">
<field name="name">account.invoice.supplier.form.inherit</field>
<field name="model">account.invoice</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="priority">2</field>
<field name="arch" type="xml">
<field name="account_analytic_id" position="replace">
<field name="analytics_id" domain="[('plan_id','&lt;&gt;',False)]" context="{'journal_id':parent.journal_id}" />
</field>
</field>
</record>
<record model="ir.ui.view" id="account_analytic_plan_instance_form">
<field name="name">account.analytic.plan.instance.form</field>
<field name="model">account.analytic.plan.instance</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Distribution">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="plan_id" select="2" required="True"/>
<field name="journal_id" select="2"/>
<field name="account_ids" string="Analytic Distribution" colspan="4">
<tree string="Analytic Distribution" editable="bottom">
<field name="rate"/>
<field name="analytic_account_id"/>
</tree>
</field>
</form>
</field>
</record>
<record model="ir.ui.view" id="account_analytic_plan_instance_tree">
<field name="name">account.analytic.plan.instance.tree</field>
<field name="model">account.analytic.plan.instance</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Distribution">
<field name="name"/>
<field name="code"/>
<field name="plan_id"/>
<field name="journal_id"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="account_analytic_plan_instance_action">
<field name="name">Analytic Distribution's Models</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.analytic.plan.instance</field>
<field name="domain">[('plan_id','&lt;&gt;',False)]</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<act_window name="Distribution Models"
domain="[('plan_id', '=', active_id),('plan_id','&lt;&gt;',False)]"
context="{'plan_id': active_id}"
res_model="account.analytic.instance"
src_model="account.analytic.plan"
id="account_analytic_instance_model_open"/>
<menuitem
name="Analytic Distribution's models" parent="account.next_id_32"
id="menu_account_analytic_plan_instance_action"
action="account_analytic_plan_instance_action"/>
<record model="ir.ui.view" id="account_analytic_plan_instance_line_form">
<field name="name">account.analytic.plan.instance.line.form</field>
<field name="model">account.analytic.plan.instance.line</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Distribution Line">
<field name="plan_id"/>
<field name="analytic_account_id"/>
<field name="rate"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="account_analytic_plan_instance_line_tree">
<field name="name">account.analytic.plan.instance.line.tree</field>
<field name="model">account.analytic.plan.instance.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Distribution Lines">
<field name="plan_id" select="1"/>
<field name="analytic_account_id" select="1"/>
<field name="rate"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="account_analytic_plan_form">
<field name="name">account.analytic.plan.form</field>
<field name="model">account.analytic.plan</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Plan">
<field name="name" select="1"/>
<field name="default_instance_id"/>
<field name="plan_ids" colspan="4"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="account_analytic_plan_tree">
<field name="name">account.analytic.plan.tree</field>
<field name="model">account.analytic.plan</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Plans">
<field name="name"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="account_analytic_plan_form_action">
<field name="name">Analytic Plan</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.analytic.plan</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
parent="account.next_id_39"
id="menu_account_analytic_plan_action"
action="account_analytic_plan_form_action"/>
<record model="ir.ui.view" id="account_analytic_plan_line_form">
<field name="name">account.analytic.plan.line.form</field>
<field name="model">account.analytic.plan.line</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Plan Line">
<field name="name"/>
<field name="sequence"/>
<field name="root_analytic_id"/>
<newline/>
<field name="min_required"/>
<field name="max_required"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="account_analytic_plan_line_tree">
<field name="name">account.analytic.plan.line.tree</field>
<field name="model">account.analytic.plan.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Plan Lines">
<field name="name" select="1"/>
<field name="sequence"/>
<field name="root_analytic_id" select="2"/>
<field name="min_required"/>
<field name="max_required"/>
</tree>
</field>
</record>
<!-- add property field on product -->
<record model="ir.ui.view" id="view_template_property_distribution_form">
<field name="name">product.template.property.distribution.form.inherit</field>
<field name="type">form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="property_account_analytic" position="replace">
<field name="property_account_distribution"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_normal_property_distribution_form">
<field name="name">product.normal.property.distribution.form.inherit</field>
<field name="type">form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="property_account_analytic" position="replace">
<field name="property_account_distribution"/>
</field>
</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<terp>
<data>
<wizard
string="Create Model"
model="account.analytic.plan.instance"
name="create.model" id="create_model"
menu="False"/>
</data>
</terp>

View File

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
import crossovered_analytic
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,183 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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 pooler
import time
from report import report_sxw
class crossovered_analytic(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(crossovered_analytic, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self._lines,
'ref_lines' : self._ref_lines,
'find_children':self.find_children,
})
self.base_amount=0.00
def find_children(self,ref_ids):
to_return_ids = []
final_list = []
parent_list = []
set_list = []
for id in ref_ids:
# to avoid duplicate entries
if id not in to_return_ids:
to_return_ids.append(self.pool.get('account.analytic.account').search(self.cr,self.uid,[('parent_id','child_of',[id])]))
data_accnt = self.pool.get('account.analytic.account').browse(self.cr,self.uid,to_return_ids[0])
for data in data_accnt:
if data.parent_id and data.parent_id.id == ref_ids[0]:
parent_list.append(data.id)
final_list.append(ref_ids[0])
set_list = self.set_account(parent_list)
final_list.extend(set_list)
return final_list #to_return_ids[0]
def set_account(self,cats):
lst = []
category = self.pool.get('account.analytic.account').read(self.cr,self.uid,cats)
for cat in category:
lst.append(cat['id'])
if cat['child_ids']:
lst.extend(self.set_account(cat['child_ids']))
return lst
def _ref_lines(self,form):
result = []
res = {}
acc_id = []
final = []
acc_pool = self.pool.get('account.analytic.account')
line_pool = self.pool.get('account.analytic.line')
self.dict_acc_ref = {}
if form['journal_ids'][0][2]:
journal = " in (" + ','.join(map(lambda x: str(x), form['journal_ids'][0][2])) + ")"
else:
journal = 'is not null'
query_general = "select id from account_analytic_line where (journal_id " + journal +") AND date>='"+ str(form['date1']) +"'"" AND date<='" + str(form['date2']) + "'"
self.cr.execute(query_general)
l_ids=self.cr.fetchall()
line_ids = [x[0] for x in l_ids]
obj_line = line_pool.browse(self.cr,self.uid,line_ids)
#this structure will be usefull for easily knowing the account_analytic_line that are related to the reference account. At this purpose, we save the move_id of analytic lines.
self.dict_acc_ref[form['ref']] = []
children_list = self.pool.get('account.analytic.account').search(self.cr,self.uid,[('parent_id','child_of',[form['ref']])])
for obj in obj_line:
if obj.account_id.id in children_list:
if obj.move_id and obj.move_id.id not in self.dict_acc_ref[form['ref']]:
self.dict_acc_ref[form['ref']].append(obj.move_id.id)
res['ref_name'] = acc_pool.name_get(self.cr,self.uid,[form['ref']])[0][1]
res['ref_code'] = acc_pool.browse(self.cr,self.uid,form['ref']).code
self.final_list = children_list
selected_ids = line_pool.search(self.cr,self.uid,[('account_id','in',self.final_list)])
query="SELECT sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \
WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"
self.cr.execute(query)
info=self.cr.dictfetchall()
res['ref_qty']=info[0]['qty']
res['ref_amt']=info[0]['amt']
self.base_amount= info[0]['amt']
result.append(res)
return result
def _lines(self,form,ids={}):
if not ids:
ids = self.ids
if form['journal_ids'][0][2]:
journal=" in (" + ','.join(map(lambda x: str(x), form['journal_ids'][0][2])) + ")"
else:
journal= 'is not null'
acc_pool = self.pool.get('account.analytic.account')
line_pool=self.pool.get('account.analytic.line')
acc_id=[]
final=[]
child_ids=[]
self.list_ids=[]
self.final_list = self.find_children(ids)
for acc_id in self.final_list:
selected_ids = line_pool.search(self.cr,self.uid,[('account_id','=',acc_id),('move_id','in',self.dict_acc_ref[form['ref']])])
if selected_ids:
query="SELECT aaa.code as code , sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty,aaa.name as acc_name,aal.account_id as id FROM account_analytic_line AS aal, account_analytic_account AS aaa \
WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"" GROUP BY aal.account_id,aaa.name,aaa.code ORDER BY aal.account_id"
self.cr.execute(query)
res = self.cr.dictfetchall()
if res:
for element in res:
if self.base_amount<>0.00:
element['perc']= (element['amt'] / self.base_amount) * 100.00
else:
element['perc']=0.00
else:
result={}
res=[]
result['id']=acc_id
data_account = acc_pool.browse(self.cr,self.uid,acc_id)
result['acc_name']=data_account.name
result['code'] = data_account.code
result['amt']=result['qty']=result['perc']=0.00
if not form['empty_line']:
res.append(result)
else:
result={}
res=[]
result['id']=acc_id
data_account = acc_pool.browse(self.cr,self.uid,acc_id)
result['acc_name']=data_account.name
result['code'] = data_account.code
result['amt']=result['qty']=result['perc']=0.00
if not form['empty_line']:
res.append(result)
for item in res:
obj_acc=acc_pool.name_get(self.cr,self.uid,[item['id']])
item['acc_name']=obj_acc[0][1]
final.append(item)
return final
report_sxw.report_sxw('report.account.analytic.account.crossovered.analytic', 'account.analytic.account', 'addons/account_analytic_plans/report/crossovered_analytic.rml',parser=crossovered_analytic, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,222 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="34.0" y1="28.0" width="527" height="786"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#cccccc" start="0,0" stop="0,0"/>
<blockBackground colorName="#cccccc" start="1,0" stop="1,0"/>
<blockBackground colorName="#cccccc" start="2,0" stop="2,0"/>
<blockBackground colorName="#cccccc" start="3,0" stop="3,0"/>
<blockBackground colorName="#cccccc" start="4,0" stop="4,0"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#cccccc" start="0,0" stop="0,0"/>
<blockBackground colorName="#cccccc" start="1,0" stop="1,0"/>
<blockBackground colorName="#cccccc" start="2,0" stop="2,0"/>
<blockBackground colorName="#cccccc" start="3,0" stop="3,0"/>
<blockBackground colorName="#cccccc" start="4,0" stop="4,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Bold" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Bold" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="176.0,176.0,176.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P8">Crossovered Analytic</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
<para style="P10">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P7">[[ company.name ]]</para>
</td>
<td>
<para style="P11">Period from [[ data['form']['date1'] ]]</para>
<para style="P11">to [[ data['form']['date2'] ]]</para>
</td>
<td>
<para style="P10">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P1">
<font color="white"> </font>
</para>
<para style="P4">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">Analytic Account Reference:</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="152.0,123.0,90.0,63.0,99.0" style="Table3">
<tr>
<td>
<para style="P13">Account Name</para>
</td>
<td>
<para style="P13">Code</para>
</td>
<td>
<para style="P13">Quantity</para>
</td>
<td>
<para style="P13">Amount</para>
</td>
<td>
<para style="P13">Percentage</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="152.0,123.0,90.0,63.0,100.0" style="Table4">
<tr>
<td>
<para style="P14">[[ repeatIn(ref_lines(data['form']),'a') ]]<font face="Times-Roman" size="10.0">[[ a['ref_name'] ]]</font></para>
</td>
<td>
<para style="P12">[[ a['ref_code'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % a['ref_qty'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % a['ref_amt'] ]]</para>
</td>
<td>
<para style="P12">100.00%</para>
</td>
</tr>
</blockTable>
<para style="P4">
<font color="white"> </font>
</para>
<para style="P4">
<font color="white"> </font>
</para>
<para style="P3">
<font color="white"> </font>
</para>
<para style="P3">
<font color="white"> </font>
</para>
<blockTable colWidths="152.0,123.0,89.0,64.0,99.0" style="Table1">
<tr>
<td>
<para style="P13">Account Name</para>
</td>
<td>
<para style="P13">Code</para>
</td>
<td>
<para style="P13">Quantity</para>
</td>
<td>
<para style="P13">Amount</para>
</td>
<td>
<para style="P13">Percentage</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="152.0,123.0,89.0,64.0,99.0" style="Table2">
<tr>
<td>
<para style="P15">[[ repeatIn(lines(data['form']),'a') ]] </para>
<para style="P15">[[a['acc_name'] ]]</para>
</td>
<td>
<para style="P12">[[ a['code'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % a['qty'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % a['amt'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % a['perc'] ]]%</para>
</td>
</tr>
</blockTable>
<para style="P2">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,5 @@
# -*- encoding: utf-8 -*-
import create_model
import wizard_crossovered_analytic
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,47 @@
# -*- encoding: utf-8 -*-
import wizard
import time
import netsvc
import pooler
info = '''<?xml version="1.0"?>
<form string="Distribution Model Saved">
<label string="This distribution model has been saved.\nYou will be able to reuse it later."/>
</form>'''
def activate(self, cr, uid, data, context):
plan_obj = pooler.get_pool(cr.dbname).get('account.analytic.plan.instance')
if data['id']:
plan = plan_obj.browse(cr, uid, data['id'], context)
if (not plan.name) or (not plan.code):
raise wizard.except_wizard('Error', 'Please put a name and a code before saving the model !')
pids = pooler.get_pool(cr.dbname).get('account.analytic.plan').search(cr, uid, [], context=context)
if (not pids):
raise wizard.except_wizard('Error', 'No analytic plan defined !')
plan_obj.write(cr,uid,[data['id']],{'plan_id':pids[0]})
return 'info'
else:
return 'endit'
class create_model(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'choice','next_state':activate}
},
'info': {
'actions': [],
'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','OK')]}
},
'endit': {
'actions': [],
'result': {'type':'form', 'arch':'', 'fields':{}, 'state':'end'}
},
}
create_model('create.model')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,59 @@
# -*- encoding: utf-8 -*-
import wizard
import time
import datetime
import pooler
form = """<?xml version="1.0"?>
<form string="Select Information">
<field name="date1"/>
<field name="date2"/>
<field name="ref" colspan="4"/>
<field name="journal_ids" colspan="4"/>
<field name="empty_line"/>
</form>"""
fields = {
'date1': {'string':'Start Date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End Date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'journal_ids': {'string':'Analytic Journal', 'type':'many2many', 'relation':'account.analytic.journal'},
'ref' :{'string':'Analytic Account Ref.', 'type':'many2one', 'relation':'account.analytic.account','required':True},
'empty_line': {'string':'Dont show empty lines', 'type':'boolean', 'default': lambda *a:False},
}
class wizard_crossovered_analytic(wizard.interface):
def _checklines(self, cr, uid, data, context):
cr.execute('select account_id from account_analytic_line')
res=cr.fetchall()
acc_ids=[x[0] for x in res]
obj_acc = pooler.get_pool(cr.dbname).get('account.analytic.account').browse(cr,uid,data['form']['ref'])
name=obj_acc.name
account_ids = pooler.get_pool(cr.dbname).get('account.analytic.account').search(cr, uid, [('parent_id', 'child_of', [data['form']['ref']])])
flag = True
for acc in account_ids:
if acc in acc_ids:
flag = False
break
if flag:
raise wizard.except_wizard('User Error',"There are no Analytic lines related to Account '" + name +"'" )
return {}
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancel'),('print','Print')]},
},
'print': {
'actions': [_checklines],
'result': {'type':'print', 'report':'account.analytic.account.crossovered.analytic', 'state':'end'},
},
}
wizard_crossovered_analytic('wizard.crossovered.analytic')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,7 @@
# -*- encoding: utf-8 -*-
import account
import account_move_line
import wizard
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
{
"name" : "Accounting and financial management-Compare Accounts",
"version" : "1.1",
"depends" : ["account"],
"author" : "Tiny",
"description": """Account Balance Module is an added functionality to the Financial Management module.
This module gives you the various options for printing balance sheet.
1. You can compare the balance sheet for different years.
2. You can set the cash or percentage comparision between two years.
3. You can set the referencial account for the percentage comparision for particular years.
4. You can select periods as an actual date or periods as creation date.
5. You have an option to print the desired report in Landscape format.
""",
"website" : "http://tinyerp.com/account_balance.html",
"category" : "Generic Modules/Accounting",
"init_xml" : [
],
"demo_xml" : [],
"update_xml" : ["account_report.xml","account_wizard.xml",],
# "translations" : {
# "fr": "i18n/french_fr.csv"
# },
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,93 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# 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 time
import netsvc
from osv import fields, osv
class account_move_line(osv.osv):
_name="account.move.line"
_inherit="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, exception=False)
strQuery = ""
if context.get('periods', False):
ids = ','.join([str(x) for x in context['periods']])
if not 'period_manner' in context:
strQuery = obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id=%d)" % (context['fiscalyear'],)
else:
if context['period_manner']=='actual':
strQuery = obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id=%d AND id in (%s))" % (context['fiscalyear'], ids)
else:
# p_id="in (SELECT id from account_period WHERE fiscalyear_id=%d AND id in (%s)))" % (context['fiscalyear'], ids)
strQuery = obj+".active AND "+obj+".state<>'draft' AND("
p_id=self.pool.get('account.period').search(cr,uid,[('fiscalyear_id','=',context['fiscalyear']),('id','in',context['periods'])])
periods = self.pool.get('account.period').read(cr,uid,p_id,['date_start','date_stop'])
count=1
len_periods=len(p_id)
for period in periods:
strQuery += "("+obj+".create_date between to_date('" + period['date_start'] + "','yyyy-mm-dd') and to_date('" + period['date_stop'] + "','yyyy-mm-dd'))"
if len_periods!=1 and count!=len_periods:
strQuery+=" OR "
count=count+1
if p_id==[]:
strQuery+=obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id=%d))" % (context['fiscalyear'],)
else:
strQuery+=")"
else:
strQuery = obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id=%d)" % (context['fiscalyear'],)
return strQuery
account_move_line()
class account_bank_statement_reconcile(osv.osv):
_inherit = "account.bank.statement.reconcile"
_columns = {
'line_ids': fields.many2many('account.move.line', 'account_bank_statement_line_rel', 'statement_id', 'line_id', 'Entries'),
}
account_bank_statement_reconcile()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<terp>
<data>
<report id="account_account_balance"
string="Account balance"
model="account.account"
name="account.balance.account.balance"
rml="account_balance/report/account_balance.rml"
auto="False"
menu="False"/>
<report id="account_account_balance_landscape"
string="Account balance"
model="account.account"
name="account.account.balance.landscape"
rml="account_balance/report/account_balance_landscape.rml"
auto="False"
menu="False"/>
</data>
</terp>

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<terp>
<data>
<menuitem parent="account.menu_finance" icon="terp-account"/>
<wizard
string="Account balance-Compare Years"
model="account.account"
name="account.balance.account.balance.report"
keyword="client_print_multi"
id="wizard_account_balance_report"/>
</data>
</terp>

View File

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
import account_balance
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,598 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# 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 time
import locale
from report import report_sxw
#from addons.account.wizard import wizard_account_balance_report
parents = {
'tr':1,
'li':1,
'story': 0,
'section': 0
}
class account_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_balance, self).__init__(cr, uid, name, context)
self.flag=1
self.parent_bal=0
self.status=0
self.done_total=0
self.baldiv={}
self.empty_parent=0
self.result_total = {}
self.total_for_perc=[]
self.localcontext.update({
'time': time,
'lines': self.lines,
'linesForTotal': self.linesForTotal,
'linesForYear': self.linesForYear,
})
self.context = context
def repeatIn(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[]):
self._node.data = ''
node = self._find_parent(self._node, nodes_parent or parents)
ns = node.nextSibling
#start
if value==['Cash','%']:
if show==1:
if perc==1:
if pattern=='none':
value=['','Cash','%']
type=['lable','lable','lable']
width=[130,65,65]
else:
value=[' ','','Cash','%']
type=['string','lable','lable','lable']
width=[65,130,65,65]
else:
if pattern=='none':
value=['']
type=['lable']
width=[195]
else:
value=[' ','']
type=['string','lable']
width=[65,195]
else:
if perc==1:
if pattern=='none':
value=['Cash','%']
type=['lable','lable']
width=[65,65]
else:
value=[' ','Cash','%']
type=['string','lable','lable']
width=[65,65,65]
else:
if pattern=='none':
value=['']
type=['lable']
width=[65]
else:
value=[' ','']
type=['string','lable']
width=[65,65]
if value==['year']:
if show==1:
if perc==1:
if pattern=='none':
width=[260]
else:
value=[' ','year']
type=['string','string']
width=[65,260]
else:
if pattern=='none':
width=[195]
else:
value=[' ','year']
type=['string','string']
width=[65,195]
else:
if perc==1:
if pattern=='none':
width=[130]
else:
value=[' ','year']
type=['string','string']
width=[65,130]
else:
if pattern=='none':
width=[65]
else:
value=[' ','year']
type=['string','string']
width=[65,65]
if value==['Debit','Credit','Balance']:
if show==1:
if perc==1:
if pattern=='none':
width=[65,65,130]
else:
value=[' ','Debit','Credit','Balance']
type=['string','lable','lable','lable']
width=[65,65,65,130]
else:
if pattern=='none':
width=[65,65,65]
else:
value=[' ','Debit','Credit','Balance']
type=['string','lable','lable','lable']
width=[65,65,65,65]
else:
if perc==1:
if pattern=='none':
value=['Balance']
type=['lable']
width=[130]
else:
value=[' ','Balance']
type=['string','lable']
width=[65,130]
else:
if pattern=='none':
value=['Balance']
type=['lable']
width=[65]
else:
value=[' ','Balance']
type=['string','lable']
width=[65,65]
if value==['debit','credit','balance']:
if show==1:
if perc==1:
if pattern=='none':
value=['debit','credit','balance','balance_perc']
type=['string','string','string','string']
width=[65,65,65,65]
else:
value=[pattern,'debit','credit','balance','balance_perc']
type=['string','string','string','string','string']
width=[65,65,65,65,65]
else:
if pattern=='none':
value=['debit','credit','balance']
type=['string','string','string']
width=[65,65,65]
else:
value=[pattern,'debit','credit','balance']
type=['string','string','string','string']
width=[65,65,65,65]
else:
if perc==1:
if pattern=='none':
value=['balance','balance_perc']
type=['string','string']
width=[65,65]
else:
value=[pattern,'balance','balance_perc']
type=['string','string','string']
width=[65,65,65]
else:
if pattern=='none':
value=['balance']
type=['string']
width=[65]
else:
value=[pattern,'balance']
type=['string','string']
width=[65,65]
if value==['sum_debit','sum_credit','']:
if show==1:
if perc==1:
if pattern=='none':
width=[65,65,130]
else:
value=[' ','sum_debit','sum_credit','']
type=['string','string','string','lable']
width=[65,65,65,130]
else:
if pattern=='none':
width=[65,65,65]
else:
value=[' ','sum_debit','sum_credit','']
type=['string','string','string','lable']
width=[65,65,65,65]
else:
if perc==1:
if pattern=='none':
value=['']
type=['lable']
width=[130]
else:
value=[' ','']
type=['string','lable']
width=[65,130]
else:
if pattern=='none':
value=['']
type=['lable']
width=[65]
else:
value=[' ','']
type=['string','lable']
width=[65,65]
if not lst:
lst.append(1)
for ns in node.childNodes :
if ns and ns.nodeName!='#text' and ns.tagName=='blockTable' and td :
width_str = ns._attrs['colWidths'].nodeValue
ns.removeAttribute('colWidths')
total_td = td * len(value)
if not width:
for v in value:
width.append(30)
check1=0
for t in range(td):
for v in range(len(value)):
if type[v] in ('String','STRING','string'):
if (value[v]==" " or value[0]==pattern):
if check1==0:
check1=1
width_str +=',0.0'
else:
width_str +=',%d'%width[v]
else:
width_str +=',%d'%width[v]
else:
width_str +=',%d'%width[v]
ns.setAttribute('colWidths',width_str)
child_list = ns.childNodes
check=0
for child in child_list:
if child.nodeName=='tr':
lc = child.childNodes[1]
for t in range(td):
i=0
for v in value:
newnode = lc.cloneNode(1)
temp2="%s['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]]"%(name)
#
if type[i] in ('String','STRING','string'):
if (v==" " or v==pattern) and i==0 and check==0:
check=1
newnode.childNodes[1].lastChild.data=""
else:
if v==" ":
newnode.childNodes[1].lastChild.data=""
else:
t1= "[[ %s['%s%d'] ]]"%(name,v,t)
if v=="year" or v=="sum_debit" or v=="sum_credit":
newnode.childNodes[1].lastChild.data = t1
else:
newnode.childNodes[1].lastChild.data = t1+"[["+temp2
# newnode.childNodes[1].lastChild.data=[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]]
elif type[i] in ('Lable','LABLE','lable'):
newnode.childNodes[1].lastChild.data= v
child.appendChild(newnode)
newnode=False
i+=1
return super(account_balance,self).repeatIn(lst, name, nodes_parent=False)
#end
def linesForYear(self,form):
temp=0
years={}
global pattern
global show
global perc
global bal_zero
global ref_bal
pattern=form['compare_pattern']
if form['show_columns']!=1:
show=0
else:
show=form['show_columns']
if form['format_perc']!=1:
perc=0
else:
perc=form['format_perc']
if form['account_choice']=='bal_zero':
bal_zero=0
else:
bal_zero=1
ctx = self.context.copy()
if perc==1:
if form['select_account']!=False:
ref_ac=self.pool.get('account.account').browse(self.cr, self.uid,form['select_account'],ctx.copy())
if ref_ac.balance<>0.00:
ref_bal=ref_ac.balance
else:
ref_bal=1.00
else:
ref_bal='nothing'
else:
ref_bal='nothing'
total_for_perc=[]
# if perc==1:
self.done_total=1
self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1)
self.done_total=0
for t1 in range(0,len(form['fiscalyear'][0][2])):
locale.setlocale(locale.LC_ALL, '')
self.result_total["sum_credit" + str(t1)]=locale.format("%.2f", self.result_total["sum_credit" + str(t1)], grouping=True)
self.result_total["sum_debit" + str(t1)]=locale.format("%.2f", self.result_total["sum_debit" + str(t1)], grouping=True)
# self.flag=1
# self.result_total = {}
for temp in range(0,len(form['fiscalyear'][0][2])):
fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][0][2][temp])
years["year"+str(temp)]=fy[0][1][12:16]
return [years]
def linesForTotal(self,form,ids={},doneAccount={},level=1):
if self.done_total==1:
self.done_total==1
else:
return [self.result_total]
accounts=[]
if not ids:
ids = self.ids
if not ids:
return []
ctx = self.context.copy()
result_total_parent=[]
for id in form['fiscalyear'][0][2]:
tmp=[]
ctx['fiscalyear'] = id
ctx['periods'] = form['periods'][0][2]
ctx['period_manner']=form['select_periods']
tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy())
if len(tmp):
accounts.append(tmp)
merged_accounts=zip(*accounts)
# used to check for the frst record so all sum_credit and sum_debit r set to 0.00
if level==1:
doneAccount={}
for entry in merged_accounts:
if entry[0].id in doneAccount:
continue
doneAccount[entry[0].id] = 1
for k in range(0,len(entry)):
temp_credit=0.00
temp_debit=0.00
temp_credit+=entry[k].credit
temp_debit+=entry[k].debit
if self.flag==1:
self.result_total["sum_credit" + str(k)]=0.00
self.result_total["sum_debit" + str(k)]=0.00
if form['account_choice']=='bal_zero':
if temp_credit<>temp_debit:
self.result_total["sum_credit" + str(k)]+=temp_credit
self.result_total["sum_debit" + str(k)]+=temp_debit
else:
self.result_total["sum_credit" + str(k)]+=temp_credit
self.result_total["sum_debit" + str(k)]+=temp_debit
self.flag=2
if entry[0].child_id:
ids2 = [(x.code,x.id) for x in entry[0].child_id]
ids2.sort()
result_total_parent = self.linesForTotal(form, [x[1] for x in ids2],doneAccount,level+1)
return [self.result_total]
def lines(self, form, ids={}, done={}, level=1):
accounts=[]
if not ids:
ids = self.ids
if not ids:
return []
result = []
ctx = self.context.copy()
tmp1=[]
for id in form['fiscalyear'][0][2]:
ctx['fiscalyear'] = id
ctx['periods'] = form['periods'][0][2]
ctx['period_manner']=form['select_periods']
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy())
if len(tmp1):
accounts.append(tmp1)
if level==1: #if parent is called,done is not empty when called again.
done={}
def cmp_code(x, y):
return cmp(x.code, y.code)
for n in range(0,len(accounts)):
accounts[n].sort(cmp_code)
common={}
merged_accounts=zip(*accounts)
for entry in merged_accounts:
j=0
checked=1
if form['account_choice']!='all': # if checked,include empty a/c;not otherwise
checked=0
if entry[0].id in done:
continue
done[entry[0].id] = 1
if entry[0].child_id: # this is for parent account,dont check 0 for it
checked=4
self.status=1 # for displaying it Bold
else:
self.status=0
if checked==0:
i=0
for i in range(0,len(entry)):
if bal_zero==0:
if entry[i].balance<>0.0:
checked=4
break
else:
checked=3
i=i+1
else:
if entry[i].credit <> 0.0 or entry[i].debit <> 0.0:
checked=4
break
else:
checked=3
i=i+1
if checked==3:
# this is the point where we skip those accounts which are encountered as empty ones
continue
self.empty_parent=0
else:
self.empty_parent=1
res = {
'code': entry[0].code,
'name': entry[0].name,
'level': level,
'status': self.status,
}
for j in range(0,len(entry)):
locale.setlocale(locale.LC_ALL, '')
res["debit"+str(j)]=locale.format("%.2f", entry[j].debit, grouping=True)
res["credit"+str(j)]=locale.format("%.2f", entry[j].credit, grouping=True)
res["balance"+str(j)]=locale.format("%.2f", entry[j].balance, grouping=True)
if j==0:
res["bal_cash"+str(j)]="0.00"
res["bal_perc"+str(j)]="0.00%"
else:
temp_cash=entry[j].balance - entry[j-1].balance
res["bal_cash"+str(j)]=locale.format("%.2f", temp_cash, grouping=True)
if entry[j-1].balance<>0.00:
temp_perc=(entry[j].balance - entry[j-1].balance )*100/entry[j-1].balance
else:
temp_perc=(entry[j].balance) *100
res["bal_perc"+str(j)]=locale.format("%.2f", temp_perc) + "%"
if ref_bal=='nothing':
if level==1:
self.parent_bal=1
else:
self.parent_bal=0
if self.parent_bal==1:
res["balance_perc"+str(j)]="/"
else:
if entry[j].balance==0.00:
if self.baldiv["baldiv"+str(level-1)+str(j)]<>0.00:
res["balance_perc"+str(j)]="0.00%"
else:
res["balance_perc"+str(j)]="/"
else:
if self.baldiv["baldiv"+str(level-1)+str(j)]<>0.00:
temp=self.baldiv["baldiv"+str(level-1)+str(j)]
temp1=(entry[j].balance * 100 )/ float(temp)
temp1=round(temp1,2)
res["balance_perc" + str(j)]=str(temp1)+"%"
else:
res["balance_perc"+str(j)]="/"
else:
res["balance_perc"+str(j)]=str( (entry[j].balance * 100 )/ float(ref_bal)) + "%"
result.append(res)
if entry[0].child_id:
for q in range(0,len(form['fiscalyear'][0][2])):
self.baldiv["baldiv"+str(level)+str(q)]=entry[q].balance
ids2 = [(x.code,x.id) for x in entry[0].child_id]
ids2.sort()
dir=[]
dir += self.lines(form, [x[1] for x in ids2], done, level+1)
if dir==[]:
for w in range(0,len(form['fiscalyear'][0][2])):
if entry[w].credit <> 0.0 or entry[w].debit <> 0.0 or entry[w].balance<>0.00:
dont_pop=1
break
else:
dont_pop=0
if dont_pop==1:
result +=dir
else:
result.pop(-1) # here we pop up the parent having its children as emprty accounts
else:
result +=dir
return result
report_sxw.report_sxw('report.account.balance.account.balance', 'account.account', 'addons/account_balance/report/account_balance.rml', parser=account_balance, header=False)
report_sxw.report_sxw('report.account.account.balance.landscape', 'account.account', 'addons/account_balance/report/account_balance_landscape.rml', parser=account_balance, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,179 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(635.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="15.0" y1="15.0" width="615" height="772"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table61">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="red"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="12.0" leading="18" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" />
<paraStyle name="P4" fontName="Times-Roman" fontSize="9.0" alignment="CENTER"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="12" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Bold" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="1.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Account balance</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P8">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P13"> [[repeatIn(linesForYear(data['form']),'year_header',td=len(data['form']['fiscalyear'][0][2]),width=[126],value=['year'],type=['string']) ]]</para>
<blockTable colWidths="190.0" style="Table6">
<tr>
<td>
<para style="P1">Account Information</para>
</td>
</tr>
</blockTable>
</section>
<section>
<para style="P13">[[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['Debit','Credit','Balance'],type=['lable','lable','lable']) ]]</para>
<blockTable colWidths="30.0,160.0" style="Table6">
<tr>
<td>
<para style="P1">Code</para>
</td>
<td>
<para style="P1">Account Name</para>
</td>
</tr>
</blockTable>
</section>
<section>
<para style="P13">[[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[84,42],value=['Cash','%'],type=['lable','lable']) ]]</para>
<blockTable colWidths="190.0" style="Table5">
<tr>
<td>
<para style="P4"> </para>
</td>
</tr>
</blockTable>
</section>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ repeatIn(lines(data['form']),'a',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['debit','credit','balance'],type=['string','string','string']) ]]</para>
<blockTable colWidths="0.0,28.0,162.0" style="Table5">
<tr>
<td>
<para style="P3"> </para>
</td>
<td>
<para style="P7">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['code'] ]]</para>
</td>
<td>
<para style="P2"><font>[['.....'*(a['level']-1) ]][[ setTag('font','font',{'color':'white'}) ]]</font><font>[[ a['status']==1 and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['name'] ]]</font></para>
</td>
</tr>
</blockTable>
</section>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ repeatIn(linesForTotal(data['form']),'total',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['sum_debit','sum_credit',''],type=['string','string','lable'] ) ]]</para>
<blockTable colWidths="190.0" style="Table6">
<tr>
<td>
<para style="P3">Total:[[ data['form']['show_columns']==0 and removeParentNode('section')]]</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,179 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(1120.0,570.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="15.0" y1="15.0" width="1080" height="530"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table61">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="red"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="12.0" leading="18" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="9.0" alignment="CENTER"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="12" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Bold" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="1.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Account balance</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P8">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P13"> [[repeatIn(linesForYear(data['form']),'year_header',td=len(data['form']['fiscalyear'][0][2]),width=[126],value=['year'],type=['string']) ]]</para>
<blockTable colWidths="180.0" style="Table6">
<tr>
<td>
<para style="P1">Account Information</para>
</td>
</tr>
</blockTable>
</section>
<section>
<para style="P13">[[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['Debit','Credit','Balance'],type=['lable','lable','lable']) ]]</para>
<blockTable colWidths="30.0,150.0" style="Table6">
<tr>
<td>
<para style="P1">Code</para>
</td>
<td>
<para style="P1">Account Name</para>
</td>
</tr>
</blockTable>
</section>
<section>
<para style="P13">[[ repeatIn([],'title',td=len(data['form']['fiscalyear'][0][2]),width=[84,42],value=['Cash','%'],type=['lable','lable']) ]]</para>
<blockTable colWidths="180.0" style="Table5">
<tr>
<td>
<para style="P4"> </para>
</td>
</tr>
</blockTable>
</section>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ repeatIn(lines(data['form']),'a',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['debit','credit','balance'],type=['string','string','string']) ]]</para>
<blockTable colWidths="0.0,28.0,152.0" style="Table5">
<tr>
<td>
<para style="P3"> </para>
</td>
<td>
<para style="P7">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['code'] ]]</para>
</td>
<td>
<para style="P2"><font>[['.....'*(a['level']-1) ]][[ setTag('font','font',{'color':'white'}) ]]</font><font>[[ a['status']==1 and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['name'] ]]</font></para>
</td>
</tr>
</blockTable>
</section>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P13">[[ repeatIn(linesForTotal(data['form']),'total',td=len(data['form']['fiscalyear'][0][2]),width=[42,42,42],value=['sum_debit','sum_credit',''],type=['string','string','lable'] ) ]]</para>
<blockTable colWidths="180.0" style="Table6">
<tr>
<td>
<para style="P3">Total:[[ data['form']['show_columns']==0 and removeParentNode('section')]]</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
import wizard_account_balance_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,181 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# 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 ir
import pooler
import time
import netsvc
from osv import fields, osv
import mx.DateTime
from mx.DateTime import RelativeDateTime
from tools import config
dates_form = '''<?xml version="1.0"?>
<form string="Customize Report">
<notebook tabpos="up">
<page string="Report Options">
<separator string="Select Fiscal Year(s)(Maximum Three Years)" colspan="4"/>
<field name="fiscalyear" colspan="5" nolabel="1"/>
<field name="landscape" colspan="4"/>
<field name="show_columns" colspan="4"/>
<field name="format_perc" colspan="4"/>
<field name="select_account" colspan="4"/>
<field name="account_choice" colspan="4"/>
<field name="compare_pattern" colspan="4"/>
</page>
<page string="Select Period">
<field name="select_periods" colspan="4"/>
<separator string="Select Period(s)" colspan="4"/>
<field name="periods" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>'''
dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2many', 'relation': 'account.fiscalyear'},
'select_account': {'string': 'Select Reference Account(for % comparision)', 'type': 'many2one', 'relation': 'account.account','help': 'Keep empty for comparision to its parent'},
'account_choice': {'string': 'Show Accounts', 'type': 'selection','selection':[('all','All accounts'),('bal_zero','With balance is not equal to 0'),('moves','With movements')]},
'show_columns': {'string': 'Show Debit/Credit Information', 'type': 'boolean'},
'landscape': {'string': 'Show Report in Landscape Form', 'type': 'boolean'},
'format_perc': {'string': 'Show Comparision in %', 'type': 'boolean'},
'compare_pattern':{'string':"Compare Selected Years In Terms Of",'type':'selection','selection':[('bal_cash','Cash'),('bal_perc','Percentage'),('none','Don'+ "'" +'t Compare')]},
'select_periods':{'string':"Select Invoices Based on Their",'type':'selection','selection':[('actual','Actual Period (Duration)'),('created','Creation Date')]},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
}
back_form='''<?xml version="1.0"?>
<form string="Notification">
<separator string="You might have done following mistakes.Please correct them and try again." colspan="4"/>
<separator string="1. You have selected more than 3 years in any case." colspan="4"/>
<separator string="2. You have not selected 'Percentage' option,but you have selected more than 2 years." colspan="4"/>
<label string="You can select maximum 3 years.Please check again." colspan="4"/>
<separator string="3. You have selected 'Percentage' option with more than 2 years,but you have not selected landscape format." colspan="4"/>
<label string="You have to select 'Landscape' option.Please Check it." colspan="4"/>
</form>'''
back_fields={
}
zero_form='''<?xml version="1.0"?>
<form string="Notification">
<separator string="You have to select atleast 1 Fiscal Year. Try again." colspan="4"/>
<label string="You may have selected the compare opions with more than 1 years with credit/debit columns and % option.This can lead contents to be printed out of the paper.Please try again."/>
</form>'''
zero_fields={
}
def _check(self, cr, uid, data, context):
if (len(data['form']['fiscalyear'][0][2])==0) or (len(data['form']['fiscalyear'][0][2])>1 and (data['form']['compare_pattern']!='none') and (data['form']['format_perc']==1) and (data['form']['show_columns']==1) and (data['form']['landscape']!=1)):
return 'zero_years'
if ((len(data['form']['fiscalyear'][0][2])==3) and (data['form']['format_perc']!=1) and (data['form']['show_columns']!=1)):
if data['form']['landscape']==1:
return 'report_landscape'
else:
return 'report'
if data['form']['format_perc']==1:
if len(data['form']['fiscalyear'][0][2])<=2:
if data['form']['landscape']==1:
return 'report_landscape'
else:
return 'report'
else:
if len(data['form']['fiscalyear'][0][2])==3:
if data['form']['landscape']==1:
return 'report_landscape'
else:
return 'backtoinit'
else:
return 'backtoinit'
else:
if len(data['form']['fiscalyear'][0][2])>2:
if data['form']['landscape']==1:
return 'report_landscape'
else:
return 'backtoinit'
else:
if data['form']['landscape']==1:
return 'report_landscape'
else:
return 'report'
class wizard_report(wizard.interface):
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)]
# p_ids=pooler.get_pool(cr.dbname).get('account.period').search(cr,uid,[('fiscalyear_id','=',fiscalyear_obj.find(cr, uid))])
# data['form']['periods']=p_ids
data['form']['compare_pattern']='none'
data['form']['account_choice']='moves'
data['form']['select_periods']='actual'
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkyear','Print')]}
},
'backtoinit': {
'actions': [],
'result': {'type':'form','arch':back_form,'fields':back_fields,'state':[('end','Ok')]}
},
'zero_years': {
'actions': [],
'result': {'type':'form','arch':zero_form,'fields':zero_fields,'state':[('end','Ok')]}
},
'checkyear': {
'actions': [],
'result': {'type':'choice','next_state':_check}
},
'report_landscape': {
'actions': [],
'result': {'type':'print', 'report':'account.account.balance.landscape', 'state':'end'}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.balance.account.balance', 'state':'end'}
}
}
wizard_report('account.balance.account.balance.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,6 @@
# -*- encoding: utf-8 -*-
import crossovered_budget
import report
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,30 @@
# -*- encoding: utf-8 -*-
{
"name" : "Crossovered Budget Management",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://tinyerp.com/module_crossovered_budget.html",
"category" : "Generic Modules/Accounting",
"description": """This module allow accountants to manage analytic and crossovered budgets.
Once the Master Budgets and the Budgets defined (in Financial Management/Configuration/Budgets/), the Project Managers can set the planned amount on each Analytic Account.
The accountant has the possibility to see the total of amount planned for each Budget and Master Budget in order to ensure the total planned is not greater/lower than what he planned for this Budget/Master Budget. Each list of record can also be switched to a graphical view of it.
Three reports are available:
1. The first is available from a list of Budgets. It gives the spreading, for these Budgets, of the Analytic Accounts per Master Budgets.
2. The second is a summary of the previous one, it only gives the spreading, for the selected Budgets, of the Analytic Accounts.
3. The last one is available from the Analytic Chart of Accounts. It gives the spreading, for the selected Analytic Accounts, of the Master Budgets per Budgets.
""",
"depends" : ["account"],
"init_xml" : [],
"demo_xml" : [],
"update_xml" : ["crossovered_budget_view.xml","crossovered_budget_report.xml","crossovered_budget_workflow.xml"],
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,196 @@
# -*- encoding: utf-8 -*-
from osv import osv,fields
import tools
import netsvc
from mx import DateTime
import time
import datetime
def strToDate(dt):
dt_date=datetime.date(int(dt[0:4]),int(dt[5:7]),int(dt[8:10]))
return dt_date
class crossovered_budget(osv.osv):
_name = "crossovered.budget"
_description = "Crossovered Budget"
_columns = {
'name': fields.char('Name', size=50, required=True,states={'done':[('readonly',True)]}),
'code': fields.char('Code', size=20, required=True,states={'done':[('readonly',True)]}),
'creating_user_id': fields.many2one('res.users','Responsible User'),
'validating_user_id': fields.many2one('res.users','Validate User', readonly=True),
'date_from': fields.date('Start Date',required=True,states={'done':[('readonly',True)]}),
'date_to': fields.date('End Date',required=True,states={'done':[('readonly',True)]}),
'state' : fields.selection([('draft','Draft'),('confirm','Confirmed'),('validate','Validated'),('done','Done'),('cancel', 'Cancelled')], 'Status', select=True, required=True, readonly=True),
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'crossovered_budget_id', 'Budget Lines',states={'done':[('readonly',True)]} ),
}
_defaults = {
'state': lambda *a: 'draft',
'creating_user_id': lambda self,cr,uid,context: uid,
}
# def action_set_to_draft(self, cr, uid, ids, *args):
# self.write(cr, uid, ids, {'state': 'draft'})
# wf_service = netsvc.LocalService('workflow')
# for id in ids:
# wf_service.trg_create(uid, self._name, id, cr)
# return True
def budget_confirm(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'confirm'
})
return True
def budget_validate(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'validate',
'validating_user_id': uid,
})
return True
def budget_cancel(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'cancel'
})
return True
def budget_done(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'done'
})
return True
crossovered_budget()
class crossovered_budget_lines(osv.osv):
def _pra_amt(self, cr, uid, ids,name,args,context):
res = {}
for line in self.browse(cr, uid, ids):
acc_ids = ','.join([str(x.id) for x in line.general_budget_id.account_ids])
if not acc_ids:
raise osv.except_osv('Error!',"The General Budget '" + str(line.general_budget_id.name) + "' has no Accounts!" )
date_to = line.date_to
date_from = line.date_from
if context.has_key('wizard_date_from'):
date_from = context['wizard_date_from']
if context.has_key('wizard_date_to'):
date_to = context['wizard_date_to']
cr.execute("select sum(amount) from account_analytic_line where account_id=%d and (date between to_date('%s','yyyy-mm-dd') and to_date('%s','yyyy-mm-dd')) and general_account_id in (%s)"%(line.analytic_account_id.id,date_from,date_to,acc_ids))
result=cr.fetchone()[0]
if result==None:
result=0.00
res[line.id]=result
return res
def _theo_amt(self, cr, uid, ids,name,args,context):
res = {}
for line in self.browse(cr, uid, ids):
today=datetime.datetime.today()
date_to = today.strftime("%Y-%m-%d")
date_from = line.date_from
if context.has_key('wizard_date_from'):
date_from = context['wizard_date_from']
if context.has_key('wizard_date_to'):
date_to = context['wizard_date_to']
if line.paid_date:
if strToDate(date_to)<=strToDate(line.paid_date):
theo_amt=0.00
else:
theo_amt=line.planned_amount
else:
total=strToDate(line.date_to) - strToDate(line.date_from)
elapsed = min(strToDate(line.date_to),strToDate(date_to)) - max(strToDate(line.date_from),strToDate(date_from))
if strToDate(date_to) < strToDate(line.date_from):
elapsed = strToDate(date_to) - strToDate(date_to)
theo_amt=float(elapsed.days/float(total.days))*line.planned_amount
res[line.id]=theo_amt
return res
def _perc(self, cr, uid, ids,name,args,context):
res = {}
for line in self.browse(cr, uid, ids):
if line.theoritical_amount<>0.00:
res[line.id]=float(line.practical_amount / line.theoritical_amount)*100
else:
res[line.id]=0.00
return res
_name="crossovered.budget.lines"
_description = "Crossovered Budget Lines"
_columns = {
'crossovered_budget_id': fields.many2one('crossovered.budget', 'Budget Ref', ondelete='cascade', select=True, required=True),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account Ref',required=True),
'general_budget_id': fields.many2one('account.budget.post', 'Master Budget Ref',required=True),
'date_from': fields.date('Start Date',required=True),
'date_to': fields.date('End Date',required=True),
'paid_date': fields.date('Paid Date'),
'planned_amount':fields.float('Planned Amount',required=True),
'practical_amount':fields.function(_pra_amt,method=True, string='Practical Amount',type='float'),
'theoritical_amount':fields.function(_theo_amt,method=True, string='Theoritical Amount',type='float'),
'percentage':fields.function(_perc,method=True, string='Percentage',type='float'),
}
crossovered_budget_lines()
class account_budget_post(osv.osv):
_name = 'account.budget.post'
_inherit = 'account.budget.post'
_columns = {
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'general_budget_id', 'Budget Lines'),
}
account_budget_post()
class account_budget_post_dotation(osv.osv):
_name = 'account.budget.post.dotation'
_inherit = 'account.budget.post.dotation'
def _tot_planned(self, cr, uid, ids,name,args,context):
res={}
for line in self.browse(cr, uid, ids):
if line.period_id:
obj_period=self.pool.get('account.period').browse(cr, uid,line.period_id.id)
total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start)
budget_id=line.post_id and line.post_id.id or False
query="select id from crossovered_budget_lines where general_budget_id= '"+ str(budget_id) + "' AND (date_from >='" +obj_period.date_start +"' and date_from <= '"+obj_period.date_stop + "') OR (date_to >='" +obj_period.date_start +"' and date_to <= '"+obj_period.date_stop + "') OR (date_from <'" +obj_period.date_start +"' and date_to > '"+obj_period.date_stop + "')"
cr.execute(query)
res1=cr.fetchall()
tot_planned=0.00
for record in res1:
obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid,record[0])
count_days = min(strToDate(obj_period.date_stop),strToDate(obj_lines.date_to)) - max(strToDate(obj_period.date_start), strToDate(obj_lines.date_from))
days_in_period = count_days.days +1
count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from)
total_days_of_rec = count_days.days +1
tot_planned += obj_lines.planned_amount/total_days_of_rec* days_in_period
res[line.id]=tot_planned
else:
res[line.id]=0.00
return res
_columns = {
'tot_planned':fields.function(_tot_planned,method=True, string='Total Planned Amount',type='float',store=True),
}
account_budget_post_dotation()
class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
_inherit = 'account.analytic.account'
_columns = {
'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'analytic_account_id', 'Budget Lines'),
}
account_analytic_account()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<terp>
<data>
<!-- Reports on crossovered.budget -->
<report id="report_crossovered_budget"
string="Print Budgets"
model="crossovered.budget"
name="crossovered.budget.report"
rml="account_budget_crossover/report/crossovered_budget_report.rml"
auto="False"
menu="False" />
<wizard
string="Print Budgets"
model="crossovered.budget"
name="wizard.crossovered.budget"
id="wizard_crossovered_budget_menu"
keyword="client_print_multi" />
<wizard
string="Print Summary of Budgets"
model="crossovered.budget"
name="wizard.crossovered.budget.summary"
id="wizard_crossovered_budget_menu_1"
keyword="client_print_multi" />
<!-- Reports on account.analytic.account -->
<wizard
id="account_analytic_account_budget_report"
string="Print Budgets"
model="account.analytic.account"
name="wizard.analytic.account.budget.report"
keyword="client_print_multi"/>
<report id="account_analytic_account_budget"
string="Print Budgets"
model="account.analytic.account"
name="account.analytic.account.budget"
rml="account_budget_crossover/report/analytic_account_budget_report.rml"
auto="False"
menu="False"/>
</data>
</terp>

View File

@ -0,0 +1,256 @@
<?xml version="1.0" ?>
<terp>
<data>
<record model="ir.ui.view" id="crossovered_budget_view_form">
<field name="name">crossovered.budget.view.form</field>
<field name="model">crossovered.budget</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Budget">
<field name="name" colspan="1" select="1"/>
<field name="code" colspan="1" select="1" />
<field name="creating_user_id" />
<field name="validating_user_id" readonly="True"/>
<field name="date_from" select="2"/>
<field name="date_to" select="2"/>
<field name="crossovered_budget_line" colspan="4" nolabel="1">
<tree string="Budget Lines">
<field name="analytic_account_id"/>
<field name="general_budget_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date"/>
<field name="planned_amount"/>
<field name="practical_amount"/>
<field name="theoritical_amount"/>
<field name="percentage"/>
</tree>
<form string="Budget Lines">
<field name="analytic_account_id" select="1"/>
<field name="general_budget_id" select="1"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date" select="1"/>
<field name="planned_amount" select="1"/>
</form>
</field>
<field name="state" select="1"/>
<group col="4" colspan="2">
<button string="Confirm" name="confirm" states="draft" type="workflow" />
<button string="Validate" name="validate" states="confirm" type="workflow"/>
<button string="Done" name="done" states="validate" type="workflow"/>
<button string="Cancel" name="cancel" states="confirm,validate" type="workflow" />
<!--<button string="Set to Draft" name="action_set_to_draft" states="cancel" type="object"/>-->
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="crossovered_budget_view_tree">
<field name="name">crossovered.budget.view.tree</field>
<field name="model">crossovered.budget</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Budget">
<field name="name" colspan="1" select="1"/>
<field name="code" colspan="1" select="1" />
<field name="state"/>
<field name="date_from"/>
<field name="date_to"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="act_crossovered_budget_view">
<field name="name">Budget</field>
<field name="res_model">crossovered.budget</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="crossovered_budget_view_tree"/>
</record>
<menuitem parent="account.next_id_31"
id="menu_act_crossovered_budget_view"
action="act_crossovered_budget_view" />
<record model="ir.ui.view" id="view_crossovered_budget_line_tree">
<field name="name">crossovered.budget.line.tree</field>
<field name="model">crossovered.budget.lines</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Budget Lines">
<field name="analytic_account_id"/>
<field name="general_budget_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date"/>
<field name="planned_amount"/>
<field name="practical_amount" select="1"/>
<field name="theoritical_amount"/>
<field name="percentage"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_crossovered_budget_line_form">
<field name="name">crossovered.budget.line.form</field>
<field name="model">crossovered.budget.lines</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Budget Lines">
<field name="crossovered_budget_id"/>
<field name="analytic_account_id" select="1"/>
<field name="general_budget_id" select="1"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date" select="1"/>
<field name="planned_amount" select="1"/>
<field name="practical_amount" select="1"/>
<field name="theoritical_amount"/>
<field name="percentage"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="act_crossovered_budget_lines_view">
<field name="name">Budget Lines</field>
<field name="res_model">crossovered.budget.lines</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_crossovered_budget_line_tree"/>
</record>
<menuitem name="Budgets" parent="account.menu_action_account_budget_post_tree"
id="menu_financial_reporting_budget_budget"/>
<menuitem name="Entries" parent="menu_financial_reporting_budget_budget"
id="menu_financial_reporting_budget_budget_entries"/>
<menuitem parent="menu_financial_reporting_budget_budget_entries"
id="menu_act_crossovered_budget_lines_view"
action="act_crossovered_budget_lines_view" />
<!-- Shortcuts -->
<act_window name="Budget Lines"
domain="[('analytic_account_id', '=', active_id)]"
res_model="crossovered.budget.lines"
src_model="account.analytic.account"
id="act_account_analytic_account_cb_lines"/>
<!--<record model="ir.ui.view" id="view_budget_post_dotation_form_inherit">
<field name="name">account.budget.post.dotation.form.inherit</field>
<field name="type">form</field>
<field name="model">account.budget.post.dotation</field>
<field name="inherit_id" ref="account.view_budget_post_dotation_form"/>
<field name="arch" type="xml">
<field name="period_id" position="after">
<field name="tot_planned" />
</field>
</field>
</record>-->
<record model="ir.ui.view" id="view_budget_post_dotation_tree_inherit">
<field name="name">account.budget.post.dotation.tree.inherit</field>
<field name="model">account.budget.post.dotation</field>
<field name="type">tree</field>
<field name="inherit_id" ref="account.view_budget_post_dotation_tree"/>
<field name="arch" type="xml">
<field name="amount" position="after">
<field name="tot_planned" />
</field>
</field>
</record>
<record model="ir.ui.view" id="account.view_budget_post_form">
<field name="name">account.budget.post.form.inherit</field>
<field name="model">account.budget.post</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Master Budget">
<notebook>
<page string="Definition">
<field name="code" select="1"/>
<field name="name" select="1"/>
</page>
<page string="Dotations">
<button string="Spread" name="%(account.wizard_budget_spread)d" type="action"/>
<field name="dotation_ids" colspan="4" nolabel="1"/>
</page>
<page string="Accounts">
<field name="account_ids" colspan="4" nolabel="1"/>
</page>
<page string="Budget Lines">
<field name="crossovered_budget_line" widget="one2many_list" colspan="4" nolabel="1" mode="tree,graph">
<graph type="bar" string="Lines">
<field name="analytic_account_id" />
<field name="general_budget_id" operator="+" />
<field name="planned_amount" operator="+"/>
<field group="True" name="general_budget_id"/>
</graph>
<tree string="Budget Lines" editable="top">
<field name="crossovered_budget_id"/>
<field name="analytic_account_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date"/>
<field name="planned_amount"/>
<field name="practical_amount" select="1"/>
<field name="theoritical_amount"/>
<field name="percentage"/>
</tree>
<form string="Budget Lines">
<field name="crossovered_budget_id"/>
<field name="analytic_account_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date"/>
<field name="planned_amount"/>
<field name="practical_amount" select="1"/>
<field name="theoritical_amount"/>
<field name="percentage"/>
</form>
</field>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_account_analytic_account_form_inherit_cci">
<field name="name">account.analytic.account.form.inherot.cci</field>
<field name="type">form</field>
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="account.view_account_analytic_account_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Budget Lines">
<field name="crossovered_budget_line" widget="one2many_list" colspan="4" nolabel="1" mode="tree,graph">
<tree string="Budget Lines" editable="top">
<field name="crossovered_budget_id"/>
<field name="general_budget_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date"/>
<field name="planned_amount"/>
</tree>
<form string="Budget Lines">
<field name="crossovered_budget_id"/>
<field name="general_budget_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="paid_date"/>
<field name="planned_amount"/>
</form>
<graph type="bar" string="Lines">
<field name="general_budget_id" />
<field name="analytic_account_id" operator="+"/>
<field name="planned_amount" operator="+"/>
<field group="True" name="analytic_account_id"/>
</graph>
</field>
</page>
</notebook>
</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,104 @@
<?xml version="1.0" ?>
<terp>
<data>
<record model="res.roles" id="crossovered_budget_role">
<field name="name">Crossovered Budget Validation</field>
</record>
<!-- Workflow definition -->
<record model="workflow" id="wkf_crossovered_budget">
<field name="name">wkf.crossovered.budget</field>
<field name="osv">crossovered.budget</field>
<field name="on_create">True</field>
</record>
<record model="workflow.activity" id="act_draft">
<field name="wkf_id" ref="wkf_crossovered_budget" />
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<record model="workflow.activity" id="act_confirm">
<field name="wkf_id" ref="wkf_crossovered_budget" />
<field name="name">confirm</field>
<field name="kind">function</field>
<field name="action">budget_confirm()</field>
<field name="split_mode">OR</field>
</record>
<record model="workflow.activity" id="act_validate">
<field name="wkf_id" ref="wkf_crossovered_budget" />
<field name="name">validate</field>
<field name="kind">function</field>
<field name="action">budget_validate()</field>
</record>
<!--<record model="workflow.activity" id="act_set_to_draft">
<field name="wkf_id" ref="wkf_crossovered_budget" />
<field name="name">settodraft</field>
<field name="kind">function</field>
<field name="action">action_set_to_draft()</field>
</record>-->
<record model="workflow.activity" id="act_cancel">
<field name="wkf_id" ref="wkf_crossovered_budget" />
<field name="name">cancel</field>
<field name="kind">function</field>
<field name="action">budget_cancel()</field>
</record>
<record model="workflow.activity" id="act_done">
<field name="wkf_id" ref="wkf_crossovered_budget" />
<field name="name">done</field>
<field name="flow_stop">True</field>
<field name="kind">stopall</field>
<field name="action">budget_done()</field>
<field name="join_mode">XOR</field>
</record>
<record model="workflow.transition" id="t1">
<field name="act_from" ref="act_draft" />
<field name="act_to" ref="act_confirm" />
<field name="signal">confirm</field>
</record>
<record model="workflow.transition" id="t2">
<field name="act_from" ref="act_confirm" />
<field name="act_to" ref="act_validate" />
<field name="signal">validate</field>
<field name="role_id" ref="crossovered_budget_role"/>
</record>
<record model="workflow.transition" id="t3">
<field name="act_from" ref="act_confirm" />
<field name="act_to" ref="act_cancel" />
<field name="signal">cancel</field>
<field name="role_id" ref="crossovered_budget_role"/>
</record>
<record model="workflow.transition" id="t4">
<field name="act_from" ref="act_validate" />
<field name="act_to" ref="act_cancel" />
<field name="signal">cancel</field>
<field name="role_id" ref="crossovered_budget_role"/>
</record>
<record model="workflow.transition" id="t5">
<field name="act_from" ref="act_validate" />
<field name="act_to" ref="act_done" />
<field name="signal">done</field>
<field name="role_id" ref="crossovered_budget_role"/>
</record>
<!--<record model="workflow.transition" id="t7">
<field name="act_from" ref="act_cancel" />
<field name="act_to" ref="act_draft" />
<field name="signal">settodraft</field>
<field name="role_id" ref="crossovered_budget_role"/>
</record>-->
</data>
</terp>

View File

@ -0,0 +1,5 @@
# -*- encoding: utf-8 -*-
import crossovered_budget_report
import analytic_account_budget_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,177 @@
# -*- encoding: utf-8 -*-
import time
import pooler
from report import report_sxw
import datetime
class analytic_account_budget_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(analytic_account_budget_report, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'funct': self.funct,
'funct_total': self.funct_total,
'time': time,
})
self.context=context
def funct(self,object,form,ids={}, done=None, level=1):
if not ids:
ids = self.ids
# if not ids:
# return []
if not done:
done={}
global tot
tot={
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
}
result=[]
accounts = self.pool.get('account.analytic.account').browse(self.cr, self.uid, [object.id], self.context.copy())
for account_id in accounts:
res={}
budget_lines=[]
b_line_ids=[]
for line in account_id.crossovered_budget_line:
b_line_ids.append(line.id)
bd_lines_ids = ','.join([str(x) for x in b_line_ids])
d_from=form['date_from']
d_to=form['date_to']
query="select id from crossovered_budget_lines where id in ("+ str(bd_lines_ids) + ")"# AND '"+ str(d_from) +"'<=date_from AND date_from<date_to AND date_to<= '"+ str(d_to) +"'"
self.cr.execute(query)
budget_line_ids=self.cr.fetchall()
if not budget_line_ids:
return []
budget_lines=[x[0] for x in budget_line_ids]
bd_ids = ','.join([str(x) for x in budget_lines])
self.cr.execute('select distinct(crossovered_budget_id) from crossovered_budget_lines where id in (%s)'%(bd_lines_ids))
budget_ids=self.cr.fetchall()
for i in range(0,len(budget_ids)):
budget_name=self.pool.get('crossovered.budget').browse(self.cr, self.uid,[budget_ids[i][0]])
res={
'b_id':'-1',
'a_id':'-1',
'name':budget_name[0].name,
'status':1,
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
}
result.append(res)
line_ids = self.pool.get('crossovered.budget.lines').search(self.cr, self.uid, [('id', 'in', b_line_ids),('crossovered_budget_id','=',budget_ids[i][0])])
line_id = self.pool.get('crossovered.budget.lines').browse(self.cr,self.uid,line_ids)
tot_theo=tot_pln=tot_prac=tot_perc=0
done_budget=[]
for line in line_id:
if line.id in budget_lines:
theo=pract=0.00
theo=line._theo_amt(self.cr, self.uid, [line.id],"theoritical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
pract=line._pra_amt(self.cr, self.uid, [line.id],"practical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
if line.general_budget_id.id in done_budget:
for record in result:
if record['b_id']==line.general_budget_id.id and record['a_id']==line.analytic_account_id.id:
record['theo'] +=theo
record['pln'] +=line.planned_amount
record['prac'] +=pract
record['perc'] +=line.percentage
tot_theo +=theo
tot_pln +=line.planned_amount
tot_prac +=pract
tot_perc +=line.percentage
else:
res1={
'b_id':line.general_budget_id.id,
'a_id':line.analytic_account_id.id,
'name':line.general_budget_id.name,
'status':2,
'theo':theo,
'pln':line.planned_amount,
'prac':pract,
'perc':line.percentage
}
tot_theo += theo
tot_pln +=line.planned_amount
tot_prac +=pract
tot_perc +=line.percentage
result.append(res1)
done_budget.append(line.general_budget_id.id)
else:
if line.general_budget_id.id in done_budget:
continue
else:
res1={
'b_id':line.general_budget_id.id,
'a_id':line.analytic_account_id.id,
'name':line.general_budget_id.name,
'status':2,
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
}
result.append(res1)
done_budget.append(line.general_budget_id.id)
if tot_theo==0.00:
tot_perc=0.00
else:
tot_perc=float(tot_prac /tot_theo)*100
result[-(len(done_budget) +1)]['theo']=tot_theo
tot['theo'] +=tot_theo
result[-(len(done_budget) +1)]['pln']=tot_pln
tot['pln'] +=tot_pln
result[-(len(done_budget) +1)]['prac']=tot_prac
tot['prac'] +=tot_prac
result[-(len(done_budget) +1)]['perc']=tot_perc
if tot['theo']==0.00:
tot['perc'] =0.00
else:
tot['perc']=float(tot['prac'] /tot['theo'])*100
return result
def funct_total(self,form):
result=[]
res={}
res={
'tot_theo':tot['theo'],
'tot_pln':tot['pln'],
'tot_prac':tot['prac'],
'tot_perc':tot['perc']
}
result.append(res)
return result
report_sxw.report_sxw('report.account.analytic.account.budget', 'account.analytic.account', 'addons/account_budget_crossover/report/analytic_account_budget_report.rml',parser=analytic_account_budget_report,header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,173 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="498" height="678"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#b3b3b3" start="0,0" stop="0,0"/>
<blockBackground colorName="#b3b3b3" start="1,0" stop="1,0"/>
<blockBackground colorName="#b3b3b3" start="2,0" stop="2,0"/>
<blockBackground colorName="#b3b3b3" start="3,0" stop="3,0"/>
<blockBackground colorName="#b3b3b3" start="4,0" stop="4,0"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="10.0" leading="10" alignment="LEFT"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<blockTable colWidths="499.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="P10">[[ company.name ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="250.0,250.0" repeatRows="1" style="Table6">
<tr>
<td>
<para style="P6">Currency: [[ company.currency_id.name ]]</para>
</td>
<td>
<para style="P7">Printed at: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S')]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="250.0,250.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P6">Analysis from [[ data['form']['date_from'] ]] to [[ data['form']['date_to'] ]]</para>
</td>
<td>
<para style="P7">Analytic Account : [[ o.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="185.0,83.0,75.0,91.0,65.0" style="Table3">
<tr>
<td>
<para style="P4">Description</para>
</td>
<td>
<para style="P4">Theoretical Amount</para>
</td>
<td>
<para style="P4">Planned Amount</para>
</td>
<td>
<para style="P4">Practical Amount</para>
</td>
<td>
<para style="P4">%</para>
</td>
</tr>
</blockTable>
<section>
<para style="P2">[[ repeatIn(funct(o,data['form']),'a') ]]</para>
<blockTable colWidths="185.0,83.0,75.0,91.0,64.0" style="Table4">
<tr>
<td>
<para style="P1">
<font>[['.....'*(a['status']-1) ]][[ setTag('font','font',{'color':'white'}) ]]</font><font>[[ a['status']==1 and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['name'] ]]</font>
</para>
</td>
<td>
<para style="P5">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['theo'] ]]</para>
</td>
<td>
<para style="P5">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['pln'] ]]</para>
</td>
<td>
<para style="P5">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['prac'] ]]</para>
</td>
<td>
<para style="P5">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['perc'] ]]%</para>
</td>
</tr>
</blockTable>
</section>
<para style="Text body">
<font color="white"> </font>
</para>
<blockTable colWidths="185.0,83.0,75.0,91.0,64.0" style="Table5">
<tr>
<td>
<para style="P5">Total:</para>
</td>
<td>
<para style="P5">
[[ repeatIn(funct_total(data['form']),'b') ]] <font face="Times-Roman">[[ '%.2f' % b['tot_theo'] ]]</font>
</para>
</td>
<td>
<para style="P5">[[ '%.2f' % b['tot_pln'] ]]</para>
</td>
<td>
<para style="P5">[[ '%.2f' % b['tot_prac'] ]]</para>
</td>
<td>
<para style="P5">[[ '%.2f' % b['tot_perc'] ]]%</para>
</td>
</tr>
</blockTable>
<para style="P2">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,227 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# 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 time
import pooler
from report import report_sxw
import datetime
import operator
import osv
class budget_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(budget_report, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'funct': self.funct,
'funct_total': self.funct_total,
'time': time,
})
self.context=context
def funct(self,object,form,ids={}, done=None, level=1):
if not ids:
ids = self.ids
# if not ids:
# return []
if not done:
done={}
global tot
tot={
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
}
result=[]
budgets = self.pool.get('crossovered.budget').browse(self.cr, self.uid, [object.id], self.context.copy())
for budget_id in budgets:
res={}
budget_lines=[]
budget_ids=[]
d_from=form['date_from']
d_to=form['date_to']
for line in budget_id.crossovered_budget_line:
budget_ids.append(line.id)
b_line_ids=','.join([str(x) for x in budget_ids])
query="select id from crossovered_budget_lines where crossovered_budget_id = '"+ str(budget_id.id) + "'"# AND '"+ str(d_from) +"'<=date_from AND date_from<date_to AND date_to<= '"+ str(d_to) +"'"
self.cr.execute(query)
budget_line_ids=self.cr.fetchall()
if not budget_line_ids:
return []
budget_lines=[x[0] for x in budget_line_ids]
bd_ids = ','.join([str(x) for x in budget_lines])
self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id in (%s)'%(b_line_ids))
an_ids=self.cr.fetchall()
for i in range(0,len(an_ids)):
analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid,[an_ids[i][0]])
res={
'b_id':'-1',
'a_id':'-1',
'name':analytic_name[0].name,
'status':1,
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
}
result.append(res)
line_ids = self.pool.get('crossovered.budget.lines').search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])])
line_id = self.pool.get('crossovered.budget.lines').browse(self.cr,self.uid,line_ids)
tot_theo=tot_pln=tot_prac=tot_perc=0.00
done_budget=[]
for line in line_id:
if line.id in budget_lines:
theo=pract=0.00
theo=line._theo_amt(self.cr, self.uid, [line.id],"theoritical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
pract=line._pra_amt(self.cr, self.uid, [line.id],"practical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id]
if line.general_budget_id.id in done_budget:
for record in result:
if record['b_id']==line.general_budget_id.id and record['a_id']==line.analytic_account_id.id:
record['theo'] +=theo
record['pln'] +=line.planned_amount
record['prac'] +=pract
if record['theo']<>0.00:
perc=(record['prac']/record['theo'])*100
else:
perc=0.00
record['perc'] =perc
tot_theo += theo
tot_pln +=line.planned_amount
tot_prac +=pract
tot_perc +=perc
else:
if theo<>0.00:
perc=(pract/theo)*100
else:
perc=0.00
res1={
'a_id':line.analytic_account_id.id,
'b_id':line.general_budget_id.id,
'name':line.general_budget_id.name,
'status':2,
'theo':theo,
'pln':line.planned_amount,
'prac':pract,
'perc':perc,
}
tot_theo += theo
tot_pln +=line.planned_amount
tot_prac +=pract
tot_perc +=perc
if form['report']=='analytic-full':
result.append(res1)
done_budget.append(line.general_budget_id.id)
else:
if line.general_budget_id.id in done_budget:
continue
else:
res1={
'a_id':line.analytic_account_id.id,
'b_id':line.general_budget_id.id,
'name':line.general_budget_id.name,
'status':2,
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
}
if form['report']=='analytic-full':
result.append(res1)
done_budget.append(line.general_budget_id.id)
if tot_theo==0.00:
tot_perc=0.00
else:
tot_perc=float(tot_prac /tot_theo)*100
if form['report']=='analytic-full':
result[-(len(done_budget) +1)]['theo']=tot_theo
tot['theo'] +=tot_theo
result[-(len(done_budget) +1)]['pln']=tot_pln
tot['pln'] +=tot_pln
result[-(len(done_budget) +1)]['prac']=tot_prac
tot['prac'] +=tot_prac
result[-(len(done_budget) +1)]['perc']=tot_perc
else:
result[-1]['theo']=tot_theo
tot['theo'] +=tot_theo
result[-1]['pln']=tot_pln
tot['pln'] +=tot_pln
result[-1]['prac']=tot_prac
tot['prac'] +=tot_prac
result[-1]['perc']=tot_perc
if tot['theo']==0.00:
tot['perc'] =0.00
else:
tot['perc']=float(tot['prac'] /tot['theo'])*100
return result
def funct_total(self,form):
result=[]
res={}
res={
'tot_theo':tot['theo'],
'tot_pln':tot['pln'],
'tot_prac':tot['prac'],
'tot_perc':tot['perc']
}
result.append(res)
return result
report_sxw.report_sxw('report.crossovered.budget.report', 'crossovered.budget', 'addons/account_budget_crossover/report/crossovered_budget_report.rml',parser=budget_report,header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,176 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="498" height="678"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#b3b3b3" start="0,0" stop="0,0"/>
<blockBackground colorName="#b3b3b3" start="1,0" stop="1,0"/>
<blockBackground colorName="#b3b3b3" start="2,0" stop="2,0"/>
<blockBackground colorName="#b3b3b3" start="3,0" stop="3,0"/>
<blockBackground colorName="#b3b3b3" start="4,0" stop="4,0"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<blockTable colWidths="499.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="P2">
<font face="Times-Roman">[[ company.name ]]</font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="250.0,250.0" repeatRows="1" style="Table6">
<tr>
<td>
<para style="P7">
<font face="Times-Roman">Currency: [[ company.currency_id.name ]]</font>
</para>
</td>
<td>
<para style="P8">Printed at: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S')]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="250.0,250.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P7">Analysis from [[ data['form']['date_from'] ]] to [[ data['form']['date_to'] ]]</para>
</td>
<td>
<para style="P8">Budget : [[ o.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="185.0,83.0,75.0,91.0,64.0" style="Table3">
<tr>
<td>
<para style="P5">Description</para>
</td>
<td>
<para style="P5">Theoretical Amount</para>
</td>
<td>
<para style="P5">Planned Amount</para>
</td>
<td>
<para style="P5">Practical Amount</para>
</td>
<td>
<para style="P5">%</para>
</td>
</tr>
</blockTable>
<section>
<para style="P4">[[ repeatIn(funct(o,data['form']),'a') ]]</para>
<blockTable colWidths="185.0,83.0,75.0,91.0,64.0" style="Table4">
<tr>
<td>
<para style="P3">
<font>[['.....'*(a['status']-1) ]][[ setTag('font','font',{'color':'white'}) ]]</font><font>[[ a['status']==1 and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['name'] ]]</font>
</para>
</td>
<td>
<para style="P6">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['theo'] ]]</para>
</td>
<td>
<para style="P6">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['pln'] ]]</para>
</td>
<td>
<para style="P6">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['prac'] ]]</para>
</td>
<td>
<para style="P6">[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ '%.2f' % a['perc'] ]]%</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="185.0,83.0,75.0,91.0,64.0" style="Table5">
<tr>
<td>
<para style="P10">Total:</para>
</td>
<td>
<para style="P6">[[ repeatIn(funct_total(data['form']),'b') ]] <font face="Times-Roman">[[ '%.2f' % b ['tot_theo'] ]]</font></para>
</td>
<td>
<para style="P6">[[ '%.2f' % b['tot_pln'] ]]</para>
</td>
<td>
<para style="P6">[[ '%.2f' % b['tot_prac'] ]]</para>
</td>
<td>
<para style="P6">[[ '%.2f' % b['tot_perc'] ]]%</para>
</td>
</tr>
</blockTable>
<para style="P4">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,6 @@
# -*- encoding: utf-8 -*-
import wizard_crossovered_budget_report
import wizard_analytic_account_budget
import wizard_crossovered_budget_summary_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,30 @@
# -*- encoding: utf-8 -*-
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select Dates Period">
<field name="date_from"/>
<field name="date_to"/>
</form>'''
dates_fields = {
'date_from': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.account.budget', 'state':'end'}
}
}
wizard_report('wizard.analytic.account.budget.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,35 @@
# -*- encoding: utf-8 -*-
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select Options">
<field name="date_from"/>
<field name="date_to"/>
</form>'''
dates_fields = {
'date_from': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
def _default(self, cr, uid, data, context):
data['form']['report']='analytic-full'
return data['form']
states = {
'init': {
'actions': [_default],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'crossovered.budget.report', 'state':'end'}
}
}
wizard_report('wizard.crossovered.budget')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select Options">
<field name="date_from"/>
<field name="date_to"/>
</form>'''
dates_fields = {
'date_from': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report_summary(wizard.interface):
def _default(self, cr, uid, data, context):
data['form']['report']='analytic-one'
return data['form']
states = {
'init': {
'actions': [_default],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'crossovered.budget.report', 'state':'end'}
}
}
wizard_report_summary('wizard.crossovered.budget.summary')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,36 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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.
#
##############################################################################
#----------------------------------------------------------
# Init Sales
#----------------------------------------------------------
import account_date_check
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,27 @@
# -*- encoding: utf-8 -*-
{
"name" : "Account Date check",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://tinyerp.com/module_sale.html",
"depends" : ["account"],
"category" : "Generic Modules/Accounting",
"init_xml" : [],
"demo_xml" : [],
"description": """
* Adds a field on journals: "Allows date not in the period"
* By default, this field is checked.
If this field is not checked, the system control that the date is in the
period when you create an account entry. Otherwise, it generates an
error message: "The date of your account move is not in the defined
period !"
""",
"update_xml" : [
"account_date_check_view.xml",
],
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,88 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# 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
from osv import osv
import time
import netsvc
import ir
from mx import DateTime
import pooler
from tools import config
class account_journal(osv.osv):
_inherit='account.journal'
_name='account.journal'
_columns = {
'allow_date':fields.boolean('Allows date not in the period'),
}
_defaults = {
'allow_date': lambda *a: 1,
}
account_journal()
class account_move_line(osv.osv):
_inherit='account.move.line'
_name='account.move.line'
def check_date(self, cr, uid, vals, context=None, check=True):
if 'date' in vals.keys():
if 'journal_id' in vals and 'journal_id' not in context:
journal_id = vals['journal_id']
if 'period_id' in vals and 'period_id' not in context:
period_id = vals['period_id']
elif 'journal_id' not in context and 'move_id' in vals:
m = self.pool.get('account.move').browse(cr, uid, vals['move_id'])
journal_id = m.journal_id.id
period_id = m.period_id.id
else:
journal_id = context['journal_id']
period_id = context['period_id']
journal=self.pool.get('account.journal').browse(cr,uid,[journal_id])[0]
if not journal.allow_date:
period=self.pool.get('account.period').browse(cr,uid,[period_id])[0]
if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') and time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'):
raise osv.except_osv('Error','The date of your account move is not in the defined period !')
else:
return True
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
flag=self.check_date(cr, uid, vals, context, check)
result = super(account_move_line, self).write(cr, uid, ids, vals, context, check, update_check)
return result
def create(self, cr, uid, vals, context=None, check=True):
flag=self.check_date(cr, uid, vals, context, check)
result = super(account_move_line, self).create(cr, uid, vals, context, check)
return result
account_move_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="view_account_journal_form_inherit2">
<field name="name">account.journal.form.inherit2</field>
<field name="model">account.journal</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="allow_date" />
</field>
</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>account_invoice_layout</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.4</pydev_property>
</pydev_project>

View File

@ -0,0 +1,6 @@
# -*- encoding: utf-8 -*-
import account_invoice_layout
import report
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,30 @@
# -*- encoding: utf-8 -*-
{
"name" : "account_invoice_layout",
"version" : "1.0",
"depends" : ["base", "account"],
"author" : "Tiny",
"description": """
This module provides some features to improve the layout of the invoices.
It gives you the possibility to
* order all the lines of an invoice
* add titles, comment lines, sub total lines
* draw horizontal lines and put page breaks
Moreover, there is one option which allow you to print all the selected invoices with a given special message at the bottom of it. This feature can be very useful for printing your invoices with end-of-year wishes, special punctual conditions...
""",
"website" : "http://tinyerp.com/",
"category" : "Generic Modules/Project & Services",
"init_xml" : [],
"demo_xml" : [],
"update_xml" : [
"account_invoice_layout_view.xml",
"account_invoice_layout_report.xml",
],
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,192 @@
# -*- encoding: utf-8 -*-
from osv import fields,osv
class notify_message(osv.osv):
_name = 'notify.message'
_description = 'Notify By Messages'
_columns = {
'name' : fields.char('Title',size=64,required=True),
'msg' : fields.text('Special Message',size=125,required=True,help='This notification will appear at the bottom of the Invoices when printed.',translate=True)
}
notify_message()
class account_invoice_line(osv.osv):
def move_line_get_item(self, cr, uid, line, context={}):
if line.state != 'article':
return None
return super(account_invoice_line, self).move_line_get_item(cr, uid, line, context)
def fields_get(self, cr, uid, fields=None, context=None):
article = {
'article': [('readonly', False), ('invisible', False)],
'text': [('readonly', True), ('invisible', True), ('required', False)],
'subtotal': [('readonly', True), ('invisible', True), ('required', False)],
'title': [('readonly', True), ('invisible', True), ('required', False)],
'break': [('readonly', True), ('invisible', True), ('required', False)],
'line': [('readonly', True), ('invisible', True), ('required', False)],
}
states = {
'name': {
'break': [('readonly', True),('required', False),('invisible', True)],
'line': [('readonly', True),('required', False),('invisible', True)],
},
'product_id': article,
'account_id': article,
'quantity': article,
'uos_id': article,
'price_unit': article,
'discount': article,
'invoice_line_tax_id': article,
'account_analytic_id': article,
}
res = super(account_invoice_line, self).fields_get(cr, uid, fields, context)
for field in res:
if states.has_key(field):
for key,value in states[field].items():
res[field].setdefault('states',{})
res[field]['states'][key] = value
return res
def _onchange_invoice_line_view(self, cr, uid, id, type, context={}, *args):
if (not type):
return {}
if type != 'article':
temp = {'value': {
'product_id': False,
'uos_id': False,
'account_id': False,
'price_unit': False,
'price_subtotal': False,
'quantity': 0,
'discount': False,
'invoice_line_tax_id': False,
'account_analytic_id': False,
},
}
if type == 'line':
temp['value']['name'] = ' '
if type == 'break':
temp['value']['name'] = ' '
if type == 'subtotal':
temp['value']['name'] = 'Sub Total'
return temp
return {}
def create(self, cr, user, vals, context=None):
if vals.has_key('state'):
if vals['state'] == 'line':
vals['name'] = ' '
if vals['state'] == 'break':
vals['name'] = ' '
if vals['state'] != 'article':
vals['quantity']= 0
vals['account_id']= self._default_account(cr, user, None)
return super(account_invoice_line, self).create(cr, user, vals, context)
def write(self, cr, user, ids, vals, context=None):
if vals.has_key('state'):
if vals['state'] != 'article':
vals['product_id']= False
vals['uos_id']= False
vals['account_id']= self._default_account(cr, user, None)
vals['price_unit']= False
vals['price_subtotal']= False
vals['quantity']= 0
vals['discount']= False
vals['invoice_line_tax_id']= False
vals['account_analytic_id']= False
if vals['state'] == 'line':
vals['name'] = ' '
if vals['state'] == 'break':
vals['name'] = ' '
return super(account_invoice_line, self).write(cr, user, ids, vals, context)
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default['state'] = self.browse(cr, uid, id).state
return super(account_invoice_line, self).copy(cr, uid, id, default, context)
def _fnct(self, cr, uid, id, name, args, context):
res = {}
for m in self.browse(cr, uid, id):
if m.state != 'article':
if m.state == 'line':
res[m.id] = '-----------------------------------------'
elif m.state == 'break':
res[m.id] = 'PAGE BREAK'
else:
res[m.id] = ' '
else:
[(temp)] = self.pool.get('account.account').name_get(cr, uid, [m.account_id.id], context=context)
res[m.id] = temp[1]
return res
_name = "account.invoice.line"
_order = "invoice_id, sequence asc"
_description = "Invoice Line"
_inherit = "account.invoice.line"
_columns = {
'state': fields.selection([
('article','Product'),
('title','Title'),
('text','Note'),
('subtotal','Sub Total'),
('line','Separator Line'),
('break','Page Break'),]
,'Type', select=True, required=True),
'sequence': fields.integer('Sequence Number'),
'functional_field': fields.function(_fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type='char', fnct_search=None, obj=None, method=True, store=False, string="Source Account"),
}
def _default_account(self, cr, uid, context=None):
cr.execute("select id from account_account where code = 0 LIMIT 1")
res=cr.fetchone()
return res[0]
_defaults = {
'state': lambda *a: 'article',
# 'account_id': _default_account
}
account_invoice_line()
class one2many_mod2(fields.one2many):
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
if not context:
context = {}
if not values:
values = {}
res = {}
for id in ids:
res[id] = []
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids),('state','=','article')], limit=self._limit)
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
res[r[self._fields_id]].append( r['id'] )
return res
# def copy(self, cr, uid, id, default=None, context=None):
# if default is None:
# default = {}
# default['line_ids'] = False
# return super(account_invoice, self).copy(cr, uid, id, default, context)
class account_invoice(osv.osv):
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default['invoice_line'] = False
return super(account_invoice, self).copy(cr, uid, id, default, context)
_inherit = "account.invoice"
_columns = {
'abstract_line_ids': fields.one2many('account.invoice.line', 'invoice_id', 'Invoice Lines',readonly=True, states={'draft':[('readonly',False)]}),
'invoice_line': one2many_mod2('account.invoice.line', 'invoice_id', 'Invoice Lines',readonly=True, states={'draft':[('readonly',False)]}),
}
account_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<terp>
<data>
<wizard string="Formatted Inv. + Message"
model="account.invoice"
name="wizard.notify_message"
id="wizard_notify_message"
keyword="client_print_multi"
/>
<report id="account_invoices_1"
string="Formatted Inv."
model="account.invoice"
name="account.invoice.layout"
rml="account_invoice_layout/report/report_account_invoice_layout.rml"
auto="False"/>
</data>
</terp>

View File

@ -0,0 +1,90 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="view_invoice_line_form_inherit_1">
<field name="name">account.invoice.line.form.inherit_1</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">
<xpath expr="/form/notebook/page/field[@name='name']" position="before">
<field name="state" select="1" on_change="_onchange_invoice_line_view(state)" />
<field name="sequence"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_invoice_line_tree_inherit_1">
<field name="name">account.invoice.line.tree.inherit_1</field>
<field name="model">account.invoice.line</field>
<field name="inherit_id" ref="account.view_invoice_line_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<xpath expr="/tree/field[@name='name']" position="before">
<field name="sequence" string="Seq."/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_invoice_line_tree_inherit_2">
<field name="name">account.invoice.line.tree.inherit_2</field>
<field name="model">account.invoice.line</field>
<field name="inherit_id" ref="view_invoice_line_tree_inherit_1"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<xpath expr="/tree/field[@name='account_id']" position="replace">
<field name="functional_field"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="account_invoice_form_inherit_1">
<field name="name">account.invoice.form.inherit_1</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='invoice_line']" position="replace">
<field name="abstract_line_ids" colspan="4" nolabel="1"/>
</xpath>
</field>
</record>
<!-- notification message views -->
<record model="ir.ui.view" id="view_notify_message_tree">
<field name="name">notify.message.tree</field>
<field name="model">notify.message</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Messages">
<field name="name"/>
<field name="msg"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_notify_message_form">
<field name="name">notify.message.form</field>
<field name="model">notify.message</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Messages">
<separator string="Write a notification or a wishful message." colspan="4"/>
<field name="name" select="1" colspan="2" />
<field name="msg" select="1" colspan="2"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="notify_mesage_tree_form">
<field name="name">Write Messages</field>
<field name="res_model">notify.message</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Notification Message" id="menu_finan_config_notify_message" parent="account.menu_finance_configuration"/>
<menuitem name="All Notification Messages" id="menu_notify_mesage_tree_form" action="notify_mesage_tree_form" parent="menu_finan_config_notify_message"/>
</data>
</terp>

View File

@ -0,0 +1,5 @@
# -*- encoding: utf-8 -*-
import report_account_invoice_layout
import special_message_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,192 @@
# -*- encoding: utf-8 -*-
import time
import pooler
from report import report_sxw
parents = {
'tr':1,
'li':1,
'story': 0,
'section': 0
}
class account_invoice_1(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_invoice_1, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'invoice_lines': self.invoice_lines,
'repeat_In':self.repeat_In,
})
self.context = context
def repeat_In(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[]):
self._node.data = ''
node = self._find_parent(self._node, nodes_parent or parents)
ns = node.nextSibling
value=['tax_types','quantity','uos','price_unit','discount','price_subtotal','currency']
type=['string','string','string','string','string','string','string']
width=[62,42,20,62,51,50,24]
td=7
tableFlag=0
if not lst:
lst.append(1)
for ns in node.childNodes :
if tableFlag==1:
break
if ns and ns.nodeName!='#text' and ns.tagName=='blockTable' and td :
tableFlag=1
width_str = ns._attrs['colWidths'].nodeValue
ns.removeAttribute('colWidths')
total_td = td * len(value)
if not width:
for v in value:
width.append(30)
for v in range(len(value)):
width_str +=',%d'%width[v]
ns.setAttribute('colWidths',width_str)
child_list = ns.childNodes
for child in child_list:
if child.nodeName=='tr':
lc = child.childNodes[1]
# for t in range(td):
i=0
for v in value:
t2="[[%s['type']=='text' and removeParentNode('tr')]]"%(name)
t1= "[[ %s['%s'] ]]"%(name,v)
t3="[[ %s['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]]"%name
newnode = lc.cloneNode(1)
newnode.childNodes[1].lastChild.data = t1 + t2 +t3
# newnode.childNodes[1].lastChild.data=[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]]
child.appendChild(newnode)
newnode=False
i+=1
return super(account_invoice_1,self).repeatIn(lst, name, nodes_parent=False)
def invoice_lines(self,invoice):
result =[]
sub_total={}
info=[]
invoice_list=[]
res={}
list_in_seq={}
ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)])
ids.sort()
for id in range(0,len(ids)):
info = self.pool.get('account.invoice.line').browse(self.cr, self.uid,ids[id], self.context.copy())
list_in_seq[info]=info.sequence
# invoice_list +=[info]
i=1
j=0
final=sorted(list_in_seq.items(), lambda x, y: cmp(x[1], y[1]))
invoice_list=[x[0] for x in final]
sum_flag={}
sum_flag[j]=-1
for entry in invoice_list:
res={}
if entry.state=='article':
self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%d'%(entry.id))
tax_ids=self.cr.fetchall()
if tax_ids==[]:
res['tax_types']=''
else:
tax_names_dict={}
for item in range(0,len(tax_ids)) :
self.cr.execute('select name from account_tax where id=%d'%(tax_ids[item][0]))
type=self.cr.fetchone()
tax_names_dict[item] =type[0]
tax_names = ','.join([tax_names_dict[x] for x in range(0,len(tax_names_dict))])
res['tax_types']=tax_names
res['name']=entry.name
res['quantity']="%.2f"%(entry.quantity)
res['price_unit']="%.2f"%(entry.price_unit)
res['discount']="%.2f"%(entry.discount)
res['price_subtotal']="%.2f"%(entry.price_subtotal)
sub_total[i]=entry.price_subtotal
i=i+1
res['note']=entry.note
res['currency']=invoice.currency_id.code
res['type']=entry.state
if entry.uos_id.id==False:
res['uos']=''
else:
uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'])
res['uos']=uos_name['name']
else:
res['quantity']=''
res['price_unit']=''
res['discount']=''
res['tax_types']=''
res['type']=entry.state
res['note']=entry.note
res['uos']=''
if entry.state=='subtotal':
res['name']=entry.name
sum=0
sum_id=0
if sum_flag[j]==-1:
temp=1
else:
temp=sum_flag[j]
for sum_id in range(temp,len(sub_total)+1):
sum+=sub_total[sum_id]
sum_flag[j+1]= sum_id +1
j=j+1
res['price_subtotal']="%.2f"%(sum)
res['currency']=invoice.currency_id.code
res['quantity']=''
res['price_unit']=''
res['discount']=''
res['tax_types']=''
res['uos']=''
elif entry.state=='title':
res['name']=entry.name
res['price_subtotal']=''
res['currency']=''
elif entry.state=='text':
res['name']=entry.name
res['price_subtotal']=''
res['currency']=''
elif entry.state=='line':
res['quantity']='____________'
res['price_unit']='______________'
res['discount']='____________'
res['tax_types']='_________________'
res['uos']='_____'
res['name']='________________________________________'
res['price_subtotal']='_______________________'
res['currency']='_______'
elif entry.state=='break':
res['type']=entry.state
res['name']=entry.name
res['price_subtotal']=''
res['currency']=''
else:
res['name']=entry.name
res['price_subtotal']=''
res['currency']=invoice.currency_id.code
result.append(res)
return result
report_sxw.report_sxw('report.account.invoice.layout', 'account.invoice', 'addons/account_invoice_layout/report/report_account_invoice_layout.rml', parser=account_invoice_1)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,297 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="34.0" y1="28.0" width="527" height="786"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="3.0" leading="8"/>
<paraStyle name="P9" fontName="Times-Italic" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="3.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Bold" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="CENTER"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="LEFT"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P21" fontName="Times-Bold" fontSize="8.0" leading="8" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P22" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P23" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="2.0" spaceAfter="3.0" leading="10"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<images/>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<para style="P1">[[ setLang(o.partner_id.lang) ]]</para>
<blockTable colWidths="295.0,232.0" style="Tableau2">
<tr>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="Standard">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
<para style="Standard">[[ o.address_invoice_id.title or '' ]] [[ o.address_invoice_id.name ]]</para>
<para style="Standard">[[ o.address_invoice_id.street ]]</para>
<para style="Standard">[[ o.address_invoice_id.street2 or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.state_id and o.address_invoice_id.state_id.name or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.country_id and o.address_invoice_id.country_id.name or '' ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="Standard">Tel.&#xA0;: [[ o.address_invoice_id.phone or removeParentNode('para') ]]</para>
<para style="Standard">Fax&#xA0;: [[ o.address_invoice_id.fax or removeParentNode('para') ]]</para>
<para style="Standard">VAT&#xA0;: [[ o.partner_id.vat or removeParentNode('para') ]]</para>
</td>
</tr>
</blockTable>
<para style="P14">
<font color="white"> </font>
</para>
<para style="P23">Invoice [[ ((o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')) or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
<para style="P23">PRO-FORMA [[ ((o.type == 'out_invoice' and o.state == 'proforma') or removeParentNode('para')) and '' ]]</para>
<para style="P23">Draft Invoice [[ ((o.type == 'out_invoice' and o.state == 'draft') or removeParentNode('para')) and '' ]]</para>
<para style="P23">Canceled Invoice [[ ((o.type == 'out_invoice' and o.state == 'cancel') or removeParentNode('para')) and '' ]]</para>
<para style="P23">Refund [[ (o.type=='out_refund' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
<para style="P23">Supplier Refund [[ (o.type=='in_refund' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
<para style="P16">
<font face="Times-Roman">Supplier Invoice [[ (o.type=='in_invoice' or removeParentNode('para')) and '' ]]</font>
<font face="Times-Roman">[[ o.number ]]</font>
</para>
<para style="P15">
<font color="white"> </font>
</para>
<para style="P17">
<font face="Times-Roman">Document</font>
<font face="Times-Roman">:</font>
<font face="Times-Roman">[[o.name]]</font>
</para>
<para style="P17">
<font face="Times-Roman">Invoice Date: </font>
<font face="Times-Roman">[[o.date_invoice]]</font>
</para>
<para style="P18">
<font face="Times-Roman">Customer Ref:</font> [[ o.address_invoice_id.partner_id.ref or '/' ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description</para>
</td>
<td>
<para style="P4">Taxes</para>
</td>
<td>
<para style="P4">Quantity</para>
</td>
<td>
<para style="P4">Unit Price</para>
</td>
<td>
<para style="P4">Disc. (%)</para>
</td>
<td>
<para style="P4">Price</para>
</td>
</tr>
</blockTable>
<section>
<para style="P20">[[ repeat_In(invoice_lines(o), 'a') ]]</para>
<blockTable colWidths="0.0,216.0" style="Tableau7">
<tr>
<td>
<para style="P8">[[ a['type']=='text' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="Table Contents"><font>[[ a['type']=='title' and ( setTag('font','font',{'size':'11.5'})) ]][[ (a['type']=='title' or a['type']=='subtotal') and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['type']=='text' and removeParentNode('font') or a['name'] ]]</font></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="453.0,74.0" style="Tableau8">
<tr>
<td>
<para style="Table Contents">[[ a['type']=='text' and a['name'] or removeParentNode('table') ]]</para>
</td>
<td>
<para style="P8">[[ a['type']=='text' and '' or removeParentNode('table') ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="28.0,499.0" style="Tableau8">
<tr>
<td>
<para style="P21">[[ a['note']=='' and removeParentNode('table') ]][[ repeatIn(( a['note'] and a['note'].splitlines()) or [], 'note') ]]</para>
</td>
<td>
<para style="P9">[[ note or removeParentNode('table') ]]</para>
</td>
</tr>
</blockTable>
<pageBreak>[[ a['type']!='break' and removeParentNode('pageBreak')]]</pageBreak>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description [[ a['type']!='break' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="P4">Taxes</para>
</td>
<td>
<para style="P4">Quantity</para>
</td>
<td>
<para style="P4">Unit Price</para>
</td>
<td>
<para style="P4">Disc. (%)</para>
</td>
<td>
<para style="P4">Price</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="215.0,313.0" style="Tableau3">
<tr>
<td>
<blockTable colWidths="81.0,73.0,60.0" style="Tableau4">
<tr>
<td>
<para style="P10">Tax</para>
</td>
<td>
<para style="P8">Base</para>
</td>
<td>
<para style="P8">Amount</para>
</td>
</tr>
<tr>
<td>
<para style="P5">
<font face="Times-Roman">[[ repeatIn(o.tax_line,'t') ]]</font> [[ t.name ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % t.base ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % t.amount]]</para>
</td>
</tr>
</blockTable>
</td>
<td>
<blockTable colWidths="214.0,95.0" style="Tableau5">
<tr>
<td>
<para style="P7">Total (excl. taxes):</para>
</td>
<td>
<para style="P12">[[ '%.2f' % o.amount_untaxed ]] [[o.currency_id.code ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P7">Taxes:</para>
</td>
<td>
<para style="P12">[[ '%.2f' % o.amount_tax ]] [[o.currency_id.code ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P13">Total <font face="Times-Roman">(incl. taxes):</font>
</para>
</td>
<td>
<para style="P22">[[ '%.2f' % o.amount_total ]] [[o.currency_id.code ]]</para>
</td>
</tr>
</blockTable>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P19">[[ format(o.comment or '') ]]</para>
<para style="P19">
<font color="white"> </font>
</para>
<para style="P19">[[ format((o.payment_term and o.payment_term.note) or '') ]]</para>
</story>
</document>

View File

@ -0,0 +1,225 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# 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 time
from report import report_sxw
import pooler
parents = {
'tr':1,
'li':1,
'story': 0,
'section': 0
}
class account_invoice_with_message(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_invoice_with_message, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'spcl_msg': self.spcl_msg,
'invoice_lines': self.invoice_lines,
'repeat_In':self.repeat_In,
})
self.context = context
def repeat_In(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[]):
self._node.data = ''
node = self._find_parent(self._node, nodes_parent or parents)
ns = node.nextSibling
value=['tax_types','quantity','uos','price_unit','discount','price_subtotal','currency']
type=['string','string','string','string','string','string','string']
width=[62,42,20,62,51,50,24]
td=7
tableFlag=0
if not lst:
lst.append(1)
for ns in node.childNodes :
if tableFlag==1:
break
if ns and ns.nodeName!='#text' and ns.tagName=='blockTable' and td :
tableFlag=1
width_str = ns._attrs['colWidths'].nodeValue
ns.removeAttribute('colWidths')
total_td = td * len(value)
if not width:
for v in value:
width.append(30)
for v in range(len(value)):
width_str +=',%d'%width[v]
ns.setAttribute('colWidths',width_str)
child_list = ns.childNodes
for child in child_list:
if child.nodeName=='tr':
lc = child.childNodes[1]
# for t in range(td):
i=0
for v in value:
t2="[[%s['type']=='text' and removeParentNode('tr')]]"%(name)
t1= "[[ %s['%s'] ]]"%(name,v)
t3="[[ %s['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]]"%name
newnode = lc.cloneNode(1)
newnode.childNodes[1].lastChild.data = t1 + t2 +t3
# newnode.childNodes[1].lastChild.data=[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]]
child.appendChild(newnode)
newnode=False
i+=1
return super(account_invoice_with_message,self).repeatIn(lst, name, nodes_parent=False)
def spcl_msg(self, form):
account_msg_data = pooler.get_pool(self.cr.dbname).get('notify.message').browse(self.cr, self.uid, form['message'])
msg = account_msg_data.msg
return msg
def invoice_lines(self,invoice):
result =[]
sub_total={}
info=[]
invoice_list=[]
res={}
list_in_seq={}
ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)])
ids.sort()
for id in range(0,len(ids)):
info = self.pool.get('account.invoice.line').browse(self.cr, self.uid,ids[id], self.context.copy())
list_in_seq[info]=info.sequence
# invoice_list +=[info]
i=1
j=0
final=sorted(list_in_seq.items(), lambda x, y: cmp(x[1], y[1]))
invoice_list=[x[0] for x in final]
sum_flag={}
sum_flag[j]=-1
for entry in invoice_list:
res={}
if entry.state=='article':
self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%d'%(entry.id))
tax_ids=self.cr.fetchall()
if tax_ids==[]:
res['tax_types']=''
else:
tax_names_dict={}
for item in range(0,len(tax_ids)) :
self.cr.execute('select name from account_tax where id=%d'%(tax_ids[item][0]))
type=self.cr.fetchone()
tax_names_dict[item] =type[0]
tax_names = ','.join([tax_names_dict[x] for x in range(0,len(tax_names_dict))])
res['tax_types']=tax_names
res['name']=entry.name
res['quantity']="%.2f"%(entry.quantity)
res['price_unit']="%.2f"%(entry.price_unit)
res['discount']="%.2f"%(entry.discount)
res['price_subtotal']="%.2f"%(entry.price_subtotal)
sub_total[i]=entry.price_subtotal
i=i+1
res['note']=entry.note
res['currency']=invoice.currency_id.code
res['type']=entry.state
if entry.uos_id.id==False:
res['uos']=''
else:
uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'])
res['uos']=uos_name['name']
else:
res['quantity']=''
res['price_unit']=''
res['discount']=''
res['tax_types']=''
res['type']=entry.state
res['note']=entry.note
res['uos']=''
if entry.state=='subtotal':
res['name']=entry.name
sum=0
sum_id=0
if sum_flag[j]==-1:
temp=1
else:
temp=sum_flag[j]
for sum_id in range(temp,len(sub_total)+1):
sum+=sub_total[sum_id]
sum_flag[j+1]= sum_id +1
j=j+1
res['price_subtotal']="%.2f"%(sum)
res['currency']=invoice.currency_id.code
res['quantity']=''
res['price_unit']=''
res['discount']=''
res['tax_types']=''
res['uos']=''
elif entry.state=='title':
res['name']=entry.name
res['price_subtotal']=''
res['currency']=''
elif entry.state=='text':
res['name']=entry.name
res['price_subtotal']=''
res['currency']=''
elif entry.state=='line':
res['quantity']='____________'
res['price_unit']='______________'
res['discount']='____________'
res['tax_types']='_________________'
res['uos']='_____'
res['name']='________________________________________'
res['price_subtotal']='_______________________'
res['currency']='_______'
elif entry.state=='break':
res['type']=entry.state
res['name']=entry.name
res['price_subtotal']=''
res['currency']=''
else:
res['name']=entry.name
res['price_subtotal']=''
res['currency']=invoice.currency_id.code
result.append(res)
return result
report_sxw.report_sxw('report.notify_account.invoice', 'account.invoice', 'addons/account_invoice_layout/report/special_message_invoice.rml', parser=account_invoice_with_message)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,300 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="34.0" y1="28.0" width="527" height="786"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="3.0" leading="8"/>
<paraStyle name="P9" fontName="Times-Italic" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="3.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Bold" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="CENTER"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="LEFT"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P21" fontName="Times-Bold" fontSize="8.0" leading="8" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P22" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P23" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="2.0" spaceAfter="3.0" leading="10"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<images/>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<para style="P1">[[ setLang(o.partner_id.lang) ]]</para>
<blockTable colWidths="295.0,232.0" style="Tableau2">
<tr>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="Standard">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
<para style="Standard">[[ o.address_invoice_id.title or '' ]] [[ o.address_invoice_id.name ]]</para>
<para style="Standard">[[ o.address_invoice_id.street ]]</para>
<para style="Standard">[[ o.address_invoice_id.street2 or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.state_id and o.address_invoice_id.state_id.name or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.country_id and o.address_invoice_id.country_id.name or '' ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="Standard">Tel.&#xA0;: [[ o.address_invoice_id.phone or removeParentNode('para') ]]</para>
<para style="Standard">Fax&#xA0;: [[ o.address_invoice_id.fax or removeParentNode('para') ]]</para>
<para style="Standard">VAT&#xA0;: [[ o.partner_id.vat or removeParentNode('para') ]]</para>
</td>
</tr>
</blockTable>
<para style="P14">
<font color="white"> </font>
</para>
<para style="P23">Invoice [[ ((o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')) or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
<para style="P23">PRO-FORMA [[ ((o.type == 'out_invoice' and o.state == 'proforma') or removeParentNode('para')) and '' ]]</para>
<para style="P23">Draft Invoice [[ ((o.type == 'out_invoice' and o.state == 'draft') or removeParentNode('para')) and '' ]]</para>
<para style="P23">Canceled Invoice [[ ((o.type == 'out_invoice' and o.state == 'cancel') or removeParentNode('para')) and '' ]]</para>
<para style="P23">Refund [[ (o.type=='out_refund' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
<para style="P23">Supplier Refund [[ (o.type=='in_refund' or removeParentNode('para')) and '' ]] [[ o.number ]]</para>
<para style="P16">
<font face="Times-Roman">Supplier Invoice [[ (o.type=='in_invoice' or removeParentNode('para')) and '' ]]</font>
<font face="Times-Roman">[[ o.number ]]</font>
</para>
<para style="P15">
<font color="white"> </font>
</para>
<para style="P17">
<font face="Times-Roman">Document</font>
<font face="Times-Roman">:</font>
<font face="Times-Roman">[[o.name]]</font>
</para>
<para style="P17">
<font face="Times-Roman">Invoice Date: </font>
<font face="Times-Roman">[[o.date_invoice]]</font>
</para>
<para style="P18">
<font face="Times-Roman">Customer Ref:</font> [[ o.address_invoice_id.partner_id.ref or '/' ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description</para>
</td>
<td>
<para style="P4">Taxes</para>
</td>
<td>
<para style="P4">Quantity</para>
</td>
<td>
<para style="P4">Unit Price</para>
</td>
<td>
<para style="P4">Disc. (%)</para>
</td>
<td>
<para style="P4">Price</para>
</td>
</tr>
</blockTable>
<section>
<para style="P20">[[ repeat_In(invoice_lines(o), 'a') ]]</para>
<blockTable colWidths="0.0,216.0" style="Tableau7">
<tr>
<td>
<para style="P8">[[ a['type']=='text' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="Table Contents"><font>[[ a['type']=='title' and ( setTag('font','font',{'size':'11.5'})) ]][[ (a['type']=='title' or a['type']=='subtotal') and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['type']=='text' and removeParentNode('font') or a['name'] ]]</font></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="453.0,74.0" style="Tableau8">
<tr>
<td>
<para style="Table Contents">[[ a['type']=='text' and a['name'] or removeParentNode('table') ]]</para>
</td>
<td>
<para style="P8">[[ a['type']=='text' and '' or removeParentNode('table') ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="28.0,499.0" style="Tableau8">
<tr>
<td>
<para style="P21">[[ a['note']=='' and removeParentNode('table') ]][[ repeatIn(( a['note'] and a['note'].splitlines()) or [], 'note') ]]</para>
</td>
<td>
<para style="P9">[[ note or removeParentNode('table') ]]</para>
</td>
</tr>
</blockTable>
<pageBreak>[[ a['type']!='break' and removeParentNode('pageBreak')]]</pageBreak>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description [[ a['type']!='break' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="P4">Taxes</para>
</td>
<td>
<para style="P4">Quantity</para>
</td>
<td>
<para style="P4">Unit Price</para>
</td>
<td>
<para style="P4">Disc. (%)</para>
</td>
<td>
<para style="P4">Price</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="215.0,313.0" style="Tableau3">
<tr>
<td>
<blockTable colWidths="81.0,73.0,60.0" style="Tableau4">
<tr>
<td>
<para style="P10">Tax</para>
</td>
<td>
<para style="P8">Base</para>
</td>
<td>
<para style="P8">Amount</para>
</td>
</tr>
<tr>
<td>
<para style="P5">
<font face="Times-Roman">[[ repeatIn(o.tax_line,'t') ]]</font> [[ t.name ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % t.base ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % t.amount]]</para>
</td>
</tr>
</blockTable>
</td>
<td>
<blockTable colWidths="214.0,95.0" style="Tableau5">
<tr>
<td>
<para style="P7">Total (excl. taxes):</para>
</td>
<td>
<para style="P12">[[ '%.2f' % o.amount_untaxed ]] [[o.currency_id.code ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P7">Taxes:</para>
</td>
<td>
<para style="P12">[[ '%.2f' % o.amount_tax ]] [[o.currency_id.code ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P13">Total <font face="Times-Roman">(incl. taxes):</font>
</para>
</td>
<td>
<para style="P22">[[ '%.2f' % o.amount_total ]] [[o.currency_id.code ]]</para>
</td>
</tr>
</blockTable>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P19">[[ format(o.comment or '') ]]</para>
<para style="P19">
<font color="white"> </font>
</para>
<para style="P19">[[ format((o.payment_term and o.payment_term.note) or '') ]]</para>
<para style="P19">[[ repeatIn((spcl_msg(data['form']) and spcl_msg(data['form']).splitlines()) or [], 'note') ]]</para>
<para style="P19">[[ note or removeParentNode('table') ]]</para>
</story>
</document>

View File

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
import invoice_special_message
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,32 @@
# -*- encoding: utf-8 -*-
import wizard
import time
import datetime
import pooler
invoice_form = """<?xml version="1.0"?>
<form string="Select Message">
<field name="message"/>
</form>"""
invoice_fields = {
'message': {'string': 'Message', 'type': 'many2one', 'relation': 'notify.message', 'required': True},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':invoice_form, 'fields':invoice_fields, 'state':[('end','Cancel'),('print','Print')]},
},
'print': {
'actions': [],
'result': {'type':'print', 'report':'notify_account.invoice', 'state':'end'},
},
}
wizard_report('wizard.notify_message')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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 report
import account
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
{
"name" : "Reporting of Balancesheet for accounting",
"version" : "1.0",
"depends" : ["account"],
"author" : "Tiny",
"description": """Financial and accounting reporting""",
"category" : "Generic Modules/Accounting",
"init_xml" : [ ],
"demo_xml" : [ ],
"update_xml" : [
"account_view.xml",
"account_report.xml",
"account_data.xml",
],
# "translations" : {
# "fr": "i18n/french_fr.csv"
# },
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,134 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# 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 time
import netsvc
from osv import fields, osv
from tools.misc import currency
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class color_rml(osv.osv):
_name = "color.rml"
_description = "Rml Colors"
_columns = {
'name': fields.char('Name', size=64, required=True),
'code': fields.char('code',size=64,required=True),
}
color_rml()
class account_report_bs(osv.osv):
_name = "account.report.bs"
_description = "Account reporting for Balance Sheet"
_font = [
('',''),
('Courier','Courier'),
('Courier-Bold','Courier-Bold'),
('Courier-BoldOblique','Courier-BoldOblique'),
('Courier-Oblique','Courier-Oblique'),
('Helvetica','Helvetica'),
('Helvetica-Bold','Helvetica-Bold'),
('Helvetica-Oblique','Helvetica-Oblique'),
('Times-Bold','Times-Bold'),
('Times-BoldItalic','Times-BoldItalic'),
('Times-Italic','Times-Italic'),
('Times-Roman','Times-Roman'),
]
_color = [
('', ''),
('green','Green'),
('red','Red'),
('pink','Pink'),
('blue','Blue'),
('yellow','Yellow'),
('cyan','Cyan'),
('lightblue','Light Blue'),
('orange','Orange'),
]
_style = [
('', ''),
('h1','Header 1'),
('h2','Header 2'),
('h3','Header 3'),
]
def onchange_parent_id(self, cr, uid, ids, parent_id):
v={}
if parent_id:
acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
v['type']=acc.type
if int(acc.style) < 6:
v['style'] = str(int(acc.style)+1)
return {'value': v}
_columns = {
'name': fields.char('Name', size=64, required=True),
'sequence': fields.integer('Sequence'),
'code': fields.char('Code', size=64, required=True),
'account_id': fields.many2many('account.account', 'account_report_rel', 'report_id', 'account_id', 'Accounts'),
'note': fields.text('Note'),
# 'style': fields.selection(_style, 'Style'),
'color_font' : fields.many2one('color.rml','Font Color'),
'color_back' : fields.many2one('color.rml','Back Color'),
'font_style' : fields.selection(_font, 'Font'),
'parent_id': fields.many2one('account.report.bs', 'Parent'),
'child_id': fields.one2many('account.report.bs', 'parent_id', 'Childs'),
'report_type' : fields.selection([('only_obj', 'Report Objects Only'),('with_account', 'Report Objects With Accounts'),('acc_with_child', 'Report Objects With Accounts and child of Accounts')],"Report Type")
}
_defaults = {
'report_type': lambda *a :'only_obj'
}
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
if not args:
args=[]
if not context:
context={}
ids = []
if name:
ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
if not ids:
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
else:
ids = self.search(cr, user, args, limit=limit, context=context)
return self.name_get(cr, user, ids, context=context)
_sql_constraints = [
('code_uniq', 'unique (code)', 'The code of the report entry must be unique !')
]
account_report_bs()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,491 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="color.rml" id="c1">
<field name="name">aliceblue</field>
<field name="code">aliceblue</field>
</record>
<record model="color.rml" id="c2">
<field name="name">antiquewhite</field>
<field name="code">antiquewhite</field>
</record>
<record model="color.rml" id="c3">
<field name="name">aqua</field>
<field name="code">aqua</field>
</record>
<record model="color.rml" id="c4">
<field name="name">aquamarine</field>
<field name="code">aquamarine</field>
</record>
<record model="color.rml" id="c5">
<field name="name">azure</field>
<field name="code">azure</field>
</record>
<record model="color.rml" id="c6">
<field name="name">beige</field>
<field name="code">beige</field>
</record>
<record model="color.rml" id="c7">
<field name="name">bisque</field>
<field name="code">bisque</field>
</record>
<record model="color.rml" id="c8">
<field name="name">black</field>
<field name="code">black</field>
</record>
<record model="color.rml" id="c9">
<field name="name">blanchedalmond</field>
<field name="code">blanchedalmond</field>
</record>
<record model="color.rml" id="c10">
<field name="name">blue</field>
<field name="code">blue</field>
</record>
<record model="color.rml" id="c11">
<field name="name">blueviolet</field>
<field name="code">blueviolet</field>
</record>
<record model="color.rml" id="c12">
<field name="name">brown</field>
<field name="code">brown</field>
</record>
<record model="color.rml" id="c13">
<field name="name">burlywood</field>
<field name="code">burlywood</field>
</record>
<record model="color.rml" id="c14">
<field name="name">cadetblue</field>
<field name="code">cadetblue</field>
</record>
<record model="color.rml" id="c15">
<field name="name">chartreuse</field>
<field name="code">chartreuse</field>
</record>
<record model="color.rml" id="c16">
<field name="name">chocolate</field>
<field name="code">chocolate</field>
</record>
<record model="color.rml" id="c17">
<field name="name">coral</field>
<field name="code">coral</field>
</record>
<record model="color.rml" id="c18">
<field name="name">cornflower</field>
<field name="code">cornflower</field>
</record>
<record model="color.rml" id="c19">
<field name="name">cornsilk</field>
<field name="code">cornsilk</field>
</record>
<record model="color.rml" id="c20">
<field name="name">crimson</field>
<field name="code">crimson</field>
</record>
<record model="color.rml" id="c21">
<field name="name">cyan</field>
<field name="code">cyan</field>
</record>
<record model="color.rml" id="c22">
<field name="name">darkblue</field>
<field name="code">darkblue</field>
</record>
<record model="color.rml" id="c23">
<field name="name">darkcyan</field>
<field name="code">darkcyan</field>
</record>
<record model="color.rml" id="c24">
<field name="name">darkgoldenrod</field>
<field name="code">darkgoldenrod</field>
</record>
<record model="color.rml" id="c25">
<field name="name">darkgray</field>
<field name="code">darkgray</field>
</record>
<record model="color.rml" id="c26">
<field name="name">darkgreen</field>
<field name="code">darkgreen</field>
</record>
<record model="color.rml" id="c27">
<field name="name">darkkhaki</field>
<field name="code">darkkhaki</field>
</record>
<record model="color.rml" id="c28">
<field name="name">darkmagenta</field>
<field name="code">darkmagenta</field>
</record>
<record model="color.rml" id="c29">
<field name="name">darkolivegreen</field>
<field name="code">darkolivegreen</field>
</record>
<record model="color.rml" id="c30">
<field name="name">darkorange</field>
<field name="code">darkorange</field>
</record>
<record model="color.rml" id="c31">
<field name="name">darkorchid</field>
<field name="code">darkorchid</field>
</record>
<record model="color.rml" id="c32">
<field name="name">darkred</field>
<field name="code">darkred</field>
</record>
<record model="color.rml" id="c33">
<field name="name">darksalmon</field>
<field name="code">darksalmon</field>
</record>
<record model="color.rml" id="c34">
<field name="name">darkseagreen</field>
<field name="code">darkseagreen</field>
</record>
<record model="color.rml" id="c35">
<field name="name">darkslateblue</field>
<field name="code">darkslateblue</field>
</record>
<record model="color.rml" id="c36">
<field name="name">darkslategray</field>
<field name="code">darkslategray</field>
</record>
<record model="color.rml" id="c37">
<field name="name">darkturquoise</field>
<field name="code">darkturquoise</field>
</record>
<record model="color.rml" id="c38">
<field name="name">darkviolet</field>
<field name="code">darkviolet</field>
</record>
<record model="color.rml" id="c39">
<field name="name">deeppink</field>
<field name="code">deeppink</field>
</record>
<record model="color.rml" id="c40">
<field name="name">deepskyblue</field>
<field name="code">deepskyblue</field>
</record>
<record model="color.rml" id="c41">
<field name="name">dimgray</field>
<field name="code">dimgray</field>
</record>
<record model="color.rml" id="c42">
<field name="name">dodgerblue</field>
<field name="code">dodgerblue</field>
</record>
<record model="color.rml" id="c43">
<field name="name">firebrick</field>
<field name="code">firebrick</field>
</record>
<record model="color.rml" id="c44">
<field name="name">floralwhite</field>
<field name="code">floralwhite</field>
</record>
<record model="color.rml" id="c45">
<field name="name">forestgreen</field>
<field name="code">forestgreen</field>
</record>
<record model="color.rml" id="c46">
<field name="name">fuchsia</field>
<field name="code">fuchsia</field>
</record>
<record model="color.rml" id="c47">
<field name="name">gainsboro</field>
<field name="code">gainsboro</field>
</record>
<record model="color.rml" id="c48">
<field name="name">ghostwhite</field>
<field name="code">ghostwhite</field>
</record>
<record model="color.rml" id="c49">
<field name="name">gold</field>
<field name="code">gold</field>
</record>
<record model="color.rml" id="c50">
<field name="name">goldenrod</field>
<field name="code">goldenrod</field>
</record>
<record model="color.rml" id="c51">
<field name="name">gray</field>
<field name="code">gray</field>
</record>
<record model="color.rml" id="c52">
<field name="name">green</field>
<field name="code">green</field>
</record>
<record model="color.rml" id="c53">
<field name="name">greenyellow</field>
<field name="code">greenyellow</field>
</record>
<record model="color.rml" id="c54">
<field name="name">honeydew</field>
<field name="code">honeydew</field>
</record>
<record model="color.rml" id="c55">
<field name="name">hotpink</field>
<field name="code">hotpink</field>
</record>
<record model="color.rml" id="c56">
<field name="name">indianred</field>
<field name="code">indianred</field>
</record>
<record model="color.rml" id="c57">
<field name="name">indigo</field>
<field name="code">indigo</field>
</record>
<record model="color.rml" id="c58">
<field name="name">ivory</field>
<field name="code">ivory</field>
</record>
<record model="color.rml" id="c59">
<field name="name">khaki</field>
<field name="code">khaki</field>
</record>
<record model="color.rml" id="c60">
<field name="name">lavender</field>
<field name="code">lavender</field>
</record>
<record model="color.rml" id="c61">
<field name="name">lavenderblush</field>
<field name="code">lavenderblush</field>
</record>
<record model="color.rml" id="c62">
<field name="name">lawngreen</field>
<field name="code">lawngreen</field>
</record>
<record model="color.rml" id="c63">
<field name="name">lemonchiffon</field>
<field name="code">lemonchiffon</field>
</record>
<record model="color.rml" id="c64">
<field name="name">lightblue</field>
<field name="code">lightblue</field>
</record>
<record model="color.rml" id="c65">
<field name="name">lightcoral</field>
<field name="code">lightcoral</field>
</record>
<record model="color.rml" id="c66">
<field name="name">lightcyan</field>
<field name="code">lightcyan</field>
</record>
<record model="color.rml" id="c67">
<field name="name">lightgoldenrodyellow</field>
<field name="code">lightgoldenrodyellow</field>
</record>
<record model="color.rml" id="c68">
<field name="name">lightgreen</field>
<field name="code">lightgreen</field>
</record>
<record model="color.rml" id="c69">
<field name="name">lightpink</field>
<field name="code">lightpink</field>
</record>
<record model="color.rml" id="c70">
<field name="name">lightsalmon</field>
<field name="code">lightsalmon</field>
</record>
<record model="color.rml" id="c71">
<field name="name">lightseagreen</field>
<field name="code">lightseagreen</field>
</record>
<record model="color.rml" id="c72">
<field name="name">lightskyblue</field>
<field name="code">lightskyblue</field>
</record>
<record model="color.rml" id="c73">
<field name="name">lightslategray</field>
<field name="code">lightslategray</field>
</record>
<record model="color.rml" id="c74">
<field name="name">lightsteelblue</field>
<field name="code">lightsteelblue</field>
</record>
<record model="color.rml" id="c75">
<field name="name">lightyellow</field>
<field name="code">lightyellow</field>
</record>
<record model="color.rml" id="c76">
<field name="name">lime</field>
<field name="code">lime</field>
</record>
<record model="color.rml" id="c77">
<field name="name">limegreen</field>
<field name="code">limegreen</field>
</record>
<record model="color.rml" id="c78">
<field name="name">linen</field>
<field name="code">linen</field>
</record>
<record model="color.rml" id="c79">
<field name="name">magenta</field>
<field name="code">magenta</field>
</record>
<record model="color.rml" id="c80">
<field name="name">maroon</field>
<field name="code">maroon</field>
</record>
<record model="color.rml" id="c81">
<field name="name">mediumaquamarine</field>
<field name="code">mediumaquamarine</field>
</record>
<record model="color.rml" id="c82">
<field name="name">mediumblue</field>
<field name="code">mediumblue</field>
</record>
<record model="color.rml" id="c83">
<field name="name">mediumorchid</field>
<field name="code">mediumorchid</field>
</record>
<record model="color.rml" id="c84">
<field name="name">mediumpurple</field>
<field name="code">mediumpurple</field>
</record>
<record model="color.rml" id="c85">
<field name="name">mediumseagreen</field>
<field name="code">mediumseagreen</field>
</record>
<record model="color.rml" id="c86">
<field name="name">mediumslateblue</field>
<field name="code">mediumslateblue</field>
</record>
<record model="color.rml" id="c87">
<field name="name">mediumspringgreen</field>
<field name="code">mediumspringgreen</field>
</record>
<record model="color.rml" id="c88">
<field name="name">mediumturquoise</field>
<field name="code">mediumturquoise</field>
</record>
<record model="color.rml" id="c89">
<field name="name">mediumvioletred</field>
<field name="code">mediumvioletred</field>
</record>
<record model="color.rml" id="c90">
<field name="name">midnightblue</field>
<field name="code">midnightblue</field>
</record>
<record model="color.rml" id="c91">
<field name="name">mintcream</field>
<field name="code">mintcream</field>
</record>
<record model="color.rml" id="c92">
<field name="name">mistyrose</field>
<field name="code">mistyrose</field>
</record>
<record model="color.rml" id="c93">
<field name="name">moccasin</field>
<field name="code">moccasin</field>
</record>
<record model="color.rml" id="c94">
<field name="name">navajowhite</field>
<field name="code">navajowhite</field>
</record>
<record model="color.rml" id="c95">
<field name="name">navy</field>
<field name="code">navy</field>
</record>
<record model="color.rml" id="c96">
<field name="name">oldlace</field>
<field name="code">oldlace</field>
</record>
<record model="color.rml" id="c97">
<field name="name">olive</field>
<field name="code">olive</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<terp>
<data>
<!-- <report id="balancesheet_report"
string="BalanceSheet Report"
model="account.report.bs"
name="account.report.bs"
rml="addons/account_report_bs/report/account_report_bs.rml"
auto="False"/>-->
<wizard
string="Account balance"
model="account.report.bs"
name="account.account.balancesheet.report"
keyword="client_print_multi"
id="wizard_balance_report"/>
</data>
</terp>

View File

@ -0,0 +1,65 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="view_account_report_bs_form">
<field name="name">account.report.bs.form</field>
<field name="model">account.report.bs</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account reporting">
<notebook>
<page string="General">
<field name="name" select="1" colspan="3"/>
<field name="code" select="1"/>
<field name="parent_id" select = "1" />
<field name="sequence"/>
<field name="color_font"/>
<field name="color_back"/>
<field name="font_style" />
<field name="report_type" />
<newline/>
<separator string="Accounts" colspan="4"/>
<field name="account_id" colspan="4" nolable="1" domain="[('type','=','view')]"/>
</page><page string="Notes">
<field name="note" nolabel="1" colspan="4"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_account_report_tree_bs">
<field name="name">account.report.report.tree.bs</field>
<field name="model">account.report.bs</field>
<field name="type">tree</field>
<field name="field_parent">child_id</field>
<field name="arch" type="xml">
<tree string="Account reporting">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_tree_bs">
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.report.bs</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_account_report_tree_bs"/>
</record>
<menuitem name="Balance Sheet Report" id="menu_finan_config_BSheet" parent="account.menu_finance_configuration"/>
<menuitem name="Balance Sheet Report" id="action_account_report_bs_form" action="action_account_tree_bs" parent="menu_finan_config_BSheet"/>
<record model="ir.actions.act_window" id="acc_bs_report_action_form">
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.report.bs</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_account_report_bs_form"/>
</record>
<menuitem name="Balance Sheet Rrport Form" id="bs_report_action_form" action="acc_bs_report_action_form" parent="menu_finan_config_BSheet"/>
</data>
</terp>

View File

@ -0,0 +1,32 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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_report_bs
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,149 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# 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 time
import pooler
import locale
from report import report_sxw
#from addons.account.wizard import wizard_account_balance_report
parents = {
'tr':1,
'li':1,
'story': 0,
'section': 0
}
class account_report_bs(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_report_bs, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'lines': self.lines,
})
self.context = context
def line_total(self,line_id,ctx):
_total = 0
bsline= self.pool.get('account.report.bs').browse(self.cr,self.uid,[line_id])[0]
bsline_accids = bsline.account_id
res =self.pool.get('account.report.bs').read(self.cr,self.uid,[line_id],['account_id','child_id'])[0]
for acc_id in res['account_id']:
acc = self.pool.get('account.account').browse(self.cr,self.uid,[acc_id],ctx)[0]
_total += acc.balance
bsline_reportbs = res['child_id']
for report in bsline_reportbs:
_total +=self.line_total(report,ctx)
return _total
def lines(self, form, ids={}, done=None, level=1):
if not ids:
ids = self.ids
if not ids:
return []
if not done:
done={}
result = []
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
report_objs = self.pool.get('account.report.bs').browse(self.cr, self.uid, ids)
title_name = False
if level==1:
title_name = report_objs[0].name
def cmp_code(x, y):
return cmp(x.code, y.code)
report_objs.sort(cmp_code)
for report_obj in report_objs:
if report_obj.id in done:
continue
done[report_obj.id] = 1
color_font = ''
color_back = ''
if report_obj.color_font:
color_font = report_obj.color_font.name
if report_obj.color_back:
color_back = report_obj.color_back.name
res = {
'code': report_obj.code,
'name': report_obj.name,
'level': level,
'balance': self.line_total(report_obj.id,ctx),
'color_font':color_font,
'color_back':color_back,
'font_style' : report_obj.font_style
}
result.append(res)
report_type = report_obj.report_type
if report_type != 'only_obj':
account_ids = self.pool.get('account.report.bs').read(self.cr,self.uid,[report_obj.id],['account_id'])[0]['account_id']
for account_id in account_ids:
res1 = self.check_child_id(account_id,level,ctx,report_type)
result += res1
if report_obj.child_id:
ids2 = [(x.code,x.id) for x in report_obj.child_id]
ids2.sort()
result += self.lines(form, [x[1] for x in ids2], done, level+1)
return result
def check_child_id(self,account_id,level,ctx,report_type):
account = self.pool.get('account.account').browse(self.cr,self.uid,[account_id],ctx)[0]
result = []
res = {
'code': account.code,
'name': account.name,
'level': level+1,
'balance': account.balance,
'color_font' : 'black',
'color_back' :'pink',
'font_style' : 'Helvetica-BoldOblique',
}
result.append(res)
if report_type != 'with_account':
acc_child_id = self.pool.get('account.account').search(self.cr,self.uid,[('parent_id','=',[account_id]),('type','=','view')])
for child_id in acc_child_id :
result += self.check_child_id(child_id,level+1,ctx,report_type)
return result
# def _sum_credit(self):
# return self.sum_credit
#
# def _sum_debit(self):
# return self.sum_debit
report_sxw.report_sxw('report.account.report.bs', 'account.report.bs', 'addons/account_reporting/report/account_report_bs.rml', parser=account_report_bs)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,133 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="35.0" y1="35.0" width="525" height="772"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="15.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents"><font color='blue'>[[ company.name ]]</font></para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4"><font color='blue'>Currency: [[ company.currency_id.name ]]</font></para>
</td>
</tr>
</blockTable>
<para style="P8"><font color='blue'>Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</font></para>
<para style="P7">[[repeatIn(objects,'o') ]]</para>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1"><font>[[o.name]] [[o.font_style and (setTag('font','font',{'face':o.font_style} ) ) ]] [[ o.color_font and ( setTag('font','font',{'color':o.color_font.name})) ]] [[ o.color_back and ( setTag('para','para',{'backColor':o.color_back.name})) ]]</font></para>
</td>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="70.0,341.0,131.0" style="Table7">
<tr>
<td>
<para style="P12" ><font color='blue'>Code</font></para>
</td>
<td>
<para style="P12"><font color='blue'>Account name</font></para>
</td>
<td>
<para style="P13"><font color='blue'>Balance</font></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="75.0,341.0,131.0" style="Table4">
<tr>
<td>
<para style="P10">[[ repeatIn(lines(data['form']), 'a') ]]<font> [[ a['code'] ]] [[ a['font_style'] and (setTag('font','font',{'face':a['font_style'] })) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
</td>
<td>
<para style="P17"><font>[[ '.. .. '*(a['level']-1) ]] [[ a['name'] ]] [[ a['font_style'] and (setTag('font','font',{'face':a['font_style']})) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
</td>
<td>
<para style="P18"><font>[[ '%.2f'% a['balance'] ]] [[ a['font_style'] and (setTag('font','font', {'face':a['font_style'] })) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,32 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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_balance_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,105 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# 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 ir
import pooler
import time
import netsvc
from osv import fields, osv
import mx.DateTime
from mx.DateTime import RelativeDateTime
from tools import config
dates_form = '''<?xml version="1.0"?>
<form string="Customize Report">
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
</form>'''
# <field name="report_type" colspan="4"/>
dates_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
# 'report_type': {'string': 'Report Type','type': 'selection','selection': [('only_obj', 'Report Objects Only'),('with_account', 'Report Objects With Accounts'),('acc_with_child', 'Report Objects With Accounts and child of Accounts'),],'required': True},
}
back_form='''<?xml version="1.0"?>
<form string="Notification">
<separator string="You might have done following mistakes.Please correct them and try again." colspan="4"/>
<separator string="1. You have selected more than 3 years in any case." colspan="4"/>
<separator string="2. You have not selected 'Percentage' option,but you have selected more than 2 years." colspan="4"/>
<label string="You can select maximum 3 years.Please check again." colspan="4"/>
</form>'''
back_fields={
}
zero_form='''<?xml version="1.0"?>
<form string="Notification">
<label string="You have to select atleast 1 Fiscal Year. Try again."/>
</form>'''
zero_fields={
}
periods_form='''<?xml version="1.0"?>
<form string="Set Periods">
<separator string="Select Period(s) (All periods if empty)" colspan="4"/>
<field name="periods" colspan="4" nolabel="1"/>
</form>'''
periods_fields={
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['report_type'] = 'only_obj'
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print BalanceSheet')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.report.bs', 'state':'end'}
}
}
wizard_report('account.account.balancesheet.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,6 @@
# -*- encoding: utf-8 -*-
#
# Generated by the Tiny ERP module recorder !
#
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
{
"name" : "Association Verticalisation",
"version" : "Association Verticalisation",
"author" : "Tiny",
"website" : "http://tinyerp.com",
"category" : "Vertical Modules/Parametrization",
"description": """Simplification of the interface for associations.""",
"depends" : ["hr","crm_configuration","event"],
"init_xml" : [],
"demo_xml" : ["crm_fund_data.xml"],
"update_xml" : ["crm_fund_demo.xml",
"aso_data.xml",
"aso_vertical_view.xml",
],
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,30 @@
<?xml version="1.0" ?>
<terp>
<data>
<record id="noone" model="res.groups">
<field name="name">No One</field>
</record>
<record id="hr.menu_hr_root" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
<record id="crm.menu_crm" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
<record id="product.menu_product_pricelist_main" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
<record id="product.menu_product_price_type_action" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
<record id="product.menu_product_pricelist_type_action" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
<record id="product.menu_product_variant_action" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
<record id="product.menu_product_template_action" model="ir.ui.menu">
<field eval="[(6,0,[ref('noone')])]" name="groups_id"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" ?>
<terp>
<data>
<record id="crm_configuration.menu_crm_case_category_act_meetings" model="ir.ui.menu">
<field eval="&quot;Calendar of Meetings&quot;" name="name"/>
<field eval="&quot;terp-calendar&quot;" name="icon"/>
<field eval="False" name="parent_id"/>
</record>
<record id="association_vertical.menu_crm_case_fund_raise" model="ir.ui.menu">
<field eval="&quot;Fund Raising&quot;" name="name"/>
<field eval="&quot;terp-account&quot;" name="icon"/>
<field eval="False" name="parent_id"/>
</record>
<record id="product.menu_main_product" model="ir.ui.menu">
<field model="ir.ui.menu" name="parent_id" search="[('name','=','Configuration'),('parent_id.name','=','Financial Management')]"/>
</record>
<!-- For Shortcuts menu -->
<record id="ir_ui_view_sc_mymeetings1" model="ir.ui.view_sc">
<field ref="crm_configuration.menu_crm_case_categ_meet_my" name="res_id"/>
<field eval="&quot;ir.ui.menu&quot;" name="resource"/>
<field eval="&quot;My Meetings&quot;" name="name"/>
<field name="user_id" ref="base.user_admin"/>
</record>
<record id="ir_ui_view_sc_myopenprojects1" model="ir.ui.view_sc">
<field ref="project.menu_open_view_my_project_open" name="res_id"/>
<field eval="&quot;ir.ui.menu&quot;" name="resource"/>
<field eval="&quot;My Open Projects&quot;" name="name"/>
<field name="user_id" ref="base.user_admin"/>
</record>
<record id="ir_ui_view_sc_products0" model="ir.ui.view_sc">
<field ref="product.menu_products" name="res_id"/>
<field eval="&quot;ir.ui.menu&quot;" name="resource"/>
<field eval="&quot;Products&quot;" name="name"/>
<field name="user_id" ref="base.user_admin"/>
</record>
<record id="ir_ui_view_sc_events0" model="ir.ui.view_sc">
<field ref="event.menu_event_event" name="res_id"/>
<field eval="&quot;ir.ui.menu&quot;" name="resource"/>
<field eval="&quot;Events&quot;" name="name"/>
<field name="user_id" ref="base.user_admin"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,146 @@
<?xml version="1.0" ?>
<terp>
<data noupdate="1">
<record id="crm_case_helpingstreetchildren0" model="crm.case">
<field eval="0.5" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund3"/>
<field eval="3.0" name="duration"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="250000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-01 10:35:50')" name="date"/>
<field name="categ_id" ref="association_vertical.categ_fund1"/>
<field eval="&quot;Helping Street Children&quot;" name="name"/>
<field eval="&quot;info@opensides.be&quot;" name="email_from"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_helpingearthquakevictims0" model="crm.case">
<field eval="0.8" name="probability"/>
<field name="partner_address_id" ref="base.main_address"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund4"/>
<field name="partner_id" ref="base.main_partner"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_admin"/>
<field eval="&quot;draft&quot;" name="state"/>
<field eval="2000000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-05 12:35:50')" name="date"/>
<field eval="8.0" name="duration"/>
<field name="categ_id" ref="association_vertical.categ_fund1"/>
<field eval="&quot;Helping earthquake victims&quot;" name="name"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_donatingbookstoschoollibraries0" model="crm.case">
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund1"/>
<field eval="5.0" name="duration"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_admin"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="500000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-07 13:50:50')" name="date"/>
<field name="categ_id" ref="association_vertical.categ_fund2"/>
<field eval="&quot;Donating books to school libraries&quot;" name="name"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_renovatinggovernmentschools0" model="crm.case">
<field name="partner_address_id" ref="base.res_partner_address_7"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund2"/>
<field eval="3.0" name="duration"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;draft&quot;" name="state"/>
<field eval="1000000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-12 15:10:50')" name="date"/>
<field name="categ_id" ref="association_vertical.categ_fund2"/>
<field eval="4.3" name="duration"/>
<field eval="&quot;Renovating government schools&quot;" name="name"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_donatingambulancestohospitals0" model="crm.case">
<field name="partner_address_id" ref="base.res_partner_address_13"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund4"/>
<field name="partner_id" ref="base.res_partner_14"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_admin"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="5000000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-17 19:00:15')" name="date"/>
<field eval="3" name="duration"/>
<field name="categ_id" ref="association_vertical.categ_fund3"/>
<field eval="&quot;Donating ambulances to hospitals&quot;" name="name"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_donatinghospitalequipments0" model="crm.case">
<field name="partner_address_id" ref="base.res_partner_address_2"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund3"/>
<field name="partner_id" ref="base.res_partner_10"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_admin"/>
<field eval="&quot;done&quot;" name="state"/>
<field eval="10000000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-27 09:00:15')" name="date"/>
<field eval="12" name="duration"/>
<field name="categ_id" ref="association_vertical.categ_fund3"/>
<field eval="&quot;Donating hospital equipments&quot;" name="name"/>
<field eval="&quot;contact@tecsas.fr&quot;" name="email_from"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_encouragingarts0" model="crm.case">
<field name="partner_address_id" ref="base.res_partner_address_14"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund2"/>
<field eval="7.0" name="duration"/>
<field name="partner_id" ref="base.res_partner_15"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;draft&quot;" name="state"/>
<field eval="10000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-01 10:00:15')" name="date"/>
<field name="categ_id" ref="association_vertical.categ_fund4"/>
<field eval="&quot;Encouraging arts&quot;" name="name"/>
</record>
</data>
<data noupdate="1">
<record id="crm_case_promotingculturalprogramsandpreservingdyingartforms0" model="crm.case">
<field eval="1.0" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_1"/>
<field eval="1" name="active"/>
<field name="category2_id" ref="association_vertical.categ2_fund1"/>
<field eval="6.0" name="duration"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_admin"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="800000.0" name="planned_cost"/>
<field name="section_id" ref="association_vertical.section_support4"/>
<field eval="time.strftime('%Y-%m-24 22:00:15')" name="date"/>
<field name="categ_id" ref="association_vertical.categ_fund4"/>
<field eval="&quot;Promoting cultural programs and preserving dying art forms&quot;" name="name"/>
<field eval="&quot;info@opensides.be&quot;" name="email_from"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,242 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
<record model="crm.case.section" id="section_support4">
<field name="name">Fund Raising</field>
<field name="code">funds</field>
</record>
<!-- CASE CATEGORY(categ_id) -->
<record model="crm.case.categ" id="categ_fund1">
<field name="name">Social Rehabilitation And Rural Upliftment</field>
<field name="section_id" ref="section_support4"/>
</record>
<record model="crm.case.categ" id="categ_fund2">
<field name="name">Learning And Education</field>
<field name="section_id" ref="section_support4"/>
</record>
<record model="crm.case.categ" id="categ_fund3">
<field name="name">Healthcare</field>
<field name="section_id" ref="section_support4"/>
</record>
<record model="crm.case.categ" id="categ_fund4">
<field name="name">Arts And Culture</field>
<field name="section_id" ref="section_support4"/>
</record>
<!-- CASE CATEGORY2(category2_id) -->
<record model="crm.case.category2" id="categ2_fund1">
<field name="name">Cash</field>
<field name="section_id" ref="section_support4"/>
</record>
<record model="crm.case.category2" id="categ2_fund2">
<field name="name">Cheque</field>
<field name="section_id" ref="section_support4"/>
</record>
<record model="crm.case.category2" id="categ2_fund3">
<field name="name">Credit Card</field>
<field name="section_id" ref="section_support4"/>
</record>
<record model="crm.case.category2" id="categ2_fund4">
<field name="name">Demand Draft</field>
<field name="section_id" ref="section_support4"/>
</record>
<!-- MENU -->
<menuitem name="CRM &amp; SRM/Fund Raising" id="menu_crm_case_fund_raise"/>
<record model="ir.actions.act_window" id="crm_case_category_act_fund1">
<field name="name">Funds</field>
<field name="res_model">crm.case</field>
<field name="view_mode">form,graph</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+')]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund1">
<field name="sequence" eval="2"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund1">
<field name="sequence" eval="1"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund1"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/New Fund Opportunity" id="menu_crm_case_categ0_act_fund" action="crm_case_category_act_fund1"/>
<!-- My Funds -->
<record model="ir.actions.act_window" id="crm_case_category_act_fund_my1">
<field name="name">My Funds</field>
<field name="res_model">crm.case</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+'),(\'user_id\',\'=\',uid)]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_my1">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_my1">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_my1">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my1"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/My Funds" id="menu_crm_case_category_act_fund_my1" action="crm_case_category_act_fund_my1"/>
<record model="ir.actions.act_window" id="crm_case_category_act_fund_my2">
<field name="name">My Funds Waiting Validation</field>
<field name="res_model">crm.case</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+'),(\'user_id\',\'=\',uid),(\'state\',\'=\',\'draft\')]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_my2">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my2"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_my2">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my2"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_my2">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my2"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/My Funds/My Funds Waiting Validation" id="menu_crm_case_categ0_act_fund_my2" action="crm_case_category_act_fund_my2"/>
<record model="ir.actions.act_window" id="crm_case_category_act_fund_my3">
<field name="name">My Funds To Be Processed</field>
<field name="res_model">crm.case</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+'),(\'user_id\',\'=\',uid),(\'state\',\'=\',\'open\')]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_my3">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_my3">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_my3">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_my3"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/My Funds/My Funds To Be Processed" id="menu_crm_case_categ0_act_fund_my3" action="crm_case_category_act_fund_my3"/>
<!-- All Funds -->
<record model="ir.actions.act_window" id="crm_case_category_act_fund_all1">
<field name="name">All Funds</field>
<field name="res_model">crm.case</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+')]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_all1">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_all1">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all1"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_all1">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all1"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/All Funds" id="menu_crm_case_categ0_act_fund_all1" action="crm_case_category_act_fund_all1"/>
<record model="ir.actions.act_window" id="crm_case_category_act_fund_all2">
<field name="name">All Funds Waiting Validation</field>
<field name="res_model">crm.case</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+'),(\'state\',\'=\',\'draft\')]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_all2">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all2"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_all2">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all2"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_all2">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all2"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/All Funds/All Funds Waiting Validation" id="menu_crm_case_categ0_act_fund_all2" action="crm_case_category_act_fund_all2"/>
<record model="ir.actions.act_window" id="crm_case_category_act_fund_all3">
<field name="name">All Funds To Be Processed</field>
<field name="res_model">crm.case</field>
<field name="view_mode">tree,form,graph</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support4)+'),(\'state\',\'=\',\'open\')]'"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_tree_view_fund_all3">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="crm_configuration.crm_case_tree_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_form_view_fund_all3">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_configuration.crm_case_form_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all3"/>
</record>
<record model="ir.actions.act_window.view" id="action_crm_tag_graph_view_fund_all3">
<field name="sequence" eval="3"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="crm_configuration.crm_case_graph_view_fund"/>
<field name="act_window_id" ref="crm_case_category_act_fund_all3"/>
</record>
<menuitem name="CRM &amp; SRM/Fund Raising/All Funds/All Funds To Be Processed" id="menu_crm_case_categ0_act_fund_all3" action="crm_case_category_act_fund_all3"/>
</data>
</terp>

View File

@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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 auction
import wizard
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,15 @@
# -*- encoding: utf-8 -*-
{
"name" : "Auction module",
"version" : "1.0",
"depends" : ["base","account","l10n_be","hr"],
"update_xml" : ["auction_view.xml", "auction_report.xml", "auction_wizard.xml"],
"demo_xml" : [
"auction_demo.xml"
],
"init_xml" : ["auction_sequence.xml"],
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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