Anup(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-opw-5267-ach into
lp:openobject-addons/6.0.
Requested reviews:
Jay Vora (OpenERP) (jvo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5267-ach/+merge/58236
Hello,
There arises a problem when you try to invoice the analytic lines with
different UoMs. It calculates wrong price for the product.
To generate follow the steps below.
1. Create an analytic entry.
2. Go to Accounting/Configuration/Analytic Accounting/Analytic Accounts
3. Open account form view and click on the link 'Lines to Invoice'.
4. Change the UoM in the Analytic line and Click on the wizard(action) Invoice
Analytic Lines.
5. An invoice will be created with wrong price for the changed UoM analytic
Line.
This fixes the issue.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5267-ach/+merge/58236
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-opw-5267-ach.
=== modified file 'hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py'
--- hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2011-01-14 00:11:01 +0000
+++ hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py 2011-04-19 07:46:02 +0000
@@ -108,13 +108,13 @@
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 @@
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 @@
'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,
}
=== modified file 'product/pricelist.py'
--- product/pricelist.py 2011-04-13 17:59:03 +0000
+++ product/pricelist.py 2011-04-19 07:46:02 +0000
@@ -265,6 +265,9 @@
price_type.currency_id.id, res['currency_id'],
product_obj.price_get(cr, uid, [product_id],
price_type.field,context=context)[product_id], round=False, context=context)
+
+ if 'uom' in context:
+ uom_price_already_computed = True
if price is not False:
price_limit = price
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-web
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-web
More help : https://help.launchpad.net/ListHelp