[REF] account
bzr revid: vth@tinyerp.com-20101011102300-59rukbdh3ps9m2dm
This commit is contained in:
@@ -146,7 +146,7 @@ class account_analytic_account(osv.osv):
|
||||
from account_analytic_line \
|
||||
where account_id IN %s \
|
||||
and invoice_id is null \
|
||||
GROUP BY account_analytic_line.account_id" ,(parent_ids,))
|
||||
GROUP BY account_analytic_line.account_id", (parent_ids,))
|
||||
for account_id, lwd in cr.fetchall():
|
||||
if account_id not in res:
|
||||
res[account_id] = {}
|
||||
@@ -258,7 +258,7 @@ class account_analytic_account(osv.osv):
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_journal.type = 'sale' \
|
||||
group by account_analytic_line.account_id" ,(parent_ids,))
|
||||
group by account_analytic_line.account_id", (parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = round(sum,2)
|
||||
|
||||
@@ -436,7 +436,7 @@ class account_analytic_account_summary_user(osv.osv):
|
||||
'account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True),
|
||||
'unit_amount': fields.function(_unit_amount, method=True, type='float',
|
||||
string='Total Time'),
|
||||
'user' : fields.many2one('res.users', 'User'),
|
||||
'user': fields.many2one('res.users', 'User'),
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
@@ -484,7 +484,7 @@ class account_analytic_account_summary_user(osv.osv):
|
||||
if fields==None:
|
||||
fields = self._columns.keys()
|
||||
|
||||
# construct a clause for the rules :
|
||||
# construct a clause for the rules:
|
||||
d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name, 'read', context=context)
|
||||
|
||||
# all inherited fields + all non inherited fields for which the attribute whose name is in load is True
|
||||
@@ -493,7 +493,7 @@ class account_analytic_account_summary_user(osv.osv):
|
||||
res = []
|
||||
cr.execute('SELECT MAX(id) FROM res_users')
|
||||
max_user = cr.fetchone()[0]
|
||||
if len(fields_pre) :
|
||||
if fields_pre:
|
||||
fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre)
|
||||
for i in range(0, len(ids), cr.IN_MAX):
|
||||
sub_ids = ids[i:i+cr.IN_MAX]
|
||||
@@ -661,14 +661,14 @@ class account_analytic_account_summary_month(osv.osv):
|
||||
if fields==None:
|
||||
fields = self._columns.keys()
|
||||
|
||||
# construct a clause for the rules :
|
||||
# construct a clause for the rules:
|
||||
d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name)
|
||||
|
||||
# all inherited fields + all non inherited fields for which the attribute whose name is in load is True
|
||||
fields_pre = filter(lambda x: x in self._columns and getattr(self._columns[x],'_classic_write'), fields) + self._inherits.values()
|
||||
|
||||
res = []
|
||||
if len(fields_pre) :
|
||||
if fields_pre:
|
||||
fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre)
|
||||
for i in range(0, len(ids), cr.IN_MAX):
|
||||
sub_ids = ids[i:i+cr.IN_MAX]
|
||||
|
||||
@@ -200,10 +200,10 @@ class account_analytic_plan_instance(osv.osv):
|
||||
for l in temp_list:
|
||||
if vals.has_key(l):
|
||||
for tempo in vals[l]:
|
||||
if acct_anal_acct.search(cr, uid, [('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]):
|
||||
if acct_anal_acct.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 %s and %s') % (str(item.min_required), str(item.max_required)))
|
||||
raise osv.except_osv(_('Value Error'),_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required)))
|
||||
|
||||
return super(account_analytic_plan_instance, self).create(cr, uid, vals, context)
|
||||
|
||||
@@ -240,7 +240,7 @@ class account_analytic_plan_instance_line(osv.osv):
|
||||
'rate': 100.0
|
||||
}
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
if not ids:
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, ['analytic_account_id'], context)
|
||||
res = []
|
||||
|
||||
@@ -29,8 +29,8 @@ class crossovered_analytic(report_sxw.rml_parse):
|
||||
self.localcontext.update( {
|
||||
'time': time,
|
||||
'lines': self._lines,
|
||||
'ref_lines' : self._ref_lines,
|
||||
'find_children':self.find_children,
|
||||
'ref_lines': self._ref_lines,
|
||||
'find_children': self.find_children,
|
||||
})
|
||||
self.base_amount = 0.00
|
||||
|
||||
@@ -99,7 +99,7 @@ class crossovered_analytic(report_sxw.rml_parse):
|
||||
if selected_ids:
|
||||
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()
|
||||
|
||||
@@ -133,7 +133,7 @@ class crossovered_analytic(report_sxw.rml_parse):
|
||||
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 \
|
||||
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)
|
||||
|
||||
+19
-19
@@ -156,7 +156,7 @@ class account_analytic_account(osv.osv):
|
||||
return dict([(i, res[i]) for i in ids])
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
if not ids:
|
||||
return []
|
||||
res = []
|
||||
for account in self.browse(cr, uid, ids, context=context):
|
||||
@@ -174,7 +174,7 @@ class account_analytic_account(osv.osv):
|
||||
return dict(res)
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Account Name', size=128, required=True),
|
||||
'name': fields.char('Account Name', size=128, required=True),
|
||||
'complete_name': fields.function(_complete_name_calc, method=True, type='char', string='Full Account Name'),
|
||||
'code': fields.char('Account Code', size=24),
|
||||
'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type', help='If you select the View Type, it means you won\'t allow to create journal entries using that account.'),
|
||||
@@ -182,14 +182,14 @@ class account_analytic_account(osv.osv):
|
||||
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
|
||||
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
|
||||
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'),
|
||||
'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'),
|
||||
'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit'),
|
||||
'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit'),
|
||||
'balance': fields.function(_balance_calc, method=True, type='float', string='Balance'),
|
||||
'debit': fields.function(_debit_calc, method=True, type='float', string='Debit'),
|
||||
'credit': fields.function(_credit_calc, method=True, type='float', string='Credit'),
|
||||
'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
|
||||
'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'),
|
||||
'partner_id' : fields.many2one('res.partner', 'Associated Partner'),
|
||||
'contact_id' : fields.many2one('res.partner.address', 'Contact'),
|
||||
'user_id' : fields.many2one('res.users', 'Account Manager'),
|
||||
'partner_id': fields.many2one('res.partner', 'Associated Partner'),
|
||||
'contact_id': fields.many2one('res.partner.address', 'Contact'),
|
||||
'user_id': fields.many2one('res.users', 'Account Manager'),
|
||||
'date_start': fields.date('Date Start'),
|
||||
'date': fields.date('Date End'),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
@@ -210,10 +210,10 @@ class account_analytic_account(osv.osv):
|
||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_defaults = {
|
||||
'type' : 'normal',
|
||||
'type': 'normal',
|
||||
'company_id': _default_company,
|
||||
'state' : 'open',
|
||||
'user_id' : lambda self, cr, uid, ctx : uid,
|
||||
'state': 'open',
|
||||
'user_id': lambda self, cr, uid, ctx: uid,
|
||||
'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False),
|
||||
'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False),
|
||||
'date_start': time.strftime('%Y-%m-%d')
|
||||
@@ -244,7 +244,7 @@ class account_analytic_account(osv.osv):
|
||||
partner = parent['partner_id'][0]
|
||||
else:
|
||||
partner = False
|
||||
res = {'value' : {}}
|
||||
res = {'value': {}}
|
||||
if partner:
|
||||
res['value']['partner_id'] = partner
|
||||
return res
|
||||
@@ -271,19 +271,19 @@ class account_analytic_line(osv.osv):
|
||||
_description = 'Analytic Line'
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Description', size=256, required=True),
|
||||
'date' : fields.date('Date', required=True, select=1),
|
||||
'amount' : fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price. Always expressed in the company main currency.', digits_compute=dp.get_precision('Account')),
|
||||
'unit_amount' : fields.float('Quantity', help='Specifies the amount of quantity to count.'),
|
||||
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
|
||||
'user_id' : fields.many2one('res.users', 'User'),
|
||||
'name': fields.char('Description', size=256, required=True),
|
||||
'date': fields.date('Date', required=True, select=1),
|
||||
'amount': fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price. Always expressed in the company main currency.', digits_compute=dp.get_precision('Account')),
|
||||
'unit_amount': fields.float('Quantity', help='Specifies the amount of quantity to count.'),
|
||||
'account_id': fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
|
||||
'user_id': fields.many2one('res.users', 'User'),
|
||||
'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c),
|
||||
'amount' : 0.00
|
||||
'amount': 0.00
|
||||
}
|
||||
|
||||
_order = 'date desc'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,7 +15,7 @@
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
@@ -38,7 +38,7 @@ class account_analytic_account(osv.osv):
|
||||
|
||||
_inherit = "account.analytic.account"
|
||||
_columns = {
|
||||
'journal_rate_ids' : fields.one2many('analytic_journal_rate_grid', 'account_id', 'Invoicing Rate per Journal'),
|
||||
'journal_rate_ids': fields.one2many('analytic_journal_rate_grid', 'account_id', 'Invoicing Rate per Journal'),
|
||||
}
|
||||
|
||||
account_analytic_account()
|
||||
@@ -92,7 +92,7 @@ class hr_analytic_timesheet(osv.osv):
|
||||
if to_invoice:
|
||||
res.setdefault('value',{})
|
||||
res['value']['to_invoice'] = to_invoice[0]
|
||||
|
||||
|
||||
return res
|
||||
|
||||
hr_analytic_timesheet()
|
||||
|
||||
@@ -40,7 +40,7 @@ class account_analytic_account(osv.osv):
|
||||
|
||||
_inherit = "account.analytic.account"
|
||||
_columns = {
|
||||
'user_product_ids' : fields.one2many('analytic_user_funct_grid', 'account_id', 'Users/Products Rel.'),
|
||||
'user_product_ids': fields.one2many('analytic_user_funct_grid', 'account_id', 'Users/Products Rel.'),
|
||||
}
|
||||
|
||||
account_analytic_account()
|
||||
|
||||
Reference in New Issue
Block a user