HR_TIMESHEET_INVOICE: improve create invoice
bzr revid: ced-93af4c09cfc8446aad3e104aea1b65ec905a5915
This commit is contained in:
parent
3dea080272
commit
b4af1461c4
|
@ -41,7 +41,7 @@ class account_analytic_line(osv.osv):
|
|||
'amount' : fields.float('Amount', required=True),
|
||||
'unit_amount' : fields.float('Quantity'),
|
||||
'product_uom_id' : fields.many2one('product.uom', 'UoM'),
|
||||
'product_id' : fields.many2one('product.product', 'Product'),
|
||||
'product_id' : fields.many2one('product.product', 'Product', required=True),
|
||||
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
|
||||
'general_account_id' : fields.many2one('account.account', 'General account', required=True, ondelete='cascade'),
|
||||
'move_id' : fields.many2one('account.move.line', 'General entry', ondelete='cascade', select=True),
|
||||
|
|
|
@ -62,7 +62,7 @@ class invoice_create(wizard.interface):
|
|||
for account in pool.get('account.analytic.account').browse(cr, uid, account_ids, context):
|
||||
partner = account.partner_id
|
||||
if (not partner) or not (account.pricelist_id):
|
||||
raise wizard.except_wizard('Analytic account incomplete', 'Plese fill in the partner and pricelist field in the analytic account:\n%s' % (account.name,))
|
||||
raise wizard.except_wizard('Analytic account incomplete', 'Please fill in the partner and pricelist field in the analytic account:\n%s' % (account.name,))
|
||||
|
||||
curr_invoice = {
|
||||
'name': time.strftime('%D')+' - '+account.name,
|
||||
|
@ -77,11 +77,13 @@ class invoice_create(wizard.interface):
|
|||
last_invoice = pool.get('account.invoice').create(cr, uid, curr_invoice)
|
||||
invoices.append(last_invoice)
|
||||
|
||||
context2=context.copy()
|
||||
context2['lang'] = partner.lang
|
||||
cr.execute("SELECT product_id,to_invoice,sum(unit_amount) FROM account_analytic_line as line WHERE account_id = %d and id IN (%s) GROUP BY product_id,to_invoice" % (account.id, ','.join(map(str,data['ids']))))
|
||||
for product_id,factor_id,qty in cr.fetchall():
|
||||
product = pool.get('product.product').browse(cr, uid, product_id, context)
|
||||
product = pool.get('product.product').browse(cr, uid, product_id, context2)
|
||||
factor_name = ''
|
||||
factor = pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context)
|
||||
factor = pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context2)
|
||||
if factor.customer_name:
|
||||
factor_name = product.name+' - '+factor.customer_name
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue