diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 1b4795f02a8..5b09f815f54 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -409,7 +409,7 @@ class account_invoice(osv.osv): ''' assert len(ids) == 1, 'This option should only be used for a single id at a time.' self.write(cr, uid, ids, {'sent': True}, context=context) - return self.pool['report'].get_action(cr, uid, [], 'account.report_invoice', context=context) + return self.pool['report'].get_action(cr, uid, ids, 'account.report_invoice', context=context) def action_invoice_sent(self, cr, uid, ids, context=None): ''' diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 729c9d16b7a..628cc7229e5 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -1040,7 +1040,7 @@ class account_move_line(osv.osv): if opening_reconciliation: obj_move_rec.write(cr, uid, unlink_ids, {'opening_reconciliation': False}) obj_move_rec.unlink(cr, uid, unlink_ids) - if all_moves: + if len(all_moves) >= 2: obj_move_line.reconcile_partial(cr, uid, all_moves, 'auto',context=context) return True diff --git a/addons/account/project/wizard/account_analytic_balance_report.py b/addons/account/project/wizard/account_analytic_balance_report.py index 3a3c301cffc..062945fa53e 100644 --- a/addons/account/project/wizard/account_analytic_balance_report.py +++ b/addons/account/project/wizard/account_analytic_balance_report.py @@ -50,6 +50,6 @@ class account_analytic_balance(osv.osv_memory): datas['form']['active_ids'] = context.get('active_ids', False) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_analyticbalance', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticbalance', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py index 125dfda46fb..ab84af4880a 100644 --- a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py +++ b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py @@ -49,6 +49,6 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory): } datas['form']['active_ids'] = context.get('active_ids', False) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_analyticcostledgerquantity', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticcostledgerquantity', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_cost_ledger_report.py b/addons/account/project/wizard/account_analytic_cost_ledger_report.py index 5f00c3c9ac5..978863f5900 100644 --- a/addons/account/project/wizard/account_analytic_cost_ledger_report.py +++ b/addons/account/project/wizard/account_analytic_cost_ledger_report.py @@ -49,6 +49,6 @@ class account_analytic_cost_ledger(osv.osv_memory): datas['form']['active_ids'] = context.get('active_ids', False) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_analyticcostledger', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticcostledger', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_inverted_balance_report.py b/addons/account/project/wizard/account_analytic_inverted_balance_report.py index ad79c0b33f6..93946960297 100644 --- a/addons/account/project/wizard/account_analytic_inverted_balance_report.py +++ b/addons/account/project/wizard/account_analytic_inverted_balance_report.py @@ -47,6 +47,6 @@ class account_analytic_inverted_balance(osv.osv_memory): 'form': data } datas['form']['active_ids'] = context.get('active_ids', False) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_invertedanalyticbalance', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_invertedanalyticbalance', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/account_analytic_journal_report.py b/addons/account/project/wizard/account_analytic_journal_report.py index f2e406bc3a5..d8790e805d8 100644 --- a/addons/account/project/wizard/account_analytic_journal_report.py +++ b/addons/account/project/wizard/account_analytic_journal_report.py @@ -57,7 +57,7 @@ class account_analytic_journal_report(osv.osv_memory): context2 = context.copy() context2['active_model'] = 'account.analytic.journal' context2['active_ids'] = ids_list - return self.pool['report'].get_action(cr, uid, ids, 'account.report_analyticjournal', data=datas, context=context2) + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticjournal', data=datas, context=context2) def default_get(self, cr, uid, fields, context=None): if context is None: diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index 6757095a7d4..6c4b701c6cf 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -47,7 +47,6 @@ Description Quantity - Unit of measure Unit Price Discount (%) Taxes @@ -57,8 +56,10 @@ - - + + + + @@ -100,7 +101,7 @@
-
+
@@ -136,7 +137,7 @@

Fiscal Position: - +

