diff --git a/addons/account/test/account_change_currency.yml b/addons/account/test/account_change_currency.yml index 71a4ff6e301..4fe89534ce5 100644 --- a/addons/account/test/account_change_currency.yml +++ b/addons/account/test/account_change_currency.yml @@ -23,15 +23,6 @@ - !assert {model: account.invoice, id: account_invoice_currency, string: Customer Invoice is in Draft state}: - state == 'draft' -- - I change the state of invoice to proforma2 by clicking PRO-FORMA button -- - !workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_currency} -- - I check that now customer invoice is in the "proforma2" state -- - !assert {model: account.invoice, id: account_invoice_currency}: - - state == 'proforma2' - Now I select USD as new currency - @@ -49,6 +40,15 @@ "active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids": [ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"), }) +- + I change the state of invoice to proforma2 by clicking PRO-FORMA button +- + !workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_currency} +- + I check that now customer invoice is in the "proforma2" state +- + !assert {model: account.invoice, id: account_invoice_currency}: + - state == 'proforma2' - I can't change the currency of invoice when it is not in draft state so i change the state to cancel - diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index bf577ebeaf6..6bd2f2138ec 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -28,6 +28,210 @@ class account_analytic_account(osv.osv): _name = "account.analytic.account" _inherit = "account.analytic.account" + def _analysis_all(self, cr, uid, ids, fields, arg, context=None): + dp = 2 + res = dict([(i, {}) for i in ids]) + + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + accounts = self.browse(cr, uid, ids, context=context) + + for f in fields: + if f == 'user_ids': + cr.execute('SELECT MAX(id) FROM res_users') + max_user = cr.fetchone()[0] + if parent_ids: + cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ + 'WHERE account_id IN %s AND unit_amount <> 0.0', (parent_ids,)) + result = cr.fetchall() + else: + result = [] + for id in ids: + res[id][f] = [int((id * max_user) + x[0]) for x in result] + elif f == 'month_ids': + if parent_ids: + cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \ + 'WHERE account_id IN %s AND unit_amount <> 0.0', (parent_ids,)) + result = cr.fetchall() + else: + result = [] + for id in ids: + res[id][f] = [int(id * 1000000 + int(x[0])) for x in result] + elif f == 'last_worked_invoiced_date': + for id in ids: + res[id][f] = 0.0 + if parent_ids: + cr.execute("select account_analytic_line.account_id, max(date) \ + from account_analytic_line \ + where account_id IN %s \ + and invoice_id is not null \ + GROUP BY account_analytic_line.account_id;", (parent_ids,)) + for account_id, sum in cr.fetchall(): + res[account_id][f] = sum + for account in accounts: + for child in account.child_ids: + if res[account.id].get(f, '') < res.get(child.id, {}).get(f, ''): + res[account.id][f] = res.get(child.id, {}).get(f, '') + elif f == 'ca_to_invoice': + for id in ids: + res[id][f] = 0.0 + res2 = {} + if parent_ids: + # Amount uninvoiced hours to invoice at sale price + # Warning + # This computation doesn't take care of pricelist ! + # Just consider list_price + cr.execute("""SELECT account_analytic_account.id, \ + COALESCE(sum (product_template.list_price * \ + account_analytic_line.unit_amount * \ + ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ + AS ca_to_invoice \ + FROM product_template \ + join product_product \ + on product_template.id = product_product.product_tmpl_id \ + JOIN account_analytic_line \ + on account_analytic_line.product_id = product_product.id \ + JOIN account_analytic_journal \ + on account_analytic_line.journal_id = account_analytic_journal.id \ + JOIN account_analytic_account \ + on account_analytic_account.id = account_analytic_line.account_id \ + JOIN hr_timesheet_invoice_factor \ + on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ + WHERE account_analytic_account.id IN %s \ + AND account_analytic_line.invoice_id is null \ + AND account_analytic_line.to_invoice IS NOT NULL \ + and account_analytic_journal.type in ('purchase','general') \ + GROUP BY account_analytic_account.id;""", (parent_ids,)) + for account_id, sum in cr.fetchall(): + res[account_id][f] = round(sum, dp) + + for account in accounts: + #res.setdefault(account.id, 0.0) + res2.setdefault(account.id, 0.0) + for child in account.child_ids: + if child.id != account.id: + res[account.id][f] += res.get(child.id, {}).get(f, 0.0) + res2[account.id] += res2.get(child.id, 0.0) + # sum both result on account_id + for id in ids: + res[id][f] = round(res.get(id, {}).get(f, 0.0), dp) + round(res2.get(id, 0.0), 2) + elif f == 'last_invoice_date': + for id in ids: + res[id][f] = '' + if parent_ids: + cr.execute ("select account_analytic_line.account_id, \ + date(max(account_invoice.date_invoice)) \ + from account_analytic_line \ + join account_invoice \ + on account_analytic_line.invoice_id = account_invoice.id \ + where account_analytic_line.account_id IN %s \ + and account_analytic_line.invoice_id is not null \ + GROUP BY account_analytic_line.account_id",(parent_ids,)) + for account_id, sum in cr.fetchall(): + res[account_id] = sum + for account in accounts: + for child in account.child_ids: + if res[account.id][f] < res.get(child.id, {}).get(f, ''): + res[account.id][f] = res.get(child.id, {}).get(f, '') + elif f == 'last_worked_date': + for id in ids: + res[id][f] = '' + if parent_ids: + cr.execute("select account_analytic_line.account_id, max(date) \ + from account_analytic_line \ + where account_id IN %s \ + and invoice_id is null \ + GROUP BY account_analytic_line.account_id" ,(parent_ids,)) + for account_id, sum in cr.fetchall(): + res[account_id][f] = sum + for account in accounts: + for child in account.child_ids: + if res[account.id][f] < res.get(child.id, {}).get(f, ''): + res[account.id][f] = res.get(child.id, {}).get(f, '') + elif f == 'hours_qtt_non_invoiced': + for id in ids: + res[id][f] = 0.0 + if parent_ids: + cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ + from account_analytic_line \ + join account_analytic_journal \ + on account_analytic_line.journal_id = account_analytic_journal.id \ + where account_analytic_line.account_id IN %s \ + and account_analytic_journal.type='general' \ + and invoice_id is null \ + AND to_invoice IS NOT NULL \ + GROUP BY account_analytic_line.account_id;",(parent_ids,)) + for account_id, sum in cr.fetchall(): + res[account_id][f] = round(sum, dp) + for account in accounts: + for child in account.child_ids: + if account.id != child.id: + res[account.id][f] += res.get(child.id, {}).get(f, 0.0) + for id in ids: + res[id][f] = round(res[id][f], dp) + elif f == 'hours_quantity': + for id in ids: + res[id][f] = 0.0 + if parent_ids: + cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ + from account_analytic_line \ + join account_analytic_journal \ + on account_analytic_line.journal_id = account_analytic_journal.id \ + where account_analytic_line.account_id IN %s \ + and account_analytic_journal.type='general' \ + GROUP BY account_analytic_line.account_id",(parent_ids,)) + ff = cr.fetchall() + for account_id, sum in ff: + res[account_id][f] = round(sum, dp) + for account in accounts: + for child in account.child_ids: + if account.id != child.id: + res[account.id][f] += res.get(child.id, {}).get(f, 0.0) + for id in ids: + res[id][f] = round(res[id][f], dp) + elif f == 'ca_theorical': + # TODO Take care of pricelist and purchase ! + for id in ids: + res[id][f] = 0.0 + res2 = {} + # Warning + # This computation doesn't take care of pricelist ! + # Just consider list_price + if parent_ids: + cr.execute("""select account_analytic_line.account_id as account_id, \ + COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ + - (account_analytic_line.unit_amount * pt.list_price \ + * hr.factor)),0.0) as somme + from account_analytic_line \ + left join account_analytic_journal \ + on (account_analytic_line.journal_id = account_analytic_journal.id) \ + join product_product pp \ + on (account_analytic_line.product_id = pp.id) \ + join product_template pt \ + on (pp.product_tmpl_id = pt.id) \ + join account_analytic_account a \ + on (a.id=account_analytic_line.account_id) \ + join hr_timesheet_invoice_factor hr \ + on (hr.id=a.to_invoice) \ + where account_analytic_line.account_id IN %s \ + and a.to_invoice IS NOT NULL \ + and account_analytic_journal.type IN ('purchase','general') + GROUP BY account_analytic_line.account_id""",(parent_ids,)) + for account_id, sum in cr.fetchall(): + res2[account_id] = round(sum, dp) + + for account in accounts: + res2.setdefault(account.id, 0.0) + for child in account.child_ids: + if account.id != child.id: + res[account.id][f] += res.get(child.id, {}).get(f, 0.0) + res[account.id][f] += res2.get(child.id, 0.0) + + # sum both result on account_id + for id in ids: + res[id][f] = round(res[id][f], dp) + round(res2.get(id, 0.0), dp) + + return res + def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) @@ -44,101 +248,6 @@ class account_analytic_account(osv.osv): return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) - def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context=None): - res = {} - res2 = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - # Amount uninvoiced hours to invoice at sale price - # Warning - # This computation doesn't take care of pricelist ! - # Just consider list_price - cr.execute("""SELECT account_analytic_account.id, \ - COALESCE(sum (product_template.list_price * \ - account_analytic_line.unit_amount * \ - ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ - AS ca_to_invoice \ - FROM product_template \ - join product_product \ - on product_template.id = product_product.product_tmpl_id \ - JOIN account_analytic_line \ - on account_analytic_line.product_id = product_product.id \ - JOIN account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - JOIN account_analytic_account \ - on account_analytic_account.id = account_analytic_line.account_id \ - JOIN hr_timesheet_invoice_factor \ - on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ - WHERE account_analytic_account.id IN %s \ - AND account_analytic_line.invoice_id is null \ - AND account_analytic_line.to_invoice IS NOT NULL \ - and account_analytic_journal.type in ('purchase','general') \ - GROUP BY account_analytic_account.id;""",(parent_ids,)) - for account_id, sum in cr.fetchall(): - res[account_id] = round(sum,2) - - for obj_id in ids: - res.setdefault(obj_id, 0.0) - res2.setdefault(obj_id, 0.0) - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if child_id != obj_id: - res[obj_id] += res.get(child_id, 0.0) - res2[obj_id] += res2.get(child_id, 0.0) - # sum both result on account_id - for id in ids: - res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) - return res - - def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context=None): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ - from account_analytic_line \ - join account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_journal.type='general' \ - and invoice_id is null \ - AND to_invoice IS NOT NULL \ - GROUP BY account_analytic_line.account_id;",(parent_ids,)) - for account_id, sum in cr.fetchall(): - res[account_id] = round(sum,2) - for obj_id in ids: - res.setdefault(obj_id, 0.0) - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if child_id != obj_id: - res[obj_id] += res.get(child_id, 0.0) - for id in ids: - res[id] = round(res.get(id, 0.0),2) - return res - - def _hours_quantity_calc(self, cr, uid, ids, name, arg, context=None): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ - from account_analytic_line \ - join account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_journal.type='general' \ - GROUP BY account_analytic_line.account_id",(parent_ids,)) - ff = cr.fetchall() - for account_id, sum in ff: - res[account_id] = round(sum,2) - for obj_id in ids: - res.setdefault(obj_id, 0.0) - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if child_id != obj_id: - res[obj_id] += res.get(child_id, 0.0) - for id in ids: - res[id] = round(res.get(id, 0.0),2) - return res - def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) @@ -155,117 +264,6 @@ class account_analytic_account(osv.osv): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) - # TODO Take care of pricelist and purchase ! - def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): - res = {} - res2 = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - # Warning - # This computation doesn't take care of pricelist ! - # Just consider list_price - if parent_ids: - cr.execute("""select account_analytic_line.account_id as account_id, \ - COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - - (account_analytic_line.unit_amount * pt.list_price \ - * hr.factor)),0.0) as somme - from account_analytic_line \ - left join account_analytic_journal \ - on (account_analytic_line.journal_id = account_analytic_journal.id) \ - join product_product pp \ - on (account_analytic_line.product_id = pp.id) \ - join product_template pt \ - on (pp.product_tmpl_id = pt.id) \ - join account_analytic_account a \ - on (a.id=account_analytic_line.account_id) \ - join hr_timesheet_invoice_factor hr \ - on (hr.id=a.to_invoice) \ - where account_analytic_line.account_id IN %s \ - and a.to_invoice IS NOT NULL \ - and account_analytic_journal.type IN ('purchase','general') - GROUP BY account_analytic_line.account_id""",(parent_ids,)) - for account_id, sum in cr.fetchall(): - res2[account_id] = round(sum,2) - - for obj_id in ids: - res.setdefault(obj_id, 0.0) - res2.setdefault(obj_id, 0.0) - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if child_id != obj_id: - res[obj_id] += res.get(child_id, 0.0) - res[obj_id] += res2.get(child_id, 0.0) - - # sum both result on account_id - for id in ids: - res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) - return res - - def _last_worked_date_calc (self, cr, uid, ids, name, arg, context=None): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute("select account_analytic_line.account_id, max(date) \ - from account_analytic_line \ - where account_id IN %s \ - and invoice_id is null \ - GROUP BY account_analytic_line.account_id" ,(parent_ids,)) - for account_id, sum in cr.fetchall(): - res[account_id] = sum - for obj_id in ids: - res.setdefault(obj_id, '') - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if res[obj_id] < res.get(child_id, ''): - res[obj_id] = res.get(child_id, '') - for id in ids: - res[id] = res.get(id, '') - return res - - def _last_invoice_date_calc (self, cr, uid, ids, name, arg, context=None): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute ("select account_analytic_line.account_id, \ - date(max(account_invoice.date_invoice)) \ - from account_analytic_line \ - join account_invoice \ - on account_analytic_line.invoice_id = account_invoice.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_line.invoice_id is not null \ - GROUP BY account_analytic_line.account_id",(parent_ids,)) - for account_id, sum in cr.fetchall(): - res[account_id] = sum - for obj_id in ids: - res.setdefault(obj_id, '') - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if res[obj_id] < res.get(child_id, ''): - res[obj_id] = res.get(child_id, '') - for id in ids: - res[id] = res.get(id, '') - return res - - def _last_worked_invoiced_date_calc (self, cr, uid, ids, name, arg, context=None): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute("select account_analytic_line.account_id, max(date) \ - from account_analytic_line \ - where account_id IN %s \ - and invoice_id is not null \ - GROUP BY account_analytic_line.account_id;",(parent_ids,)) - for account_id, sum in cr.fetchall(): - res[account_id] = sum - for obj_id in ids: - res.setdefault(obj_id, '') - for child_id in self.search(cr, uid, - [('parent_id', 'child_of', [obj_id])]): - if res[obj_id] < res.get(child_id, ''): - res[obj_id] = res.get(child_id, '') - for id in ids: - res[id] = res.get(id, '') - return res - def _remaining_hours_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids): @@ -338,42 +336,16 @@ class account_analytic_account(osv.osv): res[id] = round(res.get(id, 0.0),2) return res - def _month(self, cr, uid, ids, name, arg, context=None): - res = {} - for id in ids: - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \ - 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) - res[id] = [int(id * 1000000 + int(x[0])) for x in cr.fetchall()] - else: - res[id] = [] - return res - - def _user(self, cr, uid, ids, name, arg, context=None): - res = {} - cr.execute('SELECT MAX(id) FROM res_users') - max_user = cr.fetchone()[0] - for id in ids: - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - if parent_ids: - cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ - 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) - res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] - else: - res[id] = [] - return res - _columns ={ 'ca_invoiced': fields.function(_ca_invoiced_calc, method=True, type='float', string='Invoiced Amount', help="Total customer invoiced amount for this account."), 'total_cost': fields.function(_total_cost_calc, method=True, type='float', string='Total Costs', help="Total of costs for this account. It includes real costs (from invoices) and indirect costs, like time spent on timesheets."), - 'ca_to_invoice': fields.function(_ca_to_invoice_calc, method=True, type='float', string='Uninvoiced Amount', help="If invoice from analytic account, the remaining amount you can invoice to the customer based on the total costs."), - 'ca_theorical': fields.function(_ca_theorical_calc, method=True, type='float', string='Theorical Revenue', help="Based on the costs you had on the project, what would have been the revenue if all these costs have been invoiced at the normal sale price provided by the pricelist."), - 'hours_quantity': fields.function(_hours_quantity_calc, method=True, type='float', string='Hours Tot', help="Number of hours you spent on the analytic account (from timesheet). It computes on all journal of type 'general'."), - 'last_invoice_date': fields.function(_last_invoice_date_calc, method=True, type='date', string='Last Invoice Date', help="Date of the last invoice created for this analytic account."), - 'last_worked_invoiced_date': fields.function(_last_worked_invoiced_date_calc, method=True, type='date', string='Date of Last Invoiced Cost', help="If invoice from the costs, this is the date of the latest work or cost that have been invoiced."), - 'last_worked_date': fields.function(_last_worked_date_calc, method=True, type='date', string='Date of Last Cost/Work', help="Date of the latest work done on this account."), - 'hours_qtt_non_invoiced': fields.function(_hours_qtt_non_invoiced_calc, method=True, type='float', string='Uninvoiced Hours', help="Number of hours (from journal of type 'general') that can be invoiced if you invoice based on analytic account."), + 'ca_to_invoice': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Uninvoiced Amount', help="If invoice from analytic account, the remaining amount you can invoice to the customer based on the total costs."), + 'ca_theorical': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Theorical Revenue', help="Based on the costs you had on the project, what would have been the revenue if all these costs have been invoiced at the normal sale price provided by the pricelist."), + 'hours_quantity': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Hours Tot', help="Number of hours you spent on the analytic account (from timesheet). It computes on all journal of type 'general'."), + 'last_invoice_date': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='date', string='Last Invoice Date', help="Date of the last invoice created for this analytic account."), + 'last_worked_invoiced_date': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='date', string='Date of Last Invoiced Cost', help="If invoice from the costs, this is the date of the latest work or cost that have been invoiced."), + 'last_worked_date': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='date', string='Date of Last Cost/Work', help="Date of the latest work done on this account."), + 'hours_qtt_non_invoiced': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='float', string='Uninvoiced Hours', help="Number of hours (from journal of type 'general') that can be invoiced if you invoice based on analytic account."), 'hours_qtt_invoiced': fields.function(_hours_qtt_invoiced_calc, method=True, type='float', string='Invoiced Hours', help="Number of hours that can be invoiced plus those that already have been invoiced."), 'remaining_hours': fields.function(_remaining_hours_calc, method=True, type='float', string='Remaining Hours', help="Computed using the formula: Maximum Quantity - Hours Tot."), 'remaining_ca': fields.function(_remaining_ca_calc, method=True, type='float', string='Remaining Revenue', help="Computed using the formula: Max Invoice Price - Invoiced Amount."), @@ -381,8 +353,8 @@ class account_analytic_account(osv.osv): 'real_margin': fields.function(_real_margin_calc, method=True, type='float', string='Real Margin', help="Computed using the formula: Invoiced Amount - Total Costs."), 'theorical_margin': fields.function(_theorical_margin_calc, method=True, type='float', string='Theorical Margin', help="Computed using the formula: Theorial Revenue - Total Costs"), 'real_margin_rate': fields.function(_real_margin_rate_calc, method=True, type='float', string='Real Margin Rate (%)', help="Computes using the formula: (Real Margin / Total Costs) * 100."), - 'month_ids': fields.function(_month, method=True, type='many2many', relation='account_analytic_analysis.summary.month', string='Month'), - 'user_ids': fields.function(_user, method=True, type="many2many", relation='account_analytic_analysis.summary.user', string='User'), + 'month_ids': fields.function(_analysis_all, method=True, multi='analytic_analysis', type='many2many', relation='account_analytic_analysis.summary.month', string='Month'), + 'user_ids': fields.function(_analysis_all, method=True, multi='analytic_analysis', type="many2many", relation='account_analytic_analysis.summary.user', string='User'), } account_analytic_account() diff --git a/addons/account_reporting/report/account_report_bs.rml b/addons/account_reporting/report/account_report_bs.rml index b33ebb4bcc8..c0fa4f1e2d2 100644 --- a/addons/account_reporting/report/account_report_bs.rml +++ b/addons/account_reporting/report/account_report_bs.rml @@ -155,7 +155,7 @@ [[ company.currency_id.name ]] - [[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]] [[o.name]] + [[ setTag('font','font',{'face':o.font_style or "Helvetica",'color':o.color_font.name or "black",'backColor':o.color_back.name or "white"}) ]] [[o.name]] diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index eef25f665d8..b97edb9a546 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -35,16 +35,16 @@ class account_analytic_account(osv.osv): cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),)) currency = dict(cr.fetchall()) res_currency= self.pool.get('res.currency') - for id in ids: - if id not in ids2: + for account in self.browse(cr, uid, ids, context=context): + if account.id not in ids2: continue - for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): - if child != id: - res.setdefault(id, 0.0) - if currency[child]!=currency[id]: - res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context) + for child in account.child_ids: + if child.id != account.id: + res.setdefault(account.id, 0.0) + if currency[child.id] != currency[account.id]: + res[account.id] += res_currency.compute(cr, uid, currency[child.id], currency[account.id], res.get(child.id, 0.0), context=context) else: - res[id] += res.get(child, 0.0) + res[account.id] += res.get(child.id, 0.0) cur_obj = res_currency.browse(cr, uid, currency.values(), context=context) cur_obj = dict([(o.id, o) for o in cur_obj]) @@ -145,13 +145,13 @@ class account_analytic_account(osv.osv): for account_id, sum in cr.fetchall(): res[account_id] = sum - for id in ids: - if id not in parent_ids: + for account in self.browse(cr, uid, ids, context=context): + if account.id not in parent_ids: continue - for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): - if child != id: - res.setdefault(id, 0.0) - res[id] += res.get(child, 0.0) + for child in account.child_ids: + if child.id != account.id: + res.setdefault(account.id, 0.0) + res[account.id] += res.get(child.id, 0.0) return dict([(i, res[i]) for i in ids]) def name_get(self, cr, uid, ids, context=None): diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml index aaf344043d7..e816e3f0b1d 100644 --- a/addons/crm/crm_opportunity_view.xml +++ b/addons/crm/crm_opportunity_view.xml @@ -220,7 +220,6 @@ -