[MERGE] Merged Anup's branch for the fix of invoice created for analyric lines(case 5267). This also covers the fix for the bug lp:728092. Pricelist calculation corrected
lp bug: https://launchpad.net/bugs/728092 fixed bzr revid: jvo@tinyerp.com-20110421074529-7p3ts8v1w285jzmg
This commit is contained in:
@@ -93,7 +93,7 @@ class final_invoice_create(osv.osv_memory):
|
||||
last_invoice = invoice_obj.create(cr, uid, curr_invoice, context=context)
|
||||
invoices.append(last_invoice)
|
||||
|
||||
context2=context.copy()
|
||||
context2 = context.copy()
|
||||
context2['lang'] = partner.lang
|
||||
cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \
|
||||
"FROM account_analytic_line as line " \
|
||||
|
||||
@@ -108,13 +108,13 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
||||
|
||||
context2 = context.copy()
|
||||
context2['lang'] = partner.lang
|
||||
cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \
|
||||
cr.execute("SELECT product_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,to_invoice", (account.id, tuple(context['active_ids']),))
|
||||
"GROUP BY product_id,to_invoice,product_uom_id", (account.id, tuple(context['active_ids']),))
|
||||
|
||||
for product_id, factor_id, qty in cr.fetchall():
|
||||
for product_id, factor_id, qty, uom in cr.fetchall():
|
||||
product = product_obj.browse(cr, uid, product_id, context2)
|
||||
if not product:
|
||||
raise osv.except_osv(_('Error'), _('At least one line has no product !'))
|
||||
@@ -129,9 +129,11 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
||||
else:
|
||||
factor_name = product_obj.name_get(cr, uid, [data['product']], context=context)[0][1]
|
||||
|
||||
ctx = context.copy()
|
||||
ctx.update({'uom':uom})
|
||||
if account.pricelist_id:
|
||||
pl = account.pricelist_id.id
|
||||
price = pro_price_obj.price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id)[pl]
|
||||
price = pro_price_obj.price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id, context=ctx)[pl]
|
||||
else:
|
||||
price = 0.0
|
||||
|
||||
@@ -147,7 +149,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
||||
'name': factor_name,
|
||||
'product_id': data['product'] or product_id,
|
||||
'invoice_line_tax_id': [(6,0,tax)],
|
||||
'uos_id': product.uom_id.id,
|
||||
'uos_id': uom,
|
||||
'account_id': account_id,
|
||||
'account_analytic_id': account.id,
|
||||
}
|
||||
|
||||
@@ -266,6 +266,8 @@ class product_pricelist(osv.osv):
|
||||
product_obj.price_get(cr, uid, [product_id],
|
||||
price_type.field,context=context)[product_id], round=False, context=context)
|
||||
|
||||
uom_price_already_computed = True
|
||||
|
||||
if price is not False:
|
||||
price_limit = price
|
||||
|
||||
|
||||
Reference in New Issue
Block a user