bugfix_speed_improvement

bzr revid: fp@tinyerp.com-20081213060519-t79l5dvxcy98pl33
This commit is contained in:
Fabien Pinckaers 2008-12-13 07:05:19 +01:00
parent cb59d883b8
commit 245bdf0433
4 changed files with 33 additions and 24 deletions

View File

@ -59,12 +59,7 @@ class wizard_account_chart(wizard.interface):
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
if 'lang' in context:
import tools
trans_name = tools.translate(cr, 'ir.actions.act_window,name', 'model', context['lang'], result['name'])
if trans_name:
result['name'] = trans_name
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = str({'fiscalyear': data['form']['fiscalyear'],'target_move':data['form']['target_move']})
if data['form']['fiscalyear']:
result['name']+=':'+pooler.get_pool(cr.dbname).get('account.fiscalyear').read(cr,uid,[data['form']['fiscalyear']])[0]['code']

View File

@ -634,7 +634,7 @@ class mrp_production(osv.osv):
}
res_final_id = self.pool.get('stock.move').create(cr, uid, data)
self.write(cr, uid, [production.id], {'move_created_ids': [(6, 'WTF', [res_final_id])]})
self.write(cr, uid, [production.id], {'move_created_ids': [(6, 0, [res_final_id])]})
moves = []
for line in production.product_lines:
move_id=False

View File

@ -36,14 +36,11 @@ class price_type(osv.osv):
sale and purchase prices based on some fields of the product.
"""
def _price_field_get(self, cr, uid, context={}):
import tools
cr.execute('select name, field_description, model from ir_model_fields where model in (%s,%s) and ttype=%s order by name', ('product.product', 'product.template', 'float'))
mf = self.pool.get('ir.model.fields')
ids = mf.search(cr, uid, [('model','in', (('product.product'),('product.template'))), ('ttype','=','float')], context=context)
res = []
for field in cr.dictfetchall():
desc = tools.translate(cr, field['model'] + ',' + field['name'], 'field', context.get('lang', False) or 'en_US')
if not desc:
desc = field['field_description']
res.append((field['name'], desc))
for field in mf.browse(cr, uid, ids, context=context):
res.append((field.name, field.field_description))
return res
def _get_currency(self, cr, uid, ctx):
@ -304,14 +301,11 @@ product_pricelist_version()
class product_pricelist_item(osv.osv):
def _price_field_get(self, cr, uid, context={}):
cr.execute('select id,name from product_price_type where active')
import tools
pt = self.pool.get('product.price.type')
ids = pt.search(cr, uid, [], context=context)
result = []
for line in cr.fetchall():
transl_name = tools.translate(cr, 'product.price.type,name', 'model', ('lang' in context) and context['lang'] or 'en_US', line[1])
if not transl_name:
transl_name = line[1]
result.append((line[0], transl_name))
for line in pt.browse(cr, uid, ids, context=context):
result.append((line.id, line.name))
result.append((-1, _('Other Pricelist')))
result.append((-2, _('Partner section of the product form')))

View File

@ -172,6 +172,12 @@ class sale_order(osv.osv):
return [('id', '=', 0)]
return [('id', 'in', [x[0] for x in res])]
def _get_order(self, cr, uid, ids, context={}):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
_columns = {
'name': fields.char('Order Reference', size=64, required=True, select=True),
'shop_id':fields.many2one('sale.shop', 'Shop', required=True, readonly=True, states={'draft':[('readonly',False)]}),
@ -224,9 +230,23 @@ class sale_order(osv.osv):
'note': fields.text('Notes'),
'amount_untaxed': fields.function(_amount_all, method=True, string='Untaxed Amount',
store=True, multi='sums'),
'amount_tax': fields.function(_amount_all, method=True, string='Taxes', store=True, multi='sums'),
'amount_total': fields.function(_amount_all, method=True, string='Total', store=True, multi='sums'),
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
'sale.order.line': (_get_order, None, 10),
},
multi='sums'),
'amount_tax': fields.function(_amount_all, method=True, string='Taxes',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
'sale.order.line': (_get_order, None, 10),
},
multi='sums'),
'amount_total': fields.function(_amount_all, method=True, string='Total',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
'sale.order.line': (_get_order, None, 10),
},
multi='sums'),
'invoice_quantity': fields.selection([('order','Ordered Quantities'),('procurement','Shipped Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice). Ordered and delivered quantities may not be the same. You have to choose if you invoice based on ordered or shipped quantities. If the product is a service, shipped quantities means hours spent on the associated tasks.",required=True),
'payment_term' : fields.many2one('account.payment.term', 'Payment Term'),