diff --git a/addons/account/wizard/account_financial_report.py b/addons/account/wizard/account_financial_report.py index 6c1b57fa428..721e47193a2 100644 --- a/addons/account/wizard/account_financial_report.py +++ b/addons/account/wizard/account_financial_report.py @@ -89,6 +89,6 @@ class accounting_report(osv.osv_memory): def _print_report(self, cr, uid, ids, data, context=None): data['form'].update(self.read(cr, uid, ids, ['date_from_cmp', 'debit_credit', 'date_to_cmp', 'fiscalyear_id_cmp', 'period_from_cmp', 'period_to_cmp', 'filter_cmp', 'account_report_id', 'enable_filter', 'label_filter','target_move'], context=context)[0]) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_financial', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_financial', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_account_balance.py b/addons/account/wizard/account_report_account_balance.py index 3b9d3c21777..9eba5f24b99 100644 --- a/addons/account/wizard/account_report_account_balance.py +++ b/addons/account/wizard/account_report_account_balance.py @@ -21,6 +21,7 @@ from openerp.osv import fields, osv + class account_balance_report(osv.osv_memory): _inherit = "account.common.account.report" _name = 'account.balance.report' @@ -36,6 +37,6 @@ class account_balance_report(osv.osv_memory): def _print_report(self, cr, uid, ids, data, context=None): data = self.pre_print_report(cr, uid, ids, data, context=context) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_trialbalance', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_trialbalance', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_aged_partner_balance.py b/addons/account/wizard/account_report_aged_partner_balance.py index c918a1119fd..d7b57eaba02 100644 --- a/addons/account/wizard/account_report_aged_partner_balance.py +++ b/addons/account/wizard/account_report_aged_partner_balance.py @@ -81,6 +81,6 @@ class account_aged_trial_balance(osv.osv_memory): data['form'].update(res) if data.get('form',False): data['ids']=[data['form'].get('chart_account_id',False)] - return self.pool['report'].get_action(cr, uid, ids, 'account.report_agedpartnerbalance', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_agedpartnerbalance', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_central_journal.py b/addons/account/wizard/account_report_central_journal.py index 9f22d49afac..a31fef91ae4 100644 --- a/addons/account/wizard/account_report_central_journal.py +++ b/addons/account/wizard/account_report_central_journal.py @@ -21,6 +21,7 @@ from openerp.osv import fields, osv + class account_central_journal(osv.osv_memory): _name = 'account.central.journal' _description = 'Account Central Journal' @@ -32,6 +33,6 @@ class account_central_journal(osv.osv_memory): def _print_report(self, cr, uid, ids, data, context=None): data = self.pre_print_report(cr, uid, ids, data, context=context) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_centraljournal', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_centraljournal', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_general_journal.py b/addons/account/wizard/account_report_general_journal.py index 3d9d55b19c1..c35a5920428 100644 --- a/addons/account/wizard/account_report_general_journal.py +++ b/addons/account/wizard/account_report_general_journal.py @@ -21,6 +21,7 @@ from openerp.osv import fields, osv + class account_general_journal(osv.osv_memory): _inherit = "account.common.journal.report" _name = 'account.general.journal' @@ -32,6 +33,6 @@ class account_general_journal(osv.osv_memory): def _print_report(self, cr, uid, ids, data, context=None): data = self.pre_print_report(cr, uid, ids, data, context=context) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_generaljournal', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_generaljournal', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_general_ledger.py b/addons/account/wizard/account_report_general_ledger.py index c75477da40a..5f0a302d720 100644 --- a/addons/account/wizard/account_report_general_ledger.py +++ b/addons/account/wizard/account_report_general_ledger.py @@ -59,6 +59,6 @@ class account_report_general_ledger(osv.osv_memory): if data['form']['landscape'] is False: data['form'].pop('landscape') - return self.pool['report'].get_action(cr, uid, ids, 'account.report_generalledger', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_generalledger', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_partner_balance.py b/addons/account/wizard/account_report_partner_balance.py index d4b5fb27d14..7485bec67fe 100644 --- a/addons/account/wizard/account_report_partner_balance.py +++ b/addons/account/wizard/account_report_partner_balance.py @@ -44,6 +44,6 @@ class account_partner_balance(osv.osv_memory): context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) data['form'].update(self.read(cr, uid, ids, ['display_partner'])[0]) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_partnerbalance', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_partnerbalance', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_partner_ledger.py b/addons/account/wizard/account_report_partner_ledger.py index eb743e32e4f..38ff6988fd7 100644 --- a/addons/account/wizard/account_report_partner_ledger.py +++ b/addons/account/wizard/account_report_partner_ledger.py @@ -58,7 +58,7 @@ class account_partner_ledger(osv.osv_memory): data = self.pre_print_report(cr, uid, ids, data, context=context) data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'filter', 'page_split', 'amount_currency'])[0]) if data['form'].get('page_split') is True: - return self.pool['report'].get_action(cr, uid, ids, 'account.report_partnerledgerother', data=data, context=context) - return self.pool['report'].get_action(cr, uid, ids, 'account.report_partnerledger', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_partnerledgerother', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_partnerledger', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_print_journal.py b/addons/account/wizard/account_report_print_journal.py index 3aafc63acf4..1f6b6e0cf4d 100644 --- a/addons/account/wizard/account_report_print_journal.py +++ b/addons/account/wizard/account_report_print_journal.py @@ -67,8 +67,8 @@ class account_print_journal(osv.osv_memory): data = self.pre_print_report(cr, uid, ids, data, context=context) data['form'].update(self.read(cr, uid, ids, ['sort_selection'], context=context)[0]) if context.get('sale_purchase_only'): - return self.pool['report'].get_action(cr, uid, ids, 'account.report_salepurchasejournal', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_salepurchasejournal', data=data, context=context) else: - return self.pool['report'].get_action(cr, uid, ids, 'account.report_journal', data=data, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_journal', data=data, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_vat.py b/addons/account/wizard/account_vat.py index 5cc5c678df1..e7c806be2f9 100644 --- a/addons/account/wizard/account_vat.py +++ b/addons/account/wizard/account_vat.py @@ -61,6 +61,6 @@ class account_vat_declaration(osv.osv_memory): taxcode = taxcode_obj.browse(cr, uid, [taxcode_id], context=context)[0] datas['form']['company_id'] = taxcode.company_id.id - return self.pool['report'].get_action(cr, uid, ids, 'account.report_vat', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account.report_vat', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 5aa4b5a49db..6c71f940e8a 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -652,12 +652,10 @@ class account_analytic_account(osv.osv): 'nodestroy': True, } - def _prepare_invoice(self, cr, uid, contract, context=None): + def _prepare_invoice_data(self, cr, uid, contract, context=None): context = context or {} - inv_obj = self.pool.get('account.invoice') journal_obj = self.pool.get('account.journal') - fpos_obj = self.pool.get('account.fiscal.position') if not contract.partner_id: raise osv.except_osv(_('No Customer Defined!'),_("You must first select a Customer for Contract %s!") % contract.name ) @@ -678,33 +676,36 @@ class account_analytic_account(osv.osv): elif contract.company_id: currency_id = contract.company_id.currency_id.id - inv_data = { - 'reference': contract.code or False, + invoice = { 'account_id': contract.partner_id.property_account_receivable.id, 'type': 'out_invoice', 'partner_id': contract.partner_id.id, 'currency_id': currency_id, 'journal_id': len(journal_ids) and journal_ids[0] or False, 'date_invoice': contract.recurring_next_date, - 'origin': contract.name, + 'origin': contract.code, 'fiscal_position': fpos and fpos.id, 'payment_term': partner_payment_term, 'company_id': contract.company_id.id or False, } - invoice_id = inv_obj.create(cr, uid, inv_data, context=context) + return invoice + def _prepare_invoice_lines(self, cr, uid, contract, fiscal_position_id, context=None): + fpos_obj = self.pool.get('account.fiscal.position') + fiscal_position = fpos_obj.browse(cr, uid, fiscal_position_id, context=context) + invoice_lines = [] for line in contract.recurring_invoice_line_ids: res = line.product_id account_id = res.property_account_income.id if not account_id: account_id = res.categ_id.property_account_income_categ.id - account_id = fpos_obj.map_account(cr, uid, fpos, account_id) + account_id = fpos_obj.map_account(cr, uid, fiscal_position, account_id) taxes = res.taxes_id or False - tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes) + tax_id = fpos_obj.map_tax(cr, uid, fiscal_position, taxes) - invoice_line_vals = { + invoice_lines.append((0, 0, { 'name': line.name, 'account_id': account_id, 'account_analytic_id': contract.id, @@ -712,13 +713,14 @@ class account_analytic_account(osv.osv): 'quantity': line.quantity, 'uos_id': line.uom_id.id or False, 'product_id': line.product_id.id or False, - 'invoice_id' : invoice_id, 'invoice_line_tax_id': [(6, 0, tax_id)], - } - self.pool.get('account.invoice.line').create(cr, uid, invoice_line_vals, context=context) + })) + return invoice_lines - inv_obj.button_compute(cr, uid, [invoice_id], context=context) - return invoice_id + def _prepare_invoice(self, cr, uid, contract, context=None): + invoice = self._prepare_invoice_data(cr, uid, contract, context=context) + invoice['invoice_line'] = self._prepare_invoice_lines(cr, uid, contract, invoice['fiscal_position'], context=context) + return invoice def recurring_create_invoice(self, cr, uid, ids, context=None): return self._recurring_create_invoice(cr, uid, ids, context=context) @@ -728,6 +730,7 @@ class account_analytic_account(osv.osv): def _recurring_create_invoice(self, cr, uid, ids, automatic=False, context=None): context = context or {} + invoice_ids = [] current_date = time.strftime('%Y-%m-%d') if ids: contract_ids = ids @@ -735,8 +738,8 @@ class account_analytic_account(osv.osv): contract_ids = self.search(cr, uid, [('recurring_next_date','<=', current_date), ('state','=', 'open'), ('recurring_invoices','=', True), ('type', '=', 'contract')]) for contract in self.browse(cr, uid, contract_ids, context=context): try: - invoice_id = self._prepare_invoice(cr, uid, contract, context=context) - + invoice_values = self._prepare_invoice(cr, uid, contract, context=context) + invoice_ids.append(self.pool['account.invoice'].create(cr, uid, invoice_values, context=context)) next_date = datetime.datetime.strptime(contract.recurring_next_date or current_date, "%Y-%m-%d") interval = contract.recurring_interval if contract.recurring_rule_type == 'daily': @@ -754,7 +757,7 @@ class account_analytic_account(osv.osv): _logger.error(traceback.format_exc()) else: raise - return True + return invoice_ids class account_analytic_account_summary_user(osv.osv): _name = "account_analytic_analysis.summary.user" diff --git a/addons/account_analytic_plans/wizard/account_crossovered_analytic.py b/addons/account_analytic_plans/wizard/account_crossovered_analytic.py index ccac123c681..1bdc91f2995 100644 --- a/addons/account_analytic_plans/wizard/account_crossovered_analytic.py +++ b/addons/account_analytic_plans/wizard/account_crossovered_analytic.py @@ -24,6 +24,7 @@ import time from openerp.osv import fields, osv from openerp.tools.translate import _ + class account_crossovered_analytic(osv.osv_memory): _name = "account.crossovered.analytic" _description = "Print Crossovered Analytic" @@ -65,6 +66,6 @@ class account_crossovered_analytic(osv.osv_memory): 'model': 'account.analytic.account', 'form': data } - return self.pool['report'].get_action(cr, uid, ids, 'account_analytic_plans.report_crossoveredanalyticplans', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account_analytic_plans.report_crossoveredanalyticplans', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/wizard/account_budget_analytic.py b/addons/account_budget/wizard/account_budget_analytic.py index a58b804ebbf..bd3bbdc8d99 100644 --- a/addons/account_budget/wizard/account_budget_analytic.py +++ b/addons/account_budget/wizard/account_budget_analytic.py @@ -46,6 +46,6 @@ class account_budget_analytic(osv.osv_memory): 'form': data } datas['form']['ids'] = datas['ids'] - return self.pool['report'].get_action(cr, uid, ids, 'account_budget.report_analyticaccountbudget', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account_budget.report_analyticaccountbudget', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/wizard/account_budget_crossovered_report.py b/addons/account_budget/wizard/account_budget_crossovered_report.py index 96561df5af0..e47ff5cb421 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_report.py @@ -47,6 +47,6 @@ class account_budget_crossvered_report(osv.osv_memory): } datas['form']['ids'] = datas['ids'] datas['form']['report'] = 'analytic-full' - return self.pool['report'].get_action(cr, uid, ids, 'account_budget.report_crossoveredbudget', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account_budget.report_crossoveredbudget', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/wizard/account_budget_crossovered_summary_report.py b/addons/account_budget/wizard/account_budget_crossovered_summary_report.py index 6b676ecc684..d79e6097787 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_summary_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_summary_report.py @@ -49,6 +49,6 @@ class account_budget_crossvered_summary_report(osv.osv_memory): } datas['form']['ids'] = datas['ids'] datas['form']['report'] = 'analytic-one' - return self.pool['report'].get_action(cr, uid, ids, 'account_budget.report_crossoveredbudget', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account_budget.report_crossoveredbudget', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_budget/wizard/account_budget_report.py b/addons/account_budget/wizard/account_budget_report.py index 2308b5ff9ac..fb1814a9171 100644 --- a/addons/account_budget/wizard/account_budget_report.py +++ b/addons/account_budget/wizard/account_budget_report.py @@ -47,6 +47,6 @@ class account_budget_report(osv.osv_memory): } datas['form']['ids'] = datas['ids'] datas['form']['report'] = 'analytic-full' - return self.pool['report'].get_action(cr, uid, ids, 'account_budget.report_budget', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account_budget.report_budget', data=datas, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_check_writing/account_voucher.py b/addons/account_check_writing/account_voucher.py index c3abe28eef0..779ff61be44 100644 --- a/addons/account_check_writing/account_voucher.py +++ b/addons/account_check_writing/account_voucher.py @@ -74,26 +74,17 @@ class account_voucher(osv.osv): def print_check(self, cr, uid, ids, context=None): if not ids: - return {} + raise osv.except_osv(_('Printing error'), _('No check selected ')) - check_layout_report = { - 'top' : 'account.print.check.top', - 'middle' : 'account.print.check.middle', - 'bottom' : 'account.print.check.bottom', + data = { + 'id': ids and ids[0], + 'ids': ids, } - check_layout = self.browse(cr, uid, ids[0], context=context).company_id.check_layout - return { - 'type': 'ir.actions.report.xml', - 'report_name':check_layout_report[check_layout], - 'datas': { - 'model':'account.voucher', - 'id': ids and ids[0] or False, - 'ids': ids and ids or [], - 'report_type': 'pdf' - }, - 'nodestroy': True - } + return self.pool['report'].get_action( + cr, uid, [], 'account_check_writing.report_check', data=data, context=context + ) + def create(self, cr, uid, vals, context=None): if vals.get('amount') and vals.get('journal_id') and 'amount_in_word' not in vals: vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], vals.get('currency_id') or \ diff --git a/addons/account_check_writing/wizard/account_check_batch_printing.py b/addons/account_check_writing/wizard/account_check_batch_printing.py index c3a13e2c687..bf59557d904 100644 --- a/addons/account_check_writing/wizard/account_check_batch_printing.py +++ b/addons/account_check_writing/wizard/account_check_batch_printing.py @@ -20,9 +20,9 @@ ############################################################################## from openerp.tools.translate import _ - from openerp.osv import fields, osv + class account_check_write(osv.osv_memory): _name = 'account.check.write' _description = 'Prin Check in Batch' @@ -64,23 +64,11 @@ class account_check_write(osv.osv_memory): ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value}) #print the checks - check_layout_report = { - 'top' : 'account.print.check.top', - 'middle' : 'account.print.check.middle', - 'bottom' : 'account.print.check.bottom', + data = { + 'id': voucher_ids and voucher_ids[0], + 'ids': voucher_ids, } - check_layout = voucher_obj.browse(cr, uid, voucher_ids[0], context=context).company_id.check_layout - if not check_layout: - check_layout = 'top' - return { - 'type': 'ir.actions.report.xml', - 'report_name':check_layout_report[check_layout], - 'datas': { - 'model':'account.voucher', - 'ids': voucher_ids, - 'report_type': 'pdf' - }, - 'nodestroy': True - } - + return self.pool['report'].get_action( + cr, uid, [], 'account_check_writing.report_check', data=data, context=context + ) diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py index 820a179efdb..ddeb1f380c4 100644 --- a/addons/account_followup/account_followup.py +++ b/addons/account_followup/account_followup.py @@ -188,7 +188,7 @@ class res_partner(osv.osv): 'model': 'account_followup.followup', 'form': data } - return self.pool['report'].get_action(cr, uid, wizard_partner_ids, 'account_followup.report_followup', data=datas, context=context) + return self.pool['report'].get_action(cr, uid, [], 'account_followup.report_followup', data=datas, context=context) def do_partner_mail(self, cr, uid, partner_ids, context=None): if context is None: diff --git a/addons/auth_oauth/auth_oauth_view.xml b/addons/auth_oauth/auth_oauth_view.xml index ffc39752ec6..5c889d3a686 100644 --- a/addons/auth_oauth/auth_oauth_view.xml +++ b/addons/auth_oauth/auth_oauth_view.xml @@ -11,6 +11,7 @@ + diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 1abcdac9712..fef80bb8a53 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -14,6 +14,7 @@ Dead 1 + 1 0 1 30 diff --git a/addons/crm/static/description/index.html b/addons/crm/static/description/index.html index 5f3fd65cdc2..799dee38cf0 100644 --- a/addons/crm/static/description/index.html +++ b/addons/crm/static/description/index.html @@ -88,7 +88,7 @@ Find duplicates, merge leads and assign them to the right salesperson in one ope

Get your opportunities organized to stay focused on the best deals. Manage all your customer interactions from the opportunity like emails, phone calls, internal notes, meetings and quotations.

-Follow opportunities that interrests you to get notified upon specific events: deal won or lost, stage changed, new customer demand, etc. +Follow opportunities that interest you to get notified upon specific events: deal won or lost, stage changed, new customer demand, etc.

diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index ecb4c495d94..63c23f30cff 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -217,15 +217,7 @@ class gamification_challenge(osv.Model): vals['user_ids'] = [] vals['user_ids'] += [(4, user_id) for user_id in user_ids] - create_res = super(gamification_challenge, self).create(cr, uid, vals, context=context) - - # subscribe new users to the challenge - if vals.get('user_ids'): - # done with browse after super to be sure catch all after orm process - challenge = self.browse(cr, uid, create_res, context=context) - self.message_subscribe_users(cr, uid, [challenge.id], [user.id for user in challenge.user_ids], context=context) - - return create_res + return super(gamification_challenge, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int,long)): @@ -240,6 +232,11 @@ class gamification_challenge(osv.Model): write_res = super(gamification_challenge, self).write(cr, uid, ids, vals, context=context) + if vals.get('report_message_frequency', 'never') != 'never': + # _recompute_challenge_users do not set users for challenges with no reports, subscribing them now + for challenge in self.browse(cr, uid, ids, context=context): + self.message_subscribe(cr, uid, [challenge.id], [user.partner_id.id for user in challenge.user_ids], context=context) + if vals.get('state') == 'inprogress': self._recompute_challenge_users(cr, uid, ids, context=context) self._generate_goals_from_challenge(cr, uid, ids, context=context) @@ -264,6 +261,9 @@ class gamification_challenge(osv.Model): - Create the missing goals (eg: modified the challenge to add lines) - Update every running challenge """ + if context is None: + context = {} + # start scheduled challenges planned_challenge_ids = self.search(cr, uid, [ ('state', '=', 'draft'), @@ -281,6 +281,9 @@ class gamification_challenge(osv.Model): if not ids: ids = self.search(cr, uid, [('state', '=', 'inprogress')], context=context) + # in cron mode, will do intermediate commits + # TODO in trunk: replace by parameter + context.update({'commit_gamification': True}) return self._update_all(cr, uid, ids, context=context) def _update_all(self, cr, uid, ids, context=None): @@ -355,11 +358,6 @@ class gamification_challenge(osv.Model): if write_op: self.write(cr, uid, [challenge.id], {'user_ids': write_op}, context=context) - if to_remove_ids: - self.message_unsubscribe_users(cr, uid, [challenge.id], to_remove_ids, context=None) - if to_add_ids: - self.message_subscribe_users(cr, uid, [challenge.id], to_add_ids, context=context) - return True @@ -393,9 +391,9 @@ class gamification_challenge(osv.Model): :param list(int) ids: the list of challenge concerned""" goal_obj = self.pool.get('gamification.goal') - to_update = [] for challenge in self.browse(cr, uid, ids, context=context): (start_date, end_date) = start_end_date_for_period(challenge.period) + to_update = [] # if no periodicity, use challenge dates if not start_date and challenge.start_date: @@ -426,7 +424,15 @@ class gamification_challenge(osv.Model): cr.execute(query, query_params) user_with_goal_ids = cr.dictfetchall() - user_without_goal_ids = list(set([user.id for user in challenge.user_ids]) - set([user['user_id'] for user in user_with_goal_ids])) + + participant_user_ids = [user.id for user in challenge.user_ids] + user_without_goal_ids = list(set(participant_user_ids) - set([user['user_id'] for user in user_with_goal_ids])) + user_squating_challenge_ids = list(set([user['user_id'] for user in user_with_goal_ids]) - set(participant_user_ids)) + if user_squating_challenge_ids: + # users that used to match the challenge + goal_to_remove_ids = goal_obj.search(cr, uid, [('challenge_id', '=', challenge.id), ('user_id', 'in', user_squating_challenge_ids)], context=context) + goal_obj.unlink(cr, uid, goal_to_remove_ids, context=context) + values = { 'definition_id': line.definition_id.id, @@ -614,9 +620,10 @@ class gamification_challenge(osv.Model): ctx.update({'challenge_lines': lines_boards}) body_html = temp_obj.render_template(cr, uid, challenge.report_template_id.body_html, 'gamification.challenge', challenge.id, context=ctx) - # send to every follower of the challenge + # send to every follower and participant of the challenge self.message_post(cr, uid, challenge.id, body=body_html, + partner_ids=[user.partner_id.id for user in challenge.user_ids], context=context, subtype='mail.mt_comment') if challenge.report_message_group_id: @@ -698,34 +705,35 @@ class gamification_challenge(osv.Model): rewarded_users = [] challenge_ended = end_date == yesterday.strftime(DF) or force if challenge.reward_id and challenge_ended or challenge.reward_realtime: - for user in challenge.user_ids: - reached_goal_ids = self.pool.get('gamification.goal').search(cr, uid, [ - ('challenge_id', '=', challenge.id), - ('user_id', '=', user.id), - ('start_date', '=', start_date), - ('end_date', '=', end_date), - ('state', '=', 'reached') - ], context=context) - if len(reached_goal_ids) == len(challenge.line_ids): + # not using start_date as intemportal goals have a start date but no end_date + reached_goals = self.pool.get('gamification.goal').read_group(cr, uid, [ + ('challenge_id', '=', challenge.id), + ('end_date', '=', end_date), + ('state', '=', 'reached') + ], fields=['user_id'], groupby=['user_id'], context=context) + for reach_goals_user in reached_goals: + if reach_goals_user['user_id_count'] == len(challenge.line_ids): # the user has succeeded every assigned goal + user_id = reach_goals_user['user_id'][0] if challenge.reward_realtime: badges = self.pool['gamification.badge.user'].search(cr, uid, [ ('challenge_id', '=', challenge.id), ('badge_id', '=', challenge.reward_id.id), - ('user_id', '=', user.id), + ('user_id', '=', user_id), ], count=True, context=context) if badges > 0: # has already recieved the badge for this challenge continue - self.reward_user(cr, uid, user.id, challenge.reward_id.id, challenge.id, context=context) - rewarded_users.append(user) + self.reward_user(cr, uid, user_id, challenge.reward_id.id, challenge.id, context=context) + rewarded_users.append(user_id) if challenge_ended: # open chatter message message_body = _("The challenge %s is finished." % challenge.name) if rewarded_users: - message_body += _("
Reward (badge %s) for every succeeding user was sent to %s." % (challenge.reward_id.name, ", ".join([user.name for user in rewarded_users]))) + user_names = self.pool['res.users'].name_get(cr, uid, rewarded_users, context=context) + message_body += _("
Reward (badge %s) for every succeeding user was sent to %s." % (challenge.reward_id.name, ", ".join([name for (user_id, name) in user_names]))) else: message_body += _("
Nobody has succeeded to reach every goal, no badge is rewared for this challenge.") @@ -746,7 +754,10 @@ class gamification_challenge(osv.Model): self.reward_user(cr, uid, third_user.id, challenge.reward_second_id.id, challenge.id, context=context) message_body += "
3. %s - %s" % (third_user.name, challenge.reward_third_id.name) - self.message_post(cr, uid, challenge.id, body=message_body, context=context) + self.message_post(cr, uid, challenge.id, + partner_ids=[user.partner_id.id for user in challenge.user_ids], + body=message_body, + context=context) return True diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py index af9a763236d..b4a47a0d07a 100644 --- a/addons/gamification/models/goal.py +++ b/addons/gamification/models/goal.py @@ -138,7 +138,6 @@ class gamification_goal(osv.Model): _name = 'gamification.goal' _description = 'Gamification goal instance' - _inherit = 'mail.thread' def _get_completion(self, cr, uid, ids, field_name, arg, context=None): """Return the percentage of completeness of the goal, between 0 and 100""" @@ -226,8 +225,7 @@ class gamification_goal(osv.Model): temp_obj = self.pool.get('email.template') template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_goal_reminder', context) body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.goal', goal.id, context=context) - - self.message_post(cr, uid, goal.id, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment') + self.pool['mail.thread'].message_post(cr, uid, 0, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment') return {'to_update': True} return {} @@ -241,9 +239,9 @@ class gamification_goal(osv.Model): the target value being reached, the goal is set as failed.""" if context is None: context = {} + commit = context.get('commit_gamification', False) goals_by_definition = {} - goals_to_write = {} all_goals = {} for goal in self.browse(cr, uid, ids, context=context): if goal.state in ('draft', 'canceled'): @@ -251,10 +249,10 @@ class gamification_goal(osv.Model): continue goals_by_definition.setdefault(goal.definition_id, []).append(goal) - goals_to_write[goal.id] = {} all_goals[goal.id] = goal for definition, goals in goals_by_definition.items(): + goals_to_write = dict((goal.id, {}) for goal in goals) if definition.computation_mode == 'manually': for goal in goals: goals_to_write[goal.id].update(self._check_remind_delay(cr, uid, goal, context)) @@ -345,22 +343,24 @@ class gamification_goal(osv.Model): if new_value != goal.current: goals_to_write[goal.id]['current'] = new_value - for goal_id, value in goals_to_write.items(): - if not value: - continue - goal = all_goals[goal_id] + for goal_id, value in goals_to_write.items(): + if not value: + continue + goal = all_goals[goal_id] - # check goal target reached - if (goal.definition_condition == 'higher' and value.get('current', goal.current) >= goal.target_goal) \ - or (goal.definition_condition == 'lower' and value.get('current', goal.current) <= goal.target_goal): - value['state'] = 'reached' + # check goal target reached + if (goal.definition_condition == 'higher' and value.get('current', goal.current) >= goal.target_goal) \ + or (goal.definition_condition == 'lower' and value.get('current', goal.current) <= goal.target_goal): + value['state'] = 'reached' - # check goal failure - elif goal.end_date and fields.date.today() > goal.end_date: - value['state'] = 'failed' - value['closed'] = True - if value: - self.write(cr, uid, [goal.id], value, context=context) + # check goal failure + elif goal.end_date and fields.date.today() > goal.end_date: + value['state'] = 'failed' + value['closed'] = True + if value: + self.write(cr, uid, [goal.id], value, context=context) + if commit: + cr.commit() return True def action_start(self, cr, uid, ids, context=None): diff --git a/addons/gamification/views/goal.xml b/addons/gamification/views/goal.xml index 528d5db0511..884467404ce 100644 --- a/addons/gamification/views/goal.xml +++ b/addons/gamification/views/goal.xml @@ -86,10 +86,6 @@
-
- - -
diff --git a/addons/hr/hr.py b/addons/hr/hr.py index a13a1866493..5bb172eb082 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -248,7 +248,13 @@ class hr_employee(osv.osv): 'image': _get_default_image, 'color': 0, } - + + def copy_data(self, cr, uid, ids, default=None, context=None): + if default is None: + default = {} + default.update({'child_ids': False}) + return super(hr_employee, self).copy_data(cr, uid, ids, default, context=context) + def _broadcast_welcome(self, cr, uid, employee_id, context=None): """ Broadcast the welcome message to all users in the employee company. """ employee = self.browse(cr, uid, employee_id, context=context) @@ -421,18 +427,23 @@ class hr_department(osv.osv): res.append((record['id'], name)) return res - def copy(self, cr, uid, ids, default=None, context=None): + def copy_data(self, cr, uid, ids, default=None, context=None): if default is None: default = {} - default = default.copy() default['member_ids'] = [] - return super(hr_department, self).copy(cr, uid, ids, default, context=context) + return super(hr_department, self).copy_data(cr, uid, ids, default, context=context) class res_users(osv.osv): _name = 'res.users' _inherit = 'res.users' + def copy_data(self, cr, uid, ids, default=None, context=None): + if default is None: + default = {} + default.update({'employee_ids': False}) + return super(res_users, self).copy_data(cr, uid, ids, default, context=context) + _columns = { 'employee_ids': fields.one2many('hr.employee', 'user_id', 'Related employees'), } diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index fe677561b2c..d1ad3aa64d1 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -22,9 +22,11 @@ import time from datetime import datetime from dateutil.relativedelta import relativedelta +from pytz import timezone +import pytz from openerp.osv import fields, osv -from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools.translate import _ class hr_timesheet_sheet(osv.osv): @@ -410,22 +412,56 @@ class hr_attendance(osv.osv): attendance_ids.extend([row[0] for row in cr.fetchall()]) return attendance_ids - def _get_current_sheet(self, cr, uid, employee_id, date=False, context=None): + def _get_attendance_employee_tz(self, cr, uid, employee_id, date, context=None): + """ Simulate timesheet in employee timezone + + Return the attendance date in string format in the employee + tz converted from utc timezone as we consider date of employee + timesheet is in employee timezone + """ + employee_obj = self.pool['hr.employee'] + + tz = False + if employee_id: + employee = employee_obj.browse(cr, uid, employee_id, context=context) + tz = employee.user_id.partner_id.tz + if not date: date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) - # ending date with no time to avoid timesheet with early date_to - date_to = date[0:10]+' 00:00:00' - # limit=1 because only one sheet possible for an employee between 2 dates - sheet_ids = self.pool.get('hr_timesheet_sheet.sheet').search(cr, uid, [ - ('date_to', '>=', date_to), ('date_from', '<=', date), - ('employee_id', '=', employee_id) - ], limit=1, context=context) + + att_tz = timezone(tz or 'utc') + + attendance_dt = datetime.strptime(date, DEFAULT_SERVER_DATETIME_FORMAT) + att_tz_dt = pytz.utc.localize(attendance_dt) + att_tz_dt = att_tz_dt.astimezone(att_tz) + # We take only the date omiting the hours as we compare with timesheet + # date_from which is a date format thus using hours would lead to + # be out of scope of timesheet + att_tz_date_str = datetime.strftime(att_tz_dt, DEFAULT_SERVER_DATE_FORMAT) + return att_tz_date_str + + def _get_current_sheet(self, cr, uid, employee_id, date=False, context=None): + + sheet_obj = self.pool['hr_timesheet_sheet.sheet'] + if not date: + date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) + + att_tz_date_str = self._get_attendance_employee_tz( + cr, uid, employee_id, + date=date, context=context) + sheet_ids = sheet_obj.search(cr, uid, + [('date_from', '<=', att_tz_date_str), + ('date_to', '>=', att_tz_date_str), + ('employee_id', '=', employee_id)], + limit=1, context=context) return sheet_ids and sheet_ids[0] or False def _sheet(self, cursor, user, ids, name, args, context=None): res = {}.fromkeys(ids, False) for attendance in self.browse(cursor, user, ids, context=context): - res[attendance.id] = self._get_current_sheet(cursor, user, attendance.employee_id.id, attendance.name, context=context) + res[attendance.id] = self._get_current_sheet( + cursor, user, attendance.employee_id.id, attendance.name, + context=context) return res _columns = { @@ -447,10 +483,13 @@ class hr_attendance(osv.osv): sheet_id = context.get('sheet_id') or self._get_current_sheet(cr, uid, vals.get('employee_id'), vals.get('name'), context=context) if sheet_id: + att_tz_date_str = self._get_attendance_employee_tz( + cr, uid, vals.get('employee_id'), + date=vals.get('name'), context=context) ts = self.pool.get('hr_timesheet_sheet.sheet').browse(cr, uid, sheet_id, context=context) if ts.state not in ('draft', 'new'): raise osv.except_osv(_('Error!'), _('You can not enter an attendance in a submitted timesheet. Ask your manager to reset it before adding attendance.')) - elif ts.date_from > vals.get('name') or ts.date_to < vals.get('name'): + elif ts.date_from > att_tz_date_str or ts.date_to < att_tz_date_str: raise osv.except_osv(_('User Error!'), _('You can not enter an attendance date outside the current timesheet dates.')) return super(hr_attendance,self).create(cr, uid, vals, context=context) @@ -619,4 +658,3 @@ class hr_employee(osv.osv): 'timesheet_count': fields.function(_timesheet_count, type='integer', string='Timesheets'), } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index a913d3c067d..4a069cb5428 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -6,6 +6,7 @@ from openerp import SUPERUSER_ID from openerp import http from openerp.http import request from openerp.addons.web.controllers.main import content_disposition +import mimetypes class MailController(http.Controller): @@ -19,10 +20,11 @@ class MailController(http.Controller): if res: filecontent = base64.b64decode(res.get('base64')) filename = res.get('filename') + content_type = mimetypes.guess_type(filename) if filecontent and filename: return request.make_response( filecontent, - headers=[('Content-Type', 'application/octet-stream'), + headers=[('Content-Type', content_type[0] or 'application/octet-stream'), ('Content-Disposition', content_disposition(filename))]) return request.not_found() diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 7147288f594..92e041bdc4c 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -238,6 +238,7 @@ class mail_mail(osv.Model): if context is None: context = {} ir_mail_server = self.pool.get('ir.mail_server') + ir_attachment = self.pool['ir.attachment'] for mail in self.browse(cr, SUPERUSER_ID, ids, context=context): try: # TDE note: remove me when model_id field is present on mail.message - done here to avoid doing it multiple times in the sub method @@ -248,10 +249,15 @@ class mail_mail(osv.Model): model = None if model: context['model_name'] = model.name - # handle attachments - attachments = [] - for attach in mail.attachment_ids: - attachments.append((attach.datas_fname, base64.b64decode(attach.datas))) + + # load attachment binary data with a separate read(), as prefetching all + # `datas` (binary field) could bloat the browse cache, triggerring + # soft/hard mem limits with temporary data. + attachment_ids = [a.id for a in mail.attachment_ids] + attachments = [(a['datas_fname'], base64.b64decode(a['datas'])) + for a in ir_attachment.read(cr, SUPERUSER_ID, attachment_ids, + ['datas_fname', 'datas'])] + # specific behavior to customize the send email for notified partners email_list = [] if mail.email_to: @@ -300,6 +306,14 @@ class mail_mail(osv.Model): # /!\ can't use mail.state here, as mail.refresh() will cause an error # see revid:odo@openerp.com-20120622152536-42b2s28lvdv3odyr in 6.1 self._postprocess_sent_message(cr, uid, mail, context=context, mail_sent=mail_sent) + _logger.info('Mail with ID %r and Message-Id %r successfully sent', mail.id, mail.message_id) + except MemoryError: + # prevent catching transient MemoryErrors, bubble up to notify user or abort cron job + # instead of marking the mail as failed + _logger.exception('MemoryError while processing mail with ID %r and Msg-Id %r. '\ + 'Consider raising the --limit-memory-hard startup option', + mail.id, mail.message_id) + raise except Exception as e: _logger.exception('failed sending mail.mail %s', mail.id) mail.write({'state': 'exception'}) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 79bf92cb68d..b6166c69aef 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -433,14 +433,14 @@ class mail_thread(osv.AbstractModel): fol_obj.unlink(cr, SUPERUSER_ID, fol_ids, context=context) return res - def copy(self, cr, uid, id, default=None, context=None): + def copy_data(self, cr, uid, id, default=None, context=None): # avoid tracking multiple temporary changes during copy context = dict(context or {}, mail_notrack=True) default = default or {} default['message_ids'] = [] default['message_follower_ids'] = [] - return super(mail_thread, self).copy(cr, uid, id, default=default, context=context) + return super(mail_thread, self).copy_data(cr, uid, id, default=default, context=context) #------------------------------------------------------ # Automatically log tracked fields diff --git a/addons/mail/res_config.py b/addons/mail/res_config.py index c19eb4a38ee..2c94b432dc3 100644 --- a/addons/mail/res_config.py +++ b/addons/mail/res_config.py @@ -34,14 +34,14 @@ class project_configuration(osv.TransientModel): } def get_default_alias_domain(self, cr, uid, ids, context=None): - alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) - if not alias_domain: + alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", default=None, context=context) + if alias_domain is None: domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.base.url", context=context) try: alias_domain = urlparse.urlsplit(domain).netloc.split(':')[0] except Exception: pass - return {'alias_domain': alias_domain} + return {'alias_domain': alias_domain or False} def set_alias_domain(self, cr, uid, ids, context=None): config_parameters = self.pool.get("ir.config_parameter") diff --git a/addons/multi_company/multi_company_demo.xml b/addons/multi_company/multi_company_demo.xml index 44a021c1434..d7d1af24f07 100644 --- a/addons/multi_company/multi_company_demo.xml +++ b/addons/multi_company/multi_company_demo.xml @@ -59,7 +59,7 @@ - + OpenERP US @@ -400,7 +400,7 @@ - + diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 931188f2ef6..7fe2be499a3 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -1162,8 +1162,8 @@ class pos_order(osv.osv): return self.write(cr, uid, ids, {'state': 'payment'}, context=context) def action_paid(self, cr, uid, ids, context=None): - self.create_picking(cr, uid, ids, context=context) self.write(cr, uid, ids, {'state': 'paid'}, context=context) + self.create_picking(cr, uid, ids, context=context) return True def action_cancel(self, cr, uid, ids, context=None): diff --git a/addons/report/models/report.py b/addons/report/models/report.py index 212555dbc8a..8b09fa35419 100644 --- a/addons/report/models/report.py +++ b/addons/report/models/report.py @@ -260,8 +260,14 @@ class Report(osv.Model): def get_action(self, cr, uid, ids, report_name, data=None, context=None): """Return an action of type ir.actions.report.xml. + :param ids: Ids of the records to print (if not used, pass an empty list) :param report_name: Name of the template to generate an action for """ + if ids: + if not isinstance(ids, list): + ids = [ids] + context['active_ids'] = ids + report_obj = self.pool['ir.actions.report.xml'] idreport = report_obj.search(cr, uid, [('report_name', '=', report_name)], context=context) try: @@ -272,7 +278,7 @@ class Report(osv.Model): _('This report is not loaded into the database: %s.' % report_name) ) - action = { + return { 'context': context, 'data': data, 'type': 'ir.actions.report.xml', @@ -280,7 +286,6 @@ class Report(osv.Model): 'report_type': report.report_type, 'report_file': report.report_file, } - return action #-------------------------------------------------------------------------- # Report generation helpers diff --git a/addons/stock/product.py b/addons/stock/product.py index ae31909cfc1..9ac1a644f30 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -105,7 +105,9 @@ class product_product(osv.osv): 'compute_child': False }) - qty = product.qty_available + # qty_available depends of the location in the context + qty = self.read(cr, uid, [product.id], ['qty_available'], context=c)[0]['qty_available'] + diff = product.standard_price - new_price if not diff: raise osv.except_osv(_('Error!'), _("No difference between standard price and new price!")) if qty: diff --git a/addons/stock/stock.py b/addons/stock/stock.py index dd6c9ca3681..5f7aeb0ef1e 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2312,7 +2312,9 @@ class stock_move(osv.osv): # if product is set to average price and a specific value was entered in the picking wizard, # we use it - if move.product_id.cost_method == 'average' and move.price_unit: + if move.location_dest_id.usage != 'internal' and move.product_id.cost_method == 'average': + reference_amount = qty * move.product_id.standard_price + elif move.product_id.cost_method == 'average' and move.price_unit: reference_amount = qty * move.price_unit reference_currency_id = move.price_currency_id.id or reference_currency_id diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 8ae9da33c30..ac6636147c1 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -811,7 +811,7 @@ - + @@ -945,7 +945,7 @@ - +
@@ -1072,7 +1072,7 @@ - +
@@ -1359,7 +1359,7 @@ - + diff --git a/addons/warning/warning.py b/addons/warning/warning.py index d582478113a..539316482d2 100644 --- a/addons/warning/warning.py +++ b/addons/warning/warning.py @@ -62,14 +62,14 @@ class sale_order(osv.osv): message = False partner = self.pool.get('res.partner').browse(cr, uid, part, context=context) if partner.sale_warn != 'no-message': - if partner.sale_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.sale_warn_msg) title = _("Warning for %s") % partner.name message = partner.sale_warn_msg warning = { 'title': title, 'message': message, } + if partner.sale_warn == 'block': + return {'value': {'partner_id': False}, 'warning': warning} result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part, context=context) @@ -90,14 +90,15 @@ class purchase_order(osv.osv): message = False partner = self.pool.get('res.partner').browse(cr, uid, part) if partner.purchase_warn != 'no-message': - if partner.purchase_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.purchase_warn_msg) title = _("Warning for %s") % partner.name message = partner.purchase_warn_msg warning = { 'title': title, 'message': message } + if partner.purchase_warn == 'block': + return {'value': {'partner_id': False}, 'warning': warning} + result = super(purchase_order, self).onchange_partner_id(cr, uid, ids, part) if result.get('warning',False): @@ -123,15 +124,16 @@ class account_invoice(osv.osv): message = False partner = self.pool.get('res.partner').browse(cr, uid, partner_id) if partner.invoice_warn != 'no-message': - if partner.invoice_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.invoice_warn_msg) - title = _("Warning for %s") % partner.name message = partner.invoice_warn_msg warning = { 'title': title, 'message': message } + + if partner.invoice_warn == 'block': + return {'value': {'partner_id': False}, 'warning': warning} + result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, date_invoice=date_invoice, payment_term=payment_term, partner_bank_id=partner_bank_id, company_id=company_id) @@ -154,14 +156,15 @@ class stock_picking(osv.osv): title = False message = False if partner.picking_warn != 'no-message': - if partner.picking_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg) title = _("Warning for %s") % partner.name message = partner.picking_warn_msg warning = { 'title': title, 'message': message } + if partner.picking_warn == 'block': + return {'value': {'partner_id': False}, 'warning': warning} + result = super(stock_picking, self).onchange_partner_in(cr, uid, ids, partner_id, context) if result.get('warning',False): warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title'] @@ -183,14 +186,15 @@ class stock_picking_in(osv.osv): title = False message = False if partner.picking_warn != 'no-message': - if partner.picking_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg) title = _("Warning for %s") % partner.name message = partner.picking_warn_msg warning = { 'title': title, 'message': message } + if partner.picking_warn == 'block': + return {'value': {'partner_id': False}, 'warning': warning} + result = super(stock_picking_in, self).onchange_partner_in(cr, uid, ids, partner_id, context) if result.get('warning',False): warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title'] @@ -209,14 +213,15 @@ class stock_picking_out(osv.osv): title = False message = False if partner.picking_warn != 'no-message': - if partner.picking_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg) title = _("Warning for %s") % partner.name message = partner.picking_warn_msg warning = { 'title': title, 'message': message } + if partner.picking_warn == 'block': + return {'value': {'partner_id': False}, 'warning': warning} + result = super(stock_picking_out, self).onchange_partner_in(cr, uid, ids, partner_id, context) if result.get('warning',False): warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title'] @@ -256,12 +261,12 @@ class sale_order_line(osv.osv): message = False if product_info.sale_line_warn != 'no-message': - if product_info.sale_line_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (product_info.name), product_info.sale_line_warn_msg) title = _("Warning for %s") % product_info.name message = product_info.sale_line_warn_msg warning['title'] = title warning['message'] = message + if product_info.sale_line_warn == 'block': + return {'value': {'product_id': False}, 'warning': warning} result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty, uom, qty_uos, uos, name, partner_id, @@ -288,12 +293,12 @@ class purchase_order_line(osv.osv): message = False if product_info.purchase_line_warn != 'no-message': - if product_info.purchase_line_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (product_info.name), product_info.purchase_line_warn_msg) title = _("Warning for %s") % product_info.name message = product_info.purchase_line_warn_msg warning['title'] = title warning['message'] = message + if product_info.purchase_line_warn == 'block': + return {'value': {'product_id': False}, 'warning': warning} result = super(purchase_order_line, self).onchange_product_id(cr, uid, ids, pricelist, product, qty, uom, partner_id, date_order, fiscal_position_id) diff --git a/addons/website/security/ir.model.access.csv b/addons/website/security/ir.model.access.csv index 1a9ccccba5c..8682a349f70 100644 --- a/addons/website/security/ir.model.access.csv +++ b/addons/website/security/ir.model.access.csv @@ -2,6 +2,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_website_public,website,website.model_website,,1,0,0,0 access_website,website,website.model_website,base.group_website_designer,1,1,1,1 access_website_menu,access_website_menu,model_website_menu,,1,0,0,0 +access_website_menu_designer,Web Menu Manager,model_website_menu,base.group_website_designer,1,1,1,1 access_website,web menu manager,website.model_website,base.group_website_designer,1,1,1,1 access_website_converter_test,access_website_converter_test,model_website_converter_test,,1,1,1,1 access_website_converter_test_sub,access_website_converter_test_sub,model_website_converter_test_sub,,1,1,1,1 diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index be69c66b615..595df04a088 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -1056,6 +1056,7 @@ this.trigger("saved"); }, cancel: function () { + this.trigger("cancel"); }, close: function () { this.$el.modal('hide'); diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 8f49409924d..806b2ab4e0c 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -879,20 +879,29 @@ this._super(np); if (np.$next) { if (np.$next.hasClass("oe_custom_bg")) { - var editor = new website.editor.ImageDialog(); - editor.on('start', self, function (o) {o.url = np.$prev && np.$prev.data("src") || np.$next && np.$next.data("src") || "";}); - editor.on('save', self, function (o) { - self._set_bg(o.url); - np.$next.data("src", o.url); + var $image = $(''); + $image.attr("src", np.$prev ? np.$prev.data("src") : ''); + $image.appendTo(self.$target); + + self.element = new CKEDITOR.dom.element($image[0]); + var editor = new website.editor.MediaDialog(self, self.element); + editor.appendTo(document.body); + editor.$('[href="#editor-media-video"], [href="#editor-media-icon"]').addClass('hidden'); + + $image.on('saved', self, function (o) { + var src = $image.attr("src"); + self._set_bg(src); + np.$next.data("src", src); self.$target.trigger("snippet-style-change", [self, np]); + $image.remove(); }); editor.on('cancel', self, function () { if (!np.$prev || np.$prev.data("src") === "") { self.$target.removeClass(np.$next.data("value")); self.$target.trigger("snippet-style-change", [self, np]); } + $image.remove(); }); - editor.appendTo($('body')); } else { this._set_bg(np.$next.data("src")); } diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 6f5ba3e213c..f02a6f97cde 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -124,6 +124,7 @@ class WebsiteForum(http.Controller): values.update({ 'main_object': tag or forum, 'question_ids': question_ids, + 'question_count': question_count, 'pager': pager, 'tag': tag, 'filters': filters, @@ -134,7 +135,7 @@ class WebsiteForum(http.Controller): @http.route(['/forum//faq'], type='http', auth="public", website=True, multilang=True) def forum_faq(self, forum, **post): - values = self._prepare_forum_values(forum=forum, searches=dict(), **post) + values = self._prepare_forum_values(forum=forum, searches=dict(), header={'is_guidelines': True}, **post) return request.website.render("website_forum.faq", values) @http.route('/forum/get_tags', type='http', auth="public", multilang=True, methods=['GET'], website=True) @@ -147,7 +148,7 @@ class WebsiteForum(http.Controller): def tags(self, forum, page=1, **post): cr, uid, context = request.cr, request.uid, request.context Tag = request.registry['forum.tag'] - obj_ids = Tag.search(cr, uid, [('forum_id', '=', forum.id)], limit=None, context=context) + obj_ids = Tag.search(cr, uid, [('forum_id', '=', forum.id), ('posts_count', '>', 0)], limit=None, order='posts_count DESC', context=context) tags = Tag.browse(cr, uid, obj_ids, context=context) values = self._prepare_forum_values(forum=forum, searches={'tags': True}, **post) values.update({ @@ -427,7 +428,7 @@ class WebsiteForum(http.Controller): tag_count = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], count=True, context=context) pager = request.website.pager(url="/forum/users", total=tag_count, page=page, step=step, scope=30) - obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], context=context) + obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], order='karma DESC', context=context) users = User.browse(cr, SUPERUSER_ID, obj_ids, context=context) searches['users'] = 'True' @@ -591,12 +592,13 @@ class WebsiteForum(http.Controller): @http.route('/forum//post//comment//convert_to_answer', type='http', auth="public", multilang=True, website=True) def convert_comment_to_answer(self, forum, post, comment, **kwarg): - values = { - 'content': comment.body, - } + body = comment.body request.registry['mail.message'].unlink(request.cr, request.uid, [comment.id], context=request.context) question = post.parent_id if post.parent_id else post - return self.post_new(forum, question, **values) + for answer in question.child_ids: + if answer.create_uid.id == request.uid: + return self.post_comment(forum, answer, comment=html2plaintext(body)) + return self.post_new(forum, question, content=body) @http.route('/forum//post//convert_to_comment', type='http', auth="user", multilang=True, website=True) def convert_answer_to_comment(self, forum, post, **kwarg): diff --git a/addons/website_forum/data/forum_data.xml b/addons/website_forum/data/forum_data.xml index 245169c23e9..a387a8de7ae 100644 --- a/addons/website_forum/data/forum_data.xml +++ b/addons/website_forum/data/forum_data.xml @@ -13,10 +13,7 @@ 35 - - auth_signup.allow_uninvited - - + diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 7a8385d1a82..061b9e55eb8 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -70,6 +70,7 @@ class Post(osv.Model): _name = 'forum.post' _description = 'Forum Post' _inherit = ['mail.thread', 'website.seo.metadata'] + _order = "is_correct DESC, vote_count DESC" def _get_user_vote(self, cr, uid, ids, field_name, arg, context): res = dict.fromkeys(ids, 0) diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css index ab8ea684aae..b90c1786e24 100644 --- a/addons/website_forum/static/src/css/website_forum.css +++ b/addons/website_forum/static/src/css/website_forum.css @@ -21,6 +21,9 @@ background-color: #cccccc; margin-left: 4px; } +.question .badge-active { + background-color: #428bca; +} .oe_grey { background-color: #eeeeee; diff --git a/addons/website_forum/static/src/css/website_forum.sass b/addons/website_forum/static/src/css/website_forum.sass index da2df1460aa..f8e46f06b79 100644 --- a/addons/website_forum/static/src/css/website_forum.sass +++ b/addons/website_forum/static/src/css/website_forum.sass @@ -17,6 +17,8 @@ .badge background-color: #ccc margin-left: 4px + .badge-active + background-color: #428bca .oe_grey background-color: #eeeeee diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index df0b202f4f7..6e9af81d2d1 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -94,7 +94,8 @@
@@ -146,8 +147,11 @@ [Deleted] [Closed]
- - + + + +