diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py
index 4ece8b537d4..c84b311f307 100644
--- a/addons/account_analytic_analysis/account_analytic_analysis.py
+++ b/addons/account_analytic_analysis/account_analytic_analysis.py
@@ -528,40 +528,25 @@ class account_analytic_account_summary_user(osv.osv):
def init(self, cr):
tools.sql.drop_view_if_exists(cr, 'account_analytic_analysis_summary_user')
- cr.execute('CREATE OR REPLACE VIEW account_analytic_analysis_summary_user AS (' \
- 'SELECT ' \
- '(u.account_id * u.max_user) + u."user" AS id, ' \
- 'u.account_id AS account_id, ' \
- 'u."user" AS "user", ' \
- 'COALESCE(SUM(l.unit_amount), 0.0) AS unit_amount ' \
- 'FROM ' \
- '(SELECT ' \
- 'a.id AS account_id, ' \
- 'u1.id AS "user", ' \
- 'MAX(u2.id) AS max_user ' \
- 'FROM ' \
- 'res_users AS u1, ' \
- 'res_users AS u2, ' \
- 'account_analytic_account AS a ' \
- 'GROUP BY u1.id, a.id ' \
- ') AS u ' \
- 'LEFT JOIN ' \
- '(SELECT ' \
- 'l.account_id AS account_id, ' \
- 'l.user_id AS "user", ' \
- 'SUM(l.unit_amount) AS unit_amount ' \
- 'FROM account_analytic_line AS l, ' \
- 'account_analytic_journal AS j ' \
- 'WHERE (j.type = \'general\') and (j.id=l.journal_id) ' \
- 'GROUP BY l.account_id, l.user_id ' \
- ') AS l '
- 'ON (' \
- 'u.account_id = l.account_id ' \
- 'AND u."user" = l."user"' \
- ') ' \
- 'GROUP BY u."user", u.account_id, u.max_user' \
- ')')
-
+ cr.execute('''CREATE OR REPLACE VIEW account_analytic_analysis_summary_user AS (
+ with mu as
+ (select max(id) as max_user from res_users)
+ , lu AS
+ (SELECT
+ l.account_id AS account_id,
+ coalesce(l.user_id, 0) AS user_id,
+ SUM(l.unit_amount) AS unit_amount
+ FROM account_analytic_line AS l,
+ account_analytic_journal AS j
+ WHERE (j.type = 'general' ) and (j.id=l.journal_id)
+ GROUP BY l.account_id, l.user_id
+ )
+ select (lu.account_id * mu.max_user) + lu.user_id as id,
+ lu.account_id as account_id,
+ lu.user_id as "user",
+ unit_amount
+ from lu, mu)''')
+
account_analytic_account_summary_user()
class account_analytic_account_summary_month(osv.osv):
diff --git a/addons/delivery/delivery_view.xml b/addons/delivery/delivery_view.xml
index 77c456a3930..d98c9fd9cc3 100644
--- a/addons/delivery/delivery_view.xml
+++ b/addons/delivery/delivery_view.xml
@@ -226,7 +226,7 @@
-
+
@@ -251,7 +251,7 @@
-
+
@@ -264,7 +264,7 @@
-
+
diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
index ea4d286c89f..c9b2439596d 100644
--- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
+++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py
@@ -90,32 +90,28 @@ class account_analytic_line(osv.osv):
context2 = context.copy()
context2['lang'] = partner.lang
- cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id " \
+ cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id, name " \
"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,product_uom_id", (account.id, tuple(ids),))
+ "GROUP BY product_id, to_invoice, product_uom_id, name", (account.id, tuple(ids),))
- for product_id, factor_id, qty, uom in cr.fetchall():
- product = product_obj.browse(cr, uid, product_id, context2)
+ for product_id, factor_id, qty, uom, line_name 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'), _('At least one line has no product !'))
- factor_name = ''
- factor = invoice_factor_obj.browse(cr, uid, factor_id, context2)
- if not data.get('product', False):
- if factor.customer_name:
- factor_name = product.name+' - '+factor.customer_name
- else:
- factor_name = product.name
- else:
- data['product'] = data['product'][0]
- factor_name = product_obj.name_get(cr, uid, [data['product']], context=context)[0][1]
+ 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))
+ 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:
+ factor_name += ' - ' + factor.customer_name
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.get('product', False) or product_id, qty or 1.0, account.partner_id.id, context=ctx)[pl]
+ price = pro_price_obj.price_get(cr,uid,[pl], product_id, qty or 1.0, account.partner_id.id, context=ctx)[pl]
else:
price = 0.0
@@ -131,7 +127,7 @@ class account_analytic_line(osv.osv):
'invoice_line_tax_id': [(6,0,tax )],
'invoice_id': last_invoice,
'name': factor_name,
- 'product_id': data.get('product',product_id),
+ 'product_id': product_id,
'invoice_line_tax_id': [(6,0,tax)],
'uos_id': uom,
'account_id': account_id,
@@ -179,7 +175,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
'time': fields.boolean('Time spent', help='The time of each work done will be displayed on the invoice'),
'name': fields.boolean('Description', help='The detail of each work done will be displayed on the invoice'),
'price': fields.boolean('Cost', help='The cost of each work done will be displayed on the invoice. You probably don\'t want to check this'),
- 'product': fields.many2one('product.product', 'Product', help='Fill this field only if you want to force to use a specific product. Keep empty to use the real product that comes from the cost.'),
+ 'product': fields.many2one('product.product', 'Force Product', help='Fill this field only if you want to force to use a specific product. Keep empty to use the real product that comes from the cost.'),
}
_defaults = {