[MERGE] Merge with lp:openobject-addons
bzr revid: sbh@tinyerp.com-20100923061103-8fm2ek7u9nug3wph
This commit is contained in:
commit
cf4ea3b57a
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
-
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue