[IMP] some timesheet invoices fixes (not all)

bzr revid: fp@tinyerp.com-20121126075403-z4dq5h9ytptrf6sh
This commit is contained in:
Fabien Pinckaers 2012-11-26 08:54:03 +01:00
commit d9936eda84
4 changed files with 10 additions and 6 deletions

View File

@ -296,11 +296,14 @@ class account_analytic_account(osv.osv):
def _timesheet_ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
lines_obj = self.pool.get('account.analytic.line')
res = {}
inv_ids = []
for account in self.browse(cr, uid, ids, context=context):
res[account.id] = 0.0
line_ids = lines_obj.search(cr, uid, [('account_id','=', account.id), ('invoice_id','!=',False), ('to_invoice','!=', False), ('journal_id.type', '=', 'general')], context=context)
for line in lines_obj.browse(cr, uid, line_ids, context=context):
res[account.id] += line.invoice_id.amount_untaxed
if line.invoice_id not in inv_ids:
inv_ids.append(line.invoice_id)
res[account.id] += line.invoice_id.amount_untaxed
return res
def _remaining_ca_calc(self, cr, uid, ids, name, arg, context=None):

View File

@ -136,6 +136,7 @@ class account_analytic_account(osv.osv):
'name': name,
'view_type': 'form',
'view_mode': 'tree,form',
'context':{'analytic_account':ids[0]},
'domain' : domain,
'res_model': 'hr.expense.expense',
'nodestroy': True,

View File

@ -85,7 +85,7 @@
</group>
<notebook>
<page string="Description">
<field name="line_ids" context="{'currency_id': currency_id}">
<field name="line_ids" context="{'currency_id': currency_id, 'default_analytic_account': context.get('analytic_account')}">
<form string="Expense Lines" version="7.0">
<group>
<group>

View File

@ -106,18 +106,18 @@ class account_analytic_line(osv.osv):
last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context2)
invoices.append(last_invoice)
cr.execute("SELECT product_id, user_id, to_invoice, sum(unit_amount), product_uom_id, name " \
cr.execute("SELECT product_id, user_id, to_invoice, sum(unit_amount), product_uom_id " \
"FROM account_analytic_line as line " \
"WHERE account_id = %s " \
"AND id IN %s AND to_invoice IS NOT NULL " \
"GROUP BY product_id, user_id, to_invoice, product_uom_id, name", (account.id, tuple(ids),))
"GROUP BY product_id, user_id, to_invoice, product_uom_id", (account.id, tuple(ids),))
for product_id, user_id, factor_id, qty, uom, line_name in cr.fetchall():
for product_id, user_id, factor_id, qty, uom in cr.fetchall():
if data.get('product'):
product_id = data['product'][0]
product = product_obj.browse(cr, uid, product_id, context=context2)
if not product:
raise osv.except_osv(_('Error!'), _('There is no product defined for the line %s. Please select one or force the product through the wizard.') % (line_name))
raise osv.except_osv(_('Error!'), _('There is no product defined. Please select one or force the product through the wizard.'))
factor = invoice_factor_obj.browse(cr, uid, factor_id, context=context2)
factor_name = product_obj.name_get(cr, uid, [product_id], context=context2)[0][1]
if factor.customer_name: