[MERGE]: Merge with lp:openobject-addons-trunk
bzr revid: ksa@tinyerp.co.in-20100923044751-479cuvfyn034g3ne bzr revid: ksa@tinyerp.co.in-20100924044503-41uy13ip2cpbt4g8
This commit is contained in:
@@ -114,8 +114,7 @@ class journal_print(report_sxw.rml_parse, common_report_header):
|
||||
journal_id = [journal_id]
|
||||
obj_mline = self.pool.get('account.move.line')
|
||||
self.cr.execute('update account_journal_period set state=%s where journal_id IN %s and period_id=%s and state=%s', ('printed', self.journal_ids, period_id, 'draft'))
|
||||
self.cr.commit()
|
||||
|
||||
|
||||
move_state = ['draft','posted']
|
||||
if self.target_move == 'posted':
|
||||
move_state = ['posted']
|
||||
@@ -158,4 +157,4 @@ class journal_print(report_sxw.rml_parse, common_report_header):
|
||||
|
||||
report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header='internal')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -23,15 +23,6 @@
|
||||
-
|
||||
!assert {model: account.invoice, id: account_invoice_currency, string: Customer Invoice is in Draft state}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I change the state of invoice to proforma2 by clicking PRO-FORMA button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_currency}
|
||||
-
|
||||
I check that now customer invoice is in the "proforma2" state
|
||||
-
|
||||
!assert {model: account.invoice, id: account_invoice_currency}:
|
||||
- state == 'proforma2'
|
||||
-
|
||||
Now I select USD as new currency
|
||||
-
|
||||
@@ -41,17 +32,23 @@
|
||||
I clicked on Change Currency button to change the currency
|
||||
-
|
||||
!python {model: account.change.currency}: |
|
||||
try:
|
||||
self.view_init(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
|
||||
self.view_init(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
|
||||
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
|
||||
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
|
||||
})
|
||||
self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
|
||||
})
|
||||
self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
|
||||
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
|
||||
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
|
||||
})
|
||||
except:
|
||||
print "You can not change currency for Open Invoice !"
|
||||
})
|
||||
-
|
||||
I change the state of invoice to proforma2 by clicking PRO-FORMA button
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_currency}
|
||||
-
|
||||
I check that now customer invoice is in the "proforma2" state
|
||||
-
|
||||
!assert {model: account.invoice, id: account_invoice_currency}:
|
||||
- state == 'proforma2'
|
||||
-
|
||||
I can't change the currency of invoice when it is not in draft state so i change the state to cancel
|
||||
-
|
||||
|
||||
@@ -143,7 +143,6 @@
|
||||
(data, format) = netsvc.LocalService('report.account.account.balance').create(cr, uid, [ref('account.bal'),ref('account.gpf')], data_dict, {'periods': []})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account-account_balance-normal.'+format), 'wb+').write(data)
|
||||
print "Account Balance Report in Normal mode - From Menu"
|
||||
|
||||
data_dict.update({'model': 'ir.ui.menu'})
|
||||
data_dict['form'].update({'active_ids':[ref('account.bal'),ref('account.gpf')]})
|
||||
@@ -174,7 +173,6 @@
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account-central_journal.'+format), 'wb+').write(data)
|
||||
|
||||
print "Central Journal Report - From Menu"
|
||||
data_dict.update({'model': 'ir.ui.menu'})
|
||||
data_dict['form'].update({'active_ids':journal_period_ids})
|
||||
|
||||
@@ -226,7 +224,6 @@
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger.'+format), 'wb+').write(data)
|
||||
|
||||
print "GL report from menu"
|
||||
data_dict.update({'model': 'ir.ui.menu'})
|
||||
data_dict['form'].update({'active_ids': acc_ids})
|
||||
(data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, [], data_dict, {})
|
||||
@@ -255,7 +252,6 @@
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-landscape.'+format), 'wb+').write(data)
|
||||
|
||||
print "GL report landscape mode from menu"
|
||||
data_dict.update({'model': 'ir.ui.menu'})
|
||||
data_dict['form'].update({'active_ids': acc_ids})
|
||||
(data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, [], data_dict, {})
|
||||
@@ -285,7 +281,6 @@
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account-print_journal.'+format), 'wb+').write(data)
|
||||
|
||||
print "Journal Report - From Menu"
|
||||
data_dict.update({'model': 'ir.ui.menu'})
|
||||
data_dict['form'].update({'active_ids':journal_period_ids})
|
||||
|
||||
|
||||
@@ -47,8 +47,3 @@ for a in account_lists:
|
||||
(a2['parent_right']<a['parent_right']))
|
||||
if a2['parent_id']==a['id']:
|
||||
assert (a2['parent_left']>a['parent_left']) and (a2['parent_right']<a['parent_right'])
|
||||
|
||||
print 'Tests Ok'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,210 @@ class account_analytic_account(osv.osv):
|
||||
_name = "account.analytic.account"
|
||||
_inherit = "account.analytic.account"
|
||||
|
||||
def _analysis_all(self, cr, uid, ids, fields, arg, context=None):
|
||||
dp = 2
|
||||
res = dict([(i, {}) for i in ids])
|
||||
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
accounts = self.browse(cr, uid, ids, context=context)
|
||||
|
||||
for f in fields:
|
||||
if f == 'user_ids':
|
||||
cr.execute('SELECT MAX(id) FROM res_users')
|
||||
max_user = cr.fetchone()[0]
|
||||
if parent_ids:
|
||||
cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \
|
||||
'WHERE account_id IN %s AND unit_amount <> 0.0', (parent_ids,))
|
||||
result = cr.fetchall()
|
||||
else:
|
||||
result = []
|
||||
for id in ids:
|
||||
res[id][f] = [int((id * max_user) + x[0]) for x in result]
|
||||
elif f == 'month_ids':
|
||||
if parent_ids:
|
||||
cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \
|
||||
'WHERE account_id IN %s AND unit_amount <> 0.0', (parent_ids,))
|
||||
result = cr.fetchall()
|
||||
else:
|
||||
result = []
|
||||
for id in ids:
|
||||
res[id][f] = [int(id * 1000000 + int(x[0])) for x in result]
|
||||
elif f == 'last_worked_invoiced_date':
|
||||
for id in ids:
|
||||
res[id][f] = 0.0
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id, max(date) \
|
||||
from account_analytic_line \
|
||||
where account_id IN %s \
|
||||
and invoice_id is not null \
|
||||
GROUP BY account_analytic_line.account_id;", (parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id][f] = sum
|
||||
for account in accounts:
|
||||
for child in account.child_ids:
|
||||
if res[account.id].get(f, '') < res.get(child.id, {}).get(f, ''):
|
||||
res[account.id][f] = res.get(child.id, {}).get(f, '')
|
||||
elif f == 'ca_to_invoice':
|
||||
for id in ids:
|
||||
res[id][f] = 0.0
|
||||
res2 = {}
|
||||
if parent_ids:
|
||||
# Amount uninvoiced hours to invoice at sale price
|
||||
# Warning
|
||||
# This computation doesn't take care of pricelist !
|
||||
# Just consider list_price
|
||||
cr.execute("""SELECT account_analytic_account.id, \
|
||||
COALESCE(sum (product_template.list_price * \
|
||||
account_analytic_line.unit_amount * \
|
||||
((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \
|
||||
AS ca_to_invoice \
|
||||
FROM product_template \
|
||||
join product_product \
|
||||
on product_template.id = product_product.product_tmpl_id \
|
||||
JOIN account_analytic_line \
|
||||
on account_analytic_line.product_id = product_product.id \
|
||||
JOIN account_analytic_journal \
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
JOIN account_analytic_account \
|
||||
on account_analytic_account.id = account_analytic_line.account_id \
|
||||
JOIN hr_timesheet_invoice_factor \
|
||||
on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \
|
||||
WHERE account_analytic_account.id IN %s \
|
||||
AND account_analytic_line.invoice_id is null \
|
||||
AND account_analytic_line.to_invoice IS NOT NULL \
|
||||
and account_analytic_journal.type in ('purchase','general') \
|
||||
GROUP BY account_analytic_account.id;""", (parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id][f] = round(sum, dp)
|
||||
|
||||
for account in accounts:
|
||||
#res.setdefault(account.id, 0.0)
|
||||
res2.setdefault(account.id, 0.0)
|
||||
for child in account.child_ids:
|
||||
if child.id != account.id:
|
||||
res[account.id][f] += res.get(child.id, {}).get(f, 0.0)
|
||||
res2[account.id] += res2.get(child.id, 0.0)
|
||||
# sum both result on account_id
|
||||
for id in ids:
|
||||
res[id][f] = round(res.get(id, {}).get(f, 0.0), dp) + round(res2.get(id, 0.0), 2)
|
||||
elif f == 'last_invoice_date':
|
||||
for id in ids:
|
||||
res[id][f] = ''
|
||||
if parent_ids:
|
||||
cr.execute ("select account_analytic_line.account_id, \
|
||||
date(max(account_invoice.date_invoice)) \
|
||||
from account_analytic_line \
|
||||
join account_invoice \
|
||||
on account_analytic_line.invoice_id = account_invoice.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_line.invoice_id is not null \
|
||||
GROUP BY account_analytic_line.account_id",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
for account in accounts:
|
||||
for child in account.child_ids:
|
||||
if res[account.id][f] < res.get(child.id, {}).get(f, ''):
|
||||
res[account.id][f] = res.get(child.id, {}).get(f, '')
|
||||
elif f == 'last_worked_date':
|
||||
for id in ids:
|
||||
res[id][f] = ''
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id, max(date) \
|
||||
from account_analytic_line \
|
||||
where account_id IN %s \
|
||||
and invoice_id is null \
|
||||
GROUP BY account_analytic_line.account_id" ,(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id][f] = sum
|
||||
for account in accounts:
|
||||
for child in account.child_ids:
|
||||
if res[account.id][f] < res.get(child.id, {}).get(f, ''):
|
||||
res[account.id][f] = res.get(child.id, {}).get(f, '')
|
||||
elif f == 'hours_qtt_non_invoiced':
|
||||
for id in ids:
|
||||
res[id][f] = 0.0
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \
|
||||
from account_analytic_line \
|
||||
join account_analytic_journal \
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_journal.type='general' \
|
||||
and invoice_id is null \
|
||||
AND to_invoice IS NOT NULL \
|
||||
GROUP BY account_analytic_line.account_id;",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id][f] = round(sum, dp)
|
||||
for account in accounts:
|
||||
for child in account.child_ids:
|
||||
if account.id != child.id:
|
||||
res[account.id][f] += res.get(child.id, {}).get(f, 0.0)
|
||||
for id in ids:
|
||||
res[id][f] = round(res[id][f], dp)
|
||||
elif f == 'hours_quantity':
|
||||
for id in ids:
|
||||
res[id][f] = 0.0
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \
|
||||
from account_analytic_line \
|
||||
join account_analytic_journal \
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_journal.type='general' \
|
||||
GROUP BY account_analytic_line.account_id",(parent_ids,))
|
||||
ff = cr.fetchall()
|
||||
for account_id, sum in ff:
|
||||
res[account_id][f] = round(sum, dp)
|
||||
for account in accounts:
|
||||
for child in account.child_ids:
|
||||
if account.id != child.id:
|
||||
res[account.id][f] += res.get(child.id, {}).get(f, 0.0)
|
||||
for id in ids:
|
||||
res[id][f] = round(res[id][f], dp)
|
||||
elif f == 'ca_theorical':
|
||||
# TODO Take care of pricelist and purchase !
|
||||
for id in ids:
|
||||
res[id][f] = 0.0
|
||||
res2 = {}
|
||||
# Warning
|
||||
# This computation doesn't take care of pricelist !
|
||||
# Just consider list_price
|
||||
if parent_ids:
|
||||
cr.execute("""select account_analytic_line.account_id as account_id, \
|
||||
COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \
|
||||
- (account_analytic_line.unit_amount * pt.list_price \
|
||||
* hr.factor)),0.0) as somme
|
||||
from account_analytic_line \
|
||||
left join account_analytic_journal \
|
||||
on (account_analytic_line.journal_id = account_analytic_journal.id) \
|
||||
join product_product pp \
|
||||
on (account_analytic_line.product_id = pp.id) \
|
||||
join product_template pt \
|
||||
on (pp.product_tmpl_id = pt.id) \
|
||||
join account_analytic_account a \
|
||||
on (a.id=account_analytic_line.account_id) \
|
||||
join hr_timesheet_invoice_factor hr \
|
||||
on (hr.id=a.to_invoice) \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and a.to_invoice IS NOT NULL \
|
||||
and account_analytic_journal.type IN ('purchase','general')
|
||||
GROUP BY account_analytic_line.account_id""",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res2[account_id] = round(sum, dp)
|
||||
|
||||
for account in accounts:
|
||||
res2.setdefault(account.id, 0.0)
|
||||
for child in account.child_ids:
|
||||
if account.id != child.id:
|
||||
res[account.id][f] += res.get(child.id, {}).get(f, 0.0)
|
||||
res[account.id][f] += res2.get(child.id, 0.0)
|
||||
|
||||
# sum both result on account_id
|
||||
for id in ids:
|
||||
res[id][f] = round(res[id][f], dp) + round(res2.get(id, 0.0), dp)
|
||||
|
||||
return res
|
||||
|
||||
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
@@ -44,101 +248,6 @@ class account_analytic_account(osv.osv):
|
||||
|
||||
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
|
||||
|
||||
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
res2 = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
# Amount uninvoiced hours to invoice at sale price
|
||||
# Warning
|
||||
# This computation doesn't take care of pricelist !
|
||||
# Just consider list_price
|
||||
cr.execute("""SELECT account_analytic_account.id, \
|
||||
COALESCE(sum (product_template.list_price * \
|
||||
account_analytic_line.unit_amount * \
|
||||
((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \
|
||||
AS ca_to_invoice \
|
||||
FROM product_template \
|
||||
join product_product \
|
||||
on product_template.id = product_product.product_tmpl_id \
|
||||
JOIN account_analytic_line \
|
||||
on account_analytic_line.product_id = product_product.id \
|
||||
JOIN account_analytic_journal \
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
JOIN account_analytic_account \
|
||||
on account_analytic_account.id = account_analytic_line.account_id \
|
||||
JOIN hr_timesheet_invoice_factor \
|
||||
on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \
|
||||
WHERE account_analytic_account.id IN %s \
|
||||
AND account_analytic_line.invoice_id is null \
|
||||
AND account_analytic_line.to_invoice IS NOT NULL \
|
||||
and account_analytic_journal.type in ('purchase','general') \
|
||||
GROUP BY account_analytic_account.id;""",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = round(sum,2)
|
||||
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, 0.0)
|
||||
res2.setdefault(obj_id, 0.0)
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if child_id != obj_id:
|
||||
res[obj_id] += res.get(child_id, 0.0)
|
||||
res2[obj_id] += res2.get(child_id, 0.0)
|
||||
# sum both result on account_id
|
||||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \
|
||||
from account_analytic_line \
|
||||
join account_analytic_journal \
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_journal.type='general' \
|
||||
and invoice_id is null \
|
||||
AND to_invoice IS NOT NULL \
|
||||
GROUP BY account_analytic_line.account_id;",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = round(sum,2)
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, 0.0)
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if child_id != obj_id:
|
||||
res[obj_id] += res.get(child_id, 0.0)
|
||||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \
|
||||
from account_analytic_line \
|
||||
join account_analytic_journal \
|
||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_journal.type='general' \
|
||||
GROUP BY account_analytic_line.account_id",(parent_ids,))
|
||||
ff = cr.fetchall()
|
||||
for account_id, sum in ff:
|
||||
res[account_id] = round(sum,2)
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, 0.0)
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if child_id != obj_id:
|
||||
res[obj_id] += res.get(child_id, 0.0)
|
||||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
@@ -155,117 +264,6 @@ class account_analytic_account(osv.osv):
|
||||
res[account_id] = round(sum,2)
|
||||
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
|
||||
|
||||
# TODO Take care of pricelist and purchase !
|
||||
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
res2 = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
# Warning
|
||||
# This computation doesn't take care of pricelist !
|
||||
# Just consider list_price
|
||||
if parent_ids:
|
||||
cr.execute("""select account_analytic_line.account_id as account_id, \
|
||||
COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \
|
||||
- (account_analytic_line.unit_amount * pt.list_price \
|
||||
* hr.factor)),0.0) as somme
|
||||
from account_analytic_line \
|
||||
left join account_analytic_journal \
|
||||
on (account_analytic_line.journal_id = account_analytic_journal.id) \
|
||||
join product_product pp \
|
||||
on (account_analytic_line.product_id = pp.id) \
|
||||
join product_template pt \
|
||||
on (pp.product_tmpl_id = pt.id) \
|
||||
join account_analytic_account a \
|
||||
on (a.id=account_analytic_line.account_id) \
|
||||
join hr_timesheet_invoice_factor hr \
|
||||
on (hr.id=a.to_invoice) \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and a.to_invoice IS NOT NULL \
|
||||
and account_analytic_journal.type IN ('purchase','general')
|
||||
GROUP BY account_analytic_line.account_id""",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res2[account_id] = round(sum,2)
|
||||
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, 0.0)
|
||||
res2.setdefault(obj_id, 0.0)
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if child_id != obj_id:
|
||||
res[obj_id] += res.get(child_id, 0.0)
|
||||
res[obj_id] += res2.get(child_id, 0.0)
|
||||
|
||||
# sum both result on account_id
|
||||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _last_worked_date_calc (self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id, max(date) \
|
||||
from account_analytic_line \
|
||||
where account_id IN %s \
|
||||
and invoice_id is null \
|
||||
GROUP BY account_analytic_line.account_id" ,(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, '')
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if res[obj_id] < res.get(child_id, ''):
|
||||
res[obj_id] = res.get(child_id, '')
|
||||
for id in ids:
|
||||
res[id] = res.get(id, '')
|
||||
return res
|
||||
|
||||
def _last_invoice_date_calc (self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute ("select account_analytic_line.account_id, \
|
||||
date(max(account_invoice.date_invoice)) \
|
||||
from account_analytic_line \
|
||||
join account_invoice \
|
||||
on account_analytic_line.invoice_id = account_invoice.id \
|
||||
where account_analytic_line.account_id IN %s \
|
||||
and account_analytic_line.invoice_id is not null \
|
||||
GROUP BY account_analytic_line.account_id",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, '')
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if res[obj_id] < res.get(child_id, ''):
|
||||
res[obj_id] = res.get(child_id, '')
|
||||
for id in ids:
|
||||
res[id] = res.get(id, '')
|
||||
return res
|
||||
|
||||
def _last_worked_invoiced_date_calc (self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute("select account_analytic_line.account_id, max(date) \
|
||||
from account_analytic_line \
|
||||
where account_id IN %s \
|
||||
and invoice_id is not null \
|
||||
GROUP BY account_analytic_line.account_id;",(parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
for obj_id in ids:
|
||||
res.setdefault(obj_id, '')
|
||||
for child_id in self.search(cr, uid,
|
||||
[('parent_id', 'child_of', [obj_id])]):
|
||||
if res[obj_id] < res.get(child_id, ''):
|
||||
res[obj_id] = res.get(child_id, '')
|
||||
for id in ids:
|
||||
res[id] = res.get(id, '')
|
||||
return res
|
||||
|
||||
def _remaining_hours_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for account in self.browse(cr, uid, ids):
|
||||
@@ -338,42 +336,16 @@ class account_analytic_account(osv.osv):
|
||||
res[id] = round(res.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _month(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for id in ids:
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \
|
||||
'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,))
|
||||
res[id] = [int(id * 1000000 + int(x[0])) for x in cr.fetchall()]
|
||||
else:
|
||||
res[id] = []
|
||||
return res
|
||||
|
||||
def _user(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
cr.execute('SELECT MAX(id) FROM res_users')
|
||||
max_user = cr.fetchone()[0]
|
||||
for id in ids:
|
||||
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||
if parent_ids:
|
||||
cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \
|
||||
'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,))
|
||||
res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()]
|
||||
else:
|
||||
res[id] = []
|
||||
return res
|
||||
|
||||
_columns ={
|
||||
'ca_invoiced': fields.function(_ca_invoiced_calc, method=True, type='float', string='Invoiced Amount', help="Total customer invoiced amount for this account."),
|
||||
'total_cost': fields.function(_total_cost_calc, method=True, type='float', string='Total Costs', help="Total of costs for this account. It includes real costs (from invoices) and indirect costs, like time spent on timesheets."),
|
||||
'ca_to_invoice': fields.function(_ca_to_invoice_calc, method=True, type='float', string='Uninvoiced Amount', help="If invoice from analytic account, the remaining amount you can invoice to the customer based on the total costs."),
|
||||
'ca_theorical': fields.function(_ca_theorical_calc, method=True, type='float', string='Theorical Revenue', help="Based on the costs you had on the project, what would have been the revenue if all these costs have been invoiced at the normal sale price provided by the pricelist."),
|
||||
'hours_quantity': fields.function(_hours_quantity_calc, method=True, type='float', string='Hours Tot', help="Number of hours you spent on the analytic account (from timesheet). It computes on all journal of type 'general'."),
|
||||
'last_invoice_date': fields.function(_last_invoice_date_calc, method=True, type='date', string='Last Invoice Date', help="Date of the last invoice created for this analytic account."),
|
||||
'last_worked_invoiced_date': fields.function(_last_worked_invoiced_date_calc, method=True, type='date', string='Date of Last Invoiced Cost', help="If invoice from the costs, this is the date of the latest work or cost that have been invoiced."),
|
||||
'last_worked_date': fields.function(_last_worked_date_calc, method=True, type='date', string='Date of Last Cost/Work', help="Date of the latest work done on this account."),
|
||||
'hours_qtt_non_invoiced': fields.function(_hours_qtt_non_invoiced_calc, method=True, type='float', string='Uninvoiced Hours', help="Number of hours (from journal of type 'general') that can be invoiced if you invoice based on analytic account."),
|
||||
'ca_to_invoice': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Uninvoiced Amount', help="If invoice from analytic account, the remaining amount you can invoice to the customer based on the total costs."),
|
||||
'ca_theorical': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Theorical Revenue', help="Based on the costs you had on the project, what would have been the revenue if all these costs have been invoiced at the normal sale price provided by the pricelist."),
|
||||
'hours_quantity': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Hours Tot', help="Number of hours you spent on the analytic account (from timesheet). It computes on all journal of type 'general'."),
|
||||
'last_invoice_date': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='date', string='Last Invoice Date', help="Date of the last invoice created for this analytic account."),
|
||||
'last_worked_invoiced_date': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='date', string='Date of Last Invoiced Cost', help="If invoice from the costs, this is the date of the latest work or cost that have been invoiced."),
|
||||
'last_worked_date': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='date', string='Date of Last Cost/Work', help="Date of the latest work done on this account."),
|
||||
'hours_qtt_non_invoiced': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Uninvoiced Hours', help="Number of hours (from journal of type 'general') that can be invoiced if you invoice based on analytic account."),
|
||||
'hours_qtt_invoiced': fields.function(_hours_qtt_invoiced_calc, method=True, type='float', string='Invoiced Hours', help="Number of hours that can be invoiced plus those that already have been invoiced."),
|
||||
'remaining_hours': fields.function(_remaining_hours_calc, method=True, type='float', string='Remaining Hours', help="Computed using the formula: Maximum Quantity - Hours Tot."),
|
||||
'remaining_ca': fields.function(_remaining_ca_calc, method=True, type='float', string='Remaining Revenue', help="Computed using the formula: Max Invoice Price - Invoiced Amount."),
|
||||
@@ -381,8 +353,8 @@ class account_analytic_account(osv.osv):
|
||||
'real_margin': fields.function(_real_margin_calc, method=True, type='float', string='Real Margin', help="Computed using the formula: Invoiced Amount - Total Costs."),
|
||||
'theorical_margin': fields.function(_theorical_margin_calc, method=True, type='float', string='Theorical Margin', help="Computed using the formula: Theorial Revenue - Total Costs"),
|
||||
'real_margin_rate': fields.function(_real_margin_rate_calc, method=True, type='float', string='Real Margin Rate (%)', help="Computes using the formula: (Real Margin / Total Costs) * 100."),
|
||||
'month_ids': fields.function(_month, method=True, type='many2many', relation='account_analytic_analysis.summary.month', string='Month'),
|
||||
'user_ids': fields.function(_user, method=True, type="many2many", relation='account_analytic_analysis.summary.user', string='User'),
|
||||
'month_ids': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='many2many', relation='account_analytic_analysis.summary.month', string='Month'),
|
||||
'user_ids': fields.function(_analysis_all, method=True, multi='analytic_analysis', type="many2many", relation='account_analytic_analysis.summary.user', string='User'),
|
||||
}
|
||||
|
||||
account_analytic_account()
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
<para style="terp_default_Centre_8">[[ company.currency_id.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Centre_8"><font>[[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]] [[o.name]]</font></para>
|
||||
<para style="terp_default_Centre_8"><font>[[ setTag('font','font',{'face':o.font_style or "Helvetica",'color':o.color_font.name or "black",'backColor':o.color_back.name or "white"}) ]] [[o.name]]</font></para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
+14
-14
@@ -35,16 +35,16 @@ class account_analytic_account(osv.osv):
|
||||
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),))
|
||||
currency = dict(cr.fetchall())
|
||||
res_currency= self.pool.get('res.currency')
|
||||
for id in ids:
|
||||
if id not in ids2:
|
||||
for account in self.browse(cr, uid, ids, context=context):
|
||||
if account.id not in ids2:
|
||||
continue
|
||||
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
||||
if child != id:
|
||||
res.setdefault(id, 0.0)
|
||||
if currency[child]!=currency[id]:
|
||||
res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context)
|
||||
for child in account.child_ids:
|
||||
if child.id != account.id:
|
||||
res.setdefault(account.id, 0.0)
|
||||
if currency[child.id] != currency[account.id]:
|
||||
res[account.id] += res_currency.compute(cr, uid, currency[child.id], currency[account.id], res.get(child.id, 0.0), context=context)
|
||||
else:
|
||||
res[id] += res.get(child, 0.0)
|
||||
res[account.id] += res.get(child.id, 0.0)
|
||||
|
||||
cur_obj = res_currency.browse(cr, uid, currency.values(), context=context)
|
||||
cur_obj = dict([(o.id, o) for o in cur_obj])
|
||||
@@ -145,13 +145,13 @@ class account_analytic_account(osv.osv):
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
|
||||
for id in ids:
|
||||
if id not in parent_ids:
|
||||
for account in self.browse(cr, uid, ids, context=context):
|
||||
if account.id not in parent_ids:
|
||||
continue
|
||||
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
||||
if child != id:
|
||||
res.setdefault(id, 0.0)
|
||||
res[id] += res.get(child, 0.0)
|
||||
for child in account.child_ids:
|
||||
if child.id != account.id:
|
||||
res.setdefault(account.id, 0.0)
|
||||
res[account.id] += res.get(child.id, 0.0)
|
||||
return dict([(i, res[i]) for i in ids])
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -220,7 +220,6 @@
|
||||
<field name="date_action"/>
|
||||
<field name="title_action" />
|
||||
<field name="stage_id"/>
|
||||
<field name="partner_assigned_id" invisible="1"/>
|
||||
<field name="channel_id" invisible="1"/>
|
||||
<field name="type_id" invisible="1"/>
|
||||
<button name="stage_previous" string="Previous Stage"
|
||||
@@ -328,8 +327,6 @@
|
||||
<filter string="Salesman" icon="terp-personal"
|
||||
domain="[]" context="{'group_by':'user_id'}" />
|
||||
<filter string="Team" help="Sales Team" icon="terp-personal+" domain="[]" context="{'group_by':'section_id'}"/>
|
||||
<filter string="Assigned Partner" icon="terp-personal"
|
||||
domain="[]" context="{'group_by':'partner_assigned_id'}" />
|
||||
<separator orientation="vertical" />
|
||||
<filter string="Creation" icon="terp-go-month"
|
||||
domain="[]" context="{'group_by':'create_date'}" />
|
||||
|
||||
@@ -45,12 +45,12 @@ class decimal_precision(osv.osv):
|
||||
return res and res[0] or 2
|
||||
|
||||
def write(self, cr, uid, ids, data, *args, **argv):
|
||||
self.precision_get.clear_cache(cr.dbname)
|
||||
res = super(decimal_precision, self).write(cr, uid, ids, data, *args, **argv)
|
||||
for obj in self.pool.obj_list():
|
||||
for colname,col in self.pool.get(obj)._columns.items():
|
||||
if isinstance(col, fields.float):
|
||||
col.digits_change(cr)
|
||||
self.precision_get.clear_cache(cr.dbname)
|
||||
return res
|
||||
|
||||
decimal_precision()
|
||||
|
||||
@@ -113,87 +113,10 @@ class res_users(osv.osv):
|
||||
_inherit = 'res.users'
|
||||
_description = 'User'
|
||||
|
||||
def _parent_compute(self, cr, uid, ids, name, args, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = {}
|
||||
obj_dept = self.pool.get('hr.department')
|
||||
for user_id in ids:
|
||||
emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)], context=context)
|
||||
cr.execute('SELECT emp.department_id FROM hr_employee AS emp \
|
||||
JOIN resource_resource AS res ON res.id = emp.resource_id \
|
||||
JOIN hr_department as dept ON dept.id = emp.department_id \
|
||||
WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,))
|
||||
ids_dept = [x[0] for x in cr.fetchall()]
|
||||
parent_ids = []
|
||||
if ids_dept:
|
||||
data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context)
|
||||
parent_ids = map(lambda x: x['manager_id'][0], data_dept)
|
||||
cr.execute('SELECT res.user_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id=emp.resource_id \
|
||||
WHERE emp.id IN %s AND res.user_id IS NOT NULL', (tuple(parent_ids),))
|
||||
parent_ids = [x[0] for x in cr.fetchall()]
|
||||
result[user_id] = parent_ids
|
||||
return result
|
||||
|
||||
def _parent_search(self, cr, uid, obj, name, args, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
parent = []
|
||||
for arg in args:
|
||||
if arg[0] == 'parent_id':
|
||||
parent = arg[2]
|
||||
child_ids = self._child_compute(cr, uid, parent, name, args, context=context)
|
||||
if not child_ids:
|
||||
return [('id', 'in', [0])]
|
||||
return [('id', 'in', child_ids.get(uid, []))]
|
||||
|
||||
def _child_compute(self, cr, uid, ids, name, args, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
obj_dept = self.pool.get('hr.department')
|
||||
obj_user = self.pool.get('res.users')
|
||||
result = {}
|
||||
for user_id in ids:
|
||||
child_ids = []
|
||||
cr.execute('SELECT dept.id FROM hr_department AS dept \
|
||||
LEFT JOIN hr_employee AS emp ON dept.manager_id = emp.id \
|
||||
WHERE emp.id IN \
|
||||
(SELECT emp.id FROM hr_employee \
|
||||
JOIN resource_resource r ON r.id = emp.resource_id WHERE r.user_id=' + str(user_id) + ') ')
|
||||
mgnt_dept_ids = [x[0] for x in cr.fetchall()]
|
||||
ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context)
|
||||
if ids_dept:
|
||||
data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context)
|
||||
childs = map(lambda x: x['member_ids'], data_dept)
|
||||
childs = tools.flatten(childs)
|
||||
childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context)
|
||||
if user_id in childs:
|
||||
childs.remove(user_id)
|
||||
child_ids.extend(tools.flatten(childs))
|
||||
set = {}
|
||||
map(set.__setitem__, child_ids, [])
|
||||
child_ids = set.keys()
|
||||
result[user_id] = child_ids
|
||||
return result
|
||||
|
||||
def _child_search(self, cr, uid, obj, name, args, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
parent = []
|
||||
for arg in args:
|
||||
if arg[0] == 'child_ids':
|
||||
parent = arg[2]
|
||||
child_ids = self._child_compute(cr, uid, parent, name, args, context=context)
|
||||
if not child_ids:
|
||||
return [('id', 'in', [0])]
|
||||
return [('id', 'in', child_ids.get(uid, []))]
|
||||
|
||||
_columns = {
|
||||
'parent_id': fields.function(_parent_compute, relation='res.users', fnct_search=_parent_search, method=True, string="Managers", type='many2many'),
|
||||
'child_ids': fields.function(_child_compute, relation='res.users', fnct_search=_child_search, method=True, string="Subordinates", type='many2many'),
|
||||
'context_department_id': fields.many2one('hr.department', 'Departments'),
|
||||
}
|
||||
|
||||
res_users()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -87,10 +87,6 @@
|
||||
<notebook position="inside">
|
||||
<page string="Departments" groups="base.group_extended">
|
||||
<field name="context_department_id" completion="1" widget="selection" string="Department"/>
|
||||
<separator string="Managers" colspan="4"/>
|
||||
<field name="parent_id" nolabel="1" colspan="4"/>
|
||||
<separator string="Subordinates" colspan="4"/>
|
||||
<field name="child_ids" nolabel="1" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
|
||||
@@ -259,7 +259,7 @@
|
||||
<para style="terp_default_9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="terp_default_9">[[ o.note or '' ]] [[ setTag('para','xpre') ]]</para>
|
||||
<para style="terp_default_9">[[ setTag('para','xpre') ]] [[ o.note or '' ]] </para>
|
||||
<para style="terp_default_9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
|
||||
@@ -23,11 +23,14 @@
|
||||
|
||||
import time
|
||||
import datetime
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class hr_holidays_status(osv.osv):
|
||||
_name = "hr.holidays.status"
|
||||
_description = "Leave Type"
|
||||
@@ -35,39 +38,51 @@ class hr_holidays_status(osv.osv):
|
||||
def get_days_cat(self, cr, uid, ids, category_id, return_false, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
cr.execute("""SELECT id, type, number_of_days, holiday_status_id FROM hr_holidays WHERE category_id = %s AND state='validate' AND holiday_status_id in %s""",
|
||||
[category_id, tuple(ids)])
|
||||
result = sorted(cr.dictfetchall(), key=lambda x: x['holiday_status_id'])
|
||||
|
||||
grouped_lines = dict((k, [v for v in itr]) for k, itr in groupby(result, itemgetter('holiday_status_id')))
|
||||
|
||||
res = {}
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
res[record.id] = {}
|
||||
max_leaves = leaves_taken = 0
|
||||
if not return_false:
|
||||
cr.execute("""SELECT type, sum(number_of_days) FROM hr_holidays WHERE category_id = %s AND state='validate' AND holiday_status_id = %s GROUP BY type""", (str(category_id), str(record.id)))
|
||||
for line in cr.fetchall():
|
||||
if line[0] =='remove':
|
||||
leaves_taken = -line[1]
|
||||
if line[0] =='add':
|
||||
max_leaves = line[1]
|
||||
if record.id in grouped_lines:
|
||||
leaves_taken = -sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'remove'])
|
||||
max_leaves = sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'add'])
|
||||
|
||||
res[record.id]['max_leaves'] = max_leaves
|
||||
res[record.id]['leaves_taken'] = leaves_taken
|
||||
res[record.id]['remaining_leaves'] = max_leaves - leaves_taken
|
||||
|
||||
return res
|
||||
|
||||
def get_days(self, cr, uid, ids, employee_id, return_false, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
cr.execute("""SELECT id, type, number_of_days, holiday_status_id FROM hr_holidays WHERE employee_id = %s AND state='validate' AND holiday_status_id in %s""",
|
||||
[employee_id, tuple(ids)])
|
||||
result = sorted(cr.dictfetchall(), key=lambda x: x['holiday_status_id'])
|
||||
|
||||
grouped_lines = dict((k, [v for v in itr]) for k, itr in groupby(result, itemgetter('holiday_status_id')))
|
||||
|
||||
res = {}
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
res[record.id] = {}
|
||||
max_leaves = leaves_taken = 0
|
||||
if not return_false:
|
||||
cr.execute("""SELECT type, sum(number_of_days) FROM hr_holidays WHERE employee_id = %s AND state='validate' AND holiday_status_id = %s GROUP BY type""", (str(employee_id), str(record.id)))
|
||||
for line in cr.fetchall():
|
||||
if line[0] =='remove':
|
||||
leaves_taken = -line[1]
|
||||
if line[0] =='add':
|
||||
max_leaves = line[1]
|
||||
if record.id in grouped_lines:
|
||||
leaves_taken = -sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'remove'])
|
||||
max_leaves = sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'add'])
|
||||
|
||||
res[record.id]['max_leaves'] = max_leaves
|
||||
res[record.id]['leaves_taken'] = leaves_taken
|
||||
res[record.id]['remaining_leaves'] = max_leaves - leaves_taken
|
||||
|
||||
return res
|
||||
|
||||
def _user_left_days(self, cr, uid, ids, name, args, context=None):
|
||||
|
||||
@@ -784,6 +784,7 @@ class hr_payslip(osv.osv):
|
||||
'contract_id':fields.many2one('hr.contract', 'Contract', required=False),
|
||||
'igross': fields.float('Calculaton Field', readonly=True, digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
|
||||
'inet': fields.float('Calculaton Field', readonly=True, digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
|
||||
'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
|
||||
@@ -500,12 +500,12 @@
|
||||
</notebook>
|
||||
<group col="10" colspan="4">
|
||||
<field name="state"/>
|
||||
<button string="Cancel" icon="terp-dialog-close" name="cancel_sheet" states="draft,hr_check,confirm"/>
|
||||
<button string="Compute Sheet" icon="terp-stock_format-scientific" name="compute_sheet" states="new"/>
|
||||
<button string="Recompute Sheet" icon="terp-stock_format-scientific" name="compute_sheet" type="object" states="draft"/>
|
||||
<button string="Verify Sheet" icon="terp-camera_test" name="verify_sheet" states="draft"/>
|
||||
<button string="Approve Sheet" icon="terp-camera_test" name="final_verify_sheet" states="hr_check"/>
|
||||
<button string="Pay Salary" icon="terp-dolar_ok!" name="process_sheet" states="confirm"/>
|
||||
<button string="Cancel" icon="terp-dialog-close" name="cancel_sheet" states="draft,hr_check,confirm"/>
|
||||
<button string="Set to Draft" icon="terp-stock_effects-object-colorize" name="set_to_draft" states="cancel"/>
|
||||
</group>
|
||||
</form>
|
||||
|
||||
@@ -77,7 +77,7 @@ class report_custom(report_rml):
|
||||
<amount>%.2f</amount>
|
||||
</time-element>
|
||||
'''
|
||||
rpt_obj = pooler.get_pool(cr.dbname).get('hr.holidays')
|
||||
rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
|
||||
header_xml = '''
|
||||
<header>
|
||||
|
||||
@@ -97,7 +97,7 @@ class report_custom(report_rml):
|
||||
# Computing the xml
|
||||
#Without this, report don't show non-ascii characters (TO CHECK)
|
||||
date_xml = '\n'.join(date_xml)
|
||||
rpt_obj = pooler.get_pool(cr.dbname).get('hr.holidays')
|
||||
rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee')
|
||||
rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context)
|
||||
header_xml = '''
|
||||
<header>
|
||||
|
||||
@@ -44,17 +44,22 @@ class account_analytic_account(osv.osv):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = {}
|
||||
|
||||
cr.execute('select account_id as account_id, l.invoice_id from hr_analytic_timesheet h left join account_analytic_line l on (h.line_id=l.id)')
|
||||
account_to_invoice_map = {}
|
||||
for rec in cr.dictfetchall():
|
||||
account_to_invoice_map.setdefault(rec['account_id'], []).append(rec['invoice_id'])
|
||||
|
||||
for account in self.browse(cr, uid, ids, context=context):
|
||||
invoiced = {}
|
||||
cr.execute('select distinct(l.invoice_id) from hr_analytic_timesheet h left join account_analytic_line l on (h.line_id=l.id) where account_id=%s', (account.id,))
|
||||
invoice_ids = filter(None, map(lambda x: x[0], cr.fetchall()))
|
||||
invoice_ids = filter(None, list(set(account_to_invoice_map.get(account.id, []))))
|
||||
for invoice in obj_invoice.browse(cr, uid, invoice_ids, context=context):
|
||||
res.setdefault(account.id, 0.0)
|
||||
res[account.id] += invoice.amount_untaxed
|
||||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
return res
|
||||
|
||||
_inherit = "account.analytic.account"
|
||||
_columns = {
|
||||
|
||||
@@ -34,8 +34,6 @@ class one2many_mod2(fields.one2many):
|
||||
if values is None:
|
||||
values = {}
|
||||
|
||||
res = {}.fromkeys(ids, [])
|
||||
|
||||
# dict:
|
||||
# {idn: (date_current, user_id), ...
|
||||
# 1: ('2010-08-15', 1)}
|
||||
@@ -59,9 +57,13 @@ class one2many_mod2(fields.one2many):
|
||||
|
||||
ids2 = obj.pool.get(self._obj).search(cr, user, dom, limit=self._limit)
|
||||
|
||||
res = {}
|
||||
for i in ids:
|
||||
res[i] = []
|
||||
|
||||
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
|
||||
if r[self._fields_id]:
|
||||
res.setdefault(r[self._fields_id][0], []).append(r['id'])
|
||||
res[r[self._fields_id][0]].append(r['id'])
|
||||
|
||||
return res
|
||||
|
||||
@@ -82,7 +84,6 @@ class one2many_mod(fields.one2many):
|
||||
if values is None:
|
||||
values = {}
|
||||
|
||||
res = {}.fromkeys(ids, [])
|
||||
|
||||
res5 = obj.read(cr, user, ids, ['date_current', 'user_id'], context=context)
|
||||
res6 = {}
|
||||
@@ -96,11 +97,13 @@ class one2many_mod(fields.one2many):
|
||||
dom = [('date', '=', res6[id][0]), ('user_id', '=', res6[id][1])]
|
||||
ids2.extend(obj.pool.get(self._obj).search(cr, user,
|
||||
dom, limit=self._limit))
|
||||
|
||||
res = {}
|
||||
for i in ids:
|
||||
res[i] = []
|
||||
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2,
|
||||
[self._fields_id], context=context, load='_classic_write'):
|
||||
if r[self._fields_id]:
|
||||
res.setdefault(r[self._fields_id][0], []).append(r['id'])
|
||||
res[r[self._fields_id][0]].append(r['id'])
|
||||
|
||||
return res
|
||||
|
||||
|
||||
+6
-2
@@ -357,7 +357,9 @@ class many2many_domain(fields.many2many):
|
||||
context = {}
|
||||
|
||||
move_obj = obj.pool.get('stock.move')
|
||||
res = {}.fromkeys(ids, [])
|
||||
res = {}
|
||||
for i in ids:
|
||||
res[i] = []
|
||||
valid_move_ids = move_obj.search(cr, user, self._domain) # move ids relative to domain argument
|
||||
cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s",
|
||||
[tuple(ids), tuple(valid_move_ids)])
|
||||
@@ -377,7 +379,9 @@ class one2many_domain(fields.one2many):
|
||||
context = {}
|
||||
|
||||
move_obj = obj.pool.get('stock.move')
|
||||
res = {}.fromkeys(ids, [])
|
||||
res = {}
|
||||
for i in ids:
|
||||
res[i] = []
|
||||
move_ids = move_obj.search(cr, user, self._domain+[('production_id', 'in', tuple(ids))], context=context)
|
||||
related_move_dict = dict([(o.production_id.id, [o.id]) for o in move_obj.browse(cr, user, move_ids, context=context)])
|
||||
res.update(related_move_dict)
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
<field name="name">Repairs workshop</field>
|
||||
<field name="calendar_id" ref="resource.timesheet_group1"/>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Resource: res.company
|
||||
-->
|
||||
<record id="stock.res_company_tinyshop0" model="res.company">
|
||||
<field eval="1.0" name="manufacturing_lead"/>
|
||||
</record>
|
||||
<!--
|
||||
Resource: mrp.property.group
|
||||
-->
|
||||
|
||||
@@ -45,6 +45,7 @@ class mrp_repair(osv.osv):
|
||||
"""
|
||||
res = {}
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
|
||||
for repair in self.browse(cr, uid, ids):
|
||||
res[repair.id] = 0.0
|
||||
for line in repair.operations:
|
||||
@@ -62,6 +63,7 @@ class mrp_repair(osv.osv):
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res = {}
|
||||
#return {}.fromkeys(ids, 0)
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
for repair in self.browse(cr, uid, ids):
|
||||
@@ -94,6 +96,14 @@ class mrp_repair(osv.osv):
|
||||
res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
|
||||
return res
|
||||
|
||||
def _get_lines(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
result = {}
|
||||
for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):
|
||||
result[line.repair_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Repair Reference',size=24, required=True),
|
||||
'product_id': fields.many2one('product.product', string='Product to Repair', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
@@ -137,9 +147,21 @@ class mrp_repair(osv.osv):
|
||||
'deliver_bool': fields.boolean('Deliver', help="Check this box if you want to manage the delivery once the product is repaired. If cheked, it will create a picking with selected product. Note that you can select the locations in the Info tab, if you have the extended view."),
|
||||
'invoiced': fields.boolean('Invoiced', readonly=True),
|
||||
'repaired': fields.boolean('Repaired', readonly=True),
|
||||
'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'),
|
||||
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
|
||||
'amount_total': fields.function(_amount_total, method=True, string='Total'),
|
||||
'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount',
|
||||
store={
|
||||
'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
|
||||
'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
|
||||
}),
|
||||
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes',
|
||||
store={
|
||||
'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
|
||||
'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
|
||||
}),
|
||||
'amount_total': fields.function(_amount_total, method=True, string='Total',
|
||||
store={
|
||||
'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
|
||||
'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
|
||||
}),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
@@ -163,7 +185,6 @@ class mrp_repair(osv.osv):
|
||||
})
|
||||
return super(mrp_repair, self).copy(cr, uid, id, default, context)
|
||||
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id=None):
|
||||
""" On change of product sets some values.
|
||||
@param product_id: Changed product
|
||||
|
||||
@@ -377,23 +377,23 @@ class product_product(osv.osv):
|
||||
res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra
|
||||
return res
|
||||
|
||||
def _get_partner_code_name(self, cr, uid, ids, product_id, partner_id, context={}):
|
||||
product = self.browse(cr, uid, [product_id], context)[0]
|
||||
def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context={}):
|
||||
for supinfo in product.seller_ids:
|
||||
if supinfo.name.id == partner_id:
|
||||
return {'code': supinfo.product_code, 'name': supinfo.product_name, 'variants': ''}
|
||||
return {'code' : product.default_code, 'name' : product.name, 'variants': product.variants}
|
||||
res = {'code': product.default_code, 'name': product.name, 'variants': product.variants}
|
||||
return res
|
||||
|
||||
def _product_code(self, cr, uid, ids, name, arg, context={}):
|
||||
res = {}
|
||||
for p in self.browse(cr, uid, ids, context):
|
||||
res[p.id] = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)['code']
|
||||
res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)['code']
|
||||
return res
|
||||
|
||||
def _product_partner_ref(self, cr, uid, ids, name, arg, context={}):
|
||||
res = {}
|
||||
for p in self.browse(cr, uid, ids, context):
|
||||
data = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)
|
||||
data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)
|
||||
if not data['variants']:
|
||||
data['variants'] = p.variants
|
||||
if not data['code']:
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<field name="object_id" search="[('model','=','project.issue')]" model="ir.model"/>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.resource.type" id="type2">
|
||||
<record model="crm.case.resource.type" id="type3">
|
||||
<field name="name">Version 6.0</field>
|
||||
<field name="section_id" ref="crm.section_sales_department"/>
|
||||
<field name="object_id" search="[('model','=','project.issue')]" model="ir.model"/>
|
||||
|
||||
@@ -41,9 +41,6 @@
|
||||
<field name="product_uom" ref="product.product_uom_unit"/>
|
||||
<field name="price_unit">450</field>
|
||||
<field name="product_qty">2</field>
|
||||
<field name="product_uom_qty">3</field>
|
||||
<field name="product_uos_qty">3</field>
|
||||
<field name="type">make_to_stock</field>
|
||||
</record>
|
||||
|
||||
<record id="line3_purchase" model="purchase.order.line">
|
||||
@@ -54,7 +51,6 @@
|
||||
<field name="product_uom" ref="product.product_uom_unit"/>
|
||||
<field name="price_unit">900</field>
|
||||
<field name="product_qty">1</field>
|
||||
<field name="type">make_to_stock</field>
|
||||
</record>
|
||||
|
||||
<workflow action="purchase_confirm" model="purchase.order" ref="order_purchase2"/>
|
||||
|
||||
@@ -217,7 +217,6 @@
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
<field eval="1.0" name="po_lead"/>
|
||||
<field name="partner_id" ref="res_partner_tinyshop1"/>
|
||||
<field eval="1.0" name="manufacturing_lead"/>
|
||||
<field name="parent_id" ref="base.main_company"/>
|
||||
<field eval="80.0" name="schedule_range"/>
|
||||
<field eval=""""Shop 2"""" name="name"/>
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ class wiki_wiki2(osv.osv):
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param id: Give wiki page's ID """
|
||||
|
||||
return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
|
||||
return super(wiki_wiki2, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
|
||||
|
||||
def create_history(self, cr, uid, ids, vals, context=None):
|
||||
history_id = False
|
||||
|
||||
Reference in New Issue
Block a user