bzr revid: rch_open_erp-20100922114936-ohnqm3jdiy2yq9yp
This commit is contained in:
rch (Open ERP) 2010-09-22 17:19:36 +05:30
commit b897cd7956
8 changed files with 49 additions and 41 deletions

View File

@ -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:

View File

@ -41,17 +41,14 @@
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 can't change the currency of invoice when it is not in draft state so i change the state to cancel
-

View File

@ -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})

View File

@ -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'

View File

@ -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()

View File

@ -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):

View File

@ -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

View File

@ -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)