diff --git a/addons/account/account.py b/addons/account/account.py index 75041705547..2b7c1a8e21d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -926,9 +926,8 @@ class account_period(osv.osv): def action_draft(self, cr, uid, ids, *args): mode = 'draft' - for id in ids: - cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) - cr.execute('update account_period set state=%s where id=%s', (mode, id)) + cr.execute('update account_journal_period set state=%s where period_id in %s', (mode, tuple(ids),)) + cr.execute('update account_period set state=%s where id in %s', (mode, tuple(ids),)) return True def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): @@ -2659,8 +2658,6 @@ class wizard_multi_charts_accounts(osv.osv_memory): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(wizard_multi_charts_accounts, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) - configured_cmp = [] - unconfigured_cmp = [] cmp_select = [] company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) #display in the widget selection of companies, only the companies that haven't been configured yet (but don't care about the demo chart of accounts) @@ -2668,12 +2665,12 @@ class wizard_multi_charts_accounts(osv.osv_memory): configured_cmp = [r[0] for r in cr.fetchall()] unconfigured_cmp = list(set(company_ids)-set(configured_cmp)) for field in res['fields']: - if field == 'company_id': - res['fields'][field]['domain'] = unconfigured_cmp - res['fields'][field]['selection'] = [('', '')] - if unconfigured_cmp: - cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)] - res['fields'][field]['selection'] = cmp_select + if field == 'company_id': + res['fields'][field]['domain'] = unconfigured_cmp + res['fields'][field]['selection'] = [('', '')] + if unconfigured_cmp: + cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)] + res['fields'][field]['selection'] = cmp_select return res def execute(self, cr, uid, ids, context=None): @@ -2681,7 +2678,6 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') - obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') @@ -2689,9 +2685,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') obj_tax_code_template = self.pool.get('account.tax.code.template') - obj_acc_journal_view = self.pool.get('account.journal.view') ir_values = self.pool.get('ir.values') - obj_product = self.pool.get('product.product') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id @@ -2946,8 +2940,6 @@ class wizard_multi_charts_accounts(osv.osv_memory): acc_cash_id = obj_acc.create(cr,uid,vals) #create the bank journal - analytical_bank_ids = analytic_journal_obj.search(cr,uid,[('type','=','situation')]) - analytical_journal_bank = analytical_bank_ids and analytical_bank_ids[0] or False vals_journal = { 'name': vals['name'], 'code': _('BNK') + str(current_num), diff --git a/addons/account/installer.py b/addons/account/installer.py index b8b0ab1f6e3..b9de39043ee 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -90,8 +90,6 @@ class account_installer(osv.osv_memory): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(account_installer, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) - configured_cmp = [] - unconfigured_cmp = [] cmp_select = [] company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) #display in the widget selection of companies, only the companies that haven't been configured yet (but don't care about the demo chart of accounts) @@ -99,12 +97,12 @@ class account_installer(osv.osv_memory): configured_cmp = [r[0] for r in cr.fetchall()] unconfigured_cmp = list(set(company_ids)-set(configured_cmp)) for field in res['fields']: - if field == 'company_id': - res['fields'][field]['domain'] = unconfigured_cmp - res['fields'][field]['selection'] = [('', '')] - if unconfigured_cmp: - cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)] - res['fields'][field]['selection'] = cmp_select + if field == 'company_id': + res['fields'][field]['domain'] = unconfigured_cmp + res['fields'][field]['selection'] = [('', '')] + if unconfigured_cmp: + cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)] + res['fields'][field]['selection'] = cmp_select return res def on_change_tax(self, cr, uid, id, tax): @@ -126,11 +124,8 @@ class account_installer(osv.osv_memory): obj_acc_temp = self.pool.get('account.account.template') obj_tax_code_temp = self.pool.get('account.tax.code.template') obj_tax_temp = self.pool.get('account.tax.template') - obj_product = self.pool.get('product.product') - ir_values = self.pool.get('ir.values') obj_acc_chart_temp = self.pool.get('account.chart.template') record = self.browse(cr, uid, ids, context=context)[0] - company_id = record.company_id for res in self.read(cr, uid, ids, context=context): if record.charts == 'configurable': fp = tools.file_open(opj('account', 'configurable_account_chart.xml')) diff --git a/addons/account/project/wizard/account_analytic_balance_report.py b/addons/account/project/wizard/account_analytic_balance_report.py index 25861c055b4..81d325ee8f5 100644 --- a/addons/account/project/wizard/account_analytic_balance_report.py +++ b/addons/account/project/wizard/account_analytic_balance_report.py @@ -38,7 +38,6 @@ class account_analytic_balance(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids)[0] 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 436e46e949e..93208532e45 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 @@ -38,7 +38,6 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids)[0] 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 bbfc5d6e917..246f02c20dc 100644 --- a/addons/account/project/wizard/account_analytic_cost_ledger_report.py +++ b/addons/account/project/wizard/account_analytic_cost_ledger_report.py @@ -37,7 +37,6 @@ class account_analytic_cost_ledger(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids)[0] 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 32f935a024b..2c9690fee50 100644 --- a/addons/account/project/wizard/account_analytic_inverted_balance_report.py +++ b/addons/account/project/wizard/account_analytic_inverted_balance_report.py @@ -37,7 +37,6 @@ class account_analytic_inverted_balance(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids)[0] diff --git a/addons/account/project/wizard/account_analytic_journal_report.py b/addons/account/project/wizard/account_analytic_journal_report.py index 59dd0361805..9a2eee020b1 100644 --- a/addons/account/project/wizard/account_analytic_journal_report.py +++ b/addons/account/project/wizard/account_analytic_journal_report.py @@ -37,7 +37,6 @@ class account_analytic_journal_report(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids)[0] diff --git a/addons/account/project/wizard/project_account_analytic_line.py b/addons/account/project/wizard/project_account_analytic_line.py index e6be3bcffd3..0732ebfe491 100644 --- a/addons/account/project/wizard/project_account_analytic_line.py +++ b/addons/account/project/wizard/project_account_analytic_line.py @@ -22,36 +22,36 @@ from osv import fields, osv from tools.translate import _ class project_account_analytic_line(osv.osv_memory): - _name = "project.account.analytic.line" - _description = "Analytic Entries by line" - _columns = { + _name = "project.account.analytic.line" + _description = "Analytic Entries by line" + _columns = { 'from_date': fields.date('From'), 'to_date': fields.date('To'), } - def action_open_window(self, cr, uid, ids, context=None): - mod_obj =self.pool.get('ir.model.data') - domain = [] - data = self.read(cr, uid, ids, [])[0] - from_date = data['from_date'] - to_date = data['to_date'] - if from_date and to_date: - domain = [('date','>=',from_date), ('date','<=',to_date)] - elif from_date: - domain = [('date','>=',from_date)] - elif to_date: - domain = [('date','<=',to_date)] - result = mod_obj.get_object_reference(cr, uid, 'account', 'view_account_analytic_line_filter') - id = result and result[1] or False - return { - 'name': _('Analytic Entries by line'), - 'view_type': 'form', - "view_mode": 'tree,form', - 'res_model': 'account.analytic.line', - 'type': 'ir.actions.act_window', - 'domain': domain, - 'search_view_id': id['res_id'], - } + def action_open_window(self, cr, uid, ids, context=None): + mod_obj =self.pool.get('ir.model.data') + domain = [] + data = self.read(cr, uid, ids, [])[0] + from_date = data['from_date'] + to_date = data['to_date'] + if from_date and to_date: + domain = [('date','>=',from_date), ('date','<=',to_date)] + elif from_date: + domain = [('date','>=',from_date)] + elif to_date: + domain = [('date','<=',to_date)] + result = mod_obj.get_object_reference(cr, uid, 'account', 'view_account_analytic_line_filter') + id = result and result[1] or False + return { + 'name': _('Analytic Entries by line'), + 'view_type': 'form', + "view_mode": 'tree,form', + 'res_model': 'account.analytic.line', + 'type': 'ir.actions.act_window', + 'domain': domain, + 'search_view_id': id['res_id'], + } project_account_analytic_line() diff --git a/addons/account/report/account_balance_landscape.py b/addons/account/report/account_balance_landscape.py index a11d3bc285d..4e62a9777c9 100644 --- a/addons/account/report/account_balance_landscape.py +++ b/addons/account/report/account_balance_landscape.py @@ -98,7 +98,6 @@ class account_balance_landscape(report_sxw.rml_parse): ref_bal='nothing' - total_for_perc=[] self.done_total=1 self.total_for_perc=self.linesForTotal(form, ids={}, doneAccount={}, level=1) self.done_total=0 @@ -116,9 +115,7 @@ class account_balance_landscape(report_sxw.rml_parse): def linesForTotal(self, form, ids={}, doneAccount={}, level=1): - if self.done_total==1: - self.done_total==1 - else: + if not self.done_total==1: return [self.result_total] accounts=[] if not ids: @@ -127,7 +124,6 @@ class account_balance_landscape(report_sxw.rml_parse): return [] ctx = self.context.copy() - result_total_parent=[] for id in form['fiscalyear']: tmp=[] @@ -142,7 +138,7 @@ class account_balance_landscape(report_sxw.rml_parse): accounts.append(tmp) merged_accounts=zip(*accounts) - # used to check for the frst record so all sum_credit and sum_debit r set to 0.00 + # used to check for the frst record so all sum_credit and sum_debit r set to 0.00 if level==1: doneAccount={} for entry in merged_accounts: @@ -345,7 +341,6 @@ class account_balance_landscape(report_sxw.rml_parse): def get_lines(self, year_dict, form): final_result = [] - line_l =[] res = {} line_l = self.lines(form) self.cal_total(year_dict) @@ -357,21 +352,21 @@ class account_balance_landscape(report_sxw.rml_parse): res['level'] = l['level'] for k,v in l.items(): if k.startswith('debit'+str(year_dict['last_str'])): - res['debit'] = v + res['debit'] = v if k.startswith('credit'+str(year_dict['last_str'])): - res['credit'] = v + res['credit'] = v if k.startswith('balance'+str(year_dict['last_str'])) and not k.startswith('balance_perc'+str(year_dict['last_str'])): - res['balance'] =v + res['balance'] =v if k.startswith('balance_perc'+str(year_dict['last_str'])) and not k.startswith('balance'+str(year_dict['last_str'])): - res['balance_perc'] = v + res['balance_perc'] = v if form['compare_pattern'] == 'bal_perc': if k.startswith('bal_perc'+str(year_dict['last_str'])): - res['pattern'] = v + res['pattern'] = v elif form['compare_pattern'] == 'bal_cash': if k.startswith('bal_cash'+str(year_dict['last_str'])): - res['pattern'] = v + res['pattern'] = v else: - res['pattern'] = '' + res['pattern'] = '' final_result.append(res) return final_result diff --git a/addons/account/report/account_partner_balance.py b/addons/account/report/account_partner_balance.py index 187b9b2578f..fcc112d9d81 100644 --- a/addons/account/report/account_partner_balance.py +++ b/addons/account/report/account_partner_balance.py @@ -242,7 +242,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header): if not self.ids: return 0.0 - temp_res = 0.0 self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ @@ -261,7 +260,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header): if not self.ids: return 0.0 - temp_res = 0.0 self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ @@ -281,7 +279,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header): if not self.ids: return 0.0 - temp_res = 0.0 self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ @@ -295,7 +292,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header): return temp_res def _get_partners(self): - cr, uid = self.cr, self.uid if self.result_selection == 'customer': return _('Receivable Accounts') diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index 92d84e05c26..52d44d40723 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -118,7 +118,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): else: amount = str(amount) if (amount == '0'): - return ' ' + return ' ' orig = amount new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) if orig == new: @@ -402,14 +402,14 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): return currency_total def _display_initial_balance(self, data): - if self.initial_balance: - return True - return False + if self.initial_balance: + return True + return False def _display_currency(self, data): - if self.amount_currency: - return True - return False + if self.amount_currency: + return True + return False report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner', 'addons/account/report/account_partner_ledger.rml',parser=third_party_ledger, diff --git a/addons/account/report/account_report.py b/addons/account/report/account_report.py index 8a77ce47280..6b22dc21fdf 100644 --- a/addons/account/report/account_report.py +++ b/addons/account/report/account_report.py @@ -101,14 +101,14 @@ class report_aged_receivable(osv.osv): def _calc_bal(self, cr, uid, ids, name, args, context=None): res = {} for period in self.read(cr, uid, ids, ['name'], context=context): - date1,date2 = period['name'].split(' to ') - cr.execute("SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \ + date1,date2 = period['name'].split(' to ') + cr.execute("SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \ WHERE (line.account_id=ac.id) AND ac.type='receivable' \ AND (COALESCE(line.date,date) BETWEEN %s AND %s) \ AND (reconcile_id IS NULL) AND ac.active",(str(date2),str(date1),)) - amount = cr.fetchone() - amount = amount[0] or 0.00 - res[period['id']] = amount + amount = cr.fetchone() + amount = amount[0] or 0.00 + res[period['id']] = amount return res diff --git a/addons/account/wizard/account_subscription_generate.py b/addons/account/wizard/account_subscription_generate.py index 4c99539301b..8efcd25b789 100644 --- a/addons/account/wizard/account_subscription_generate.py +++ b/addons/account/wizard/account_subscription_generate.py @@ -38,10 +38,10 @@ class account_subscription_generate(osv.osv_memory): act_obj = self.pool.get('ir.actions.act_window') moves_created=[] for data in self.read(cr, uid, ids, context=context): - cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],)) - line_ids = map(lambda x: x[0], cr.fetchall()) - moves = self.pool.get('account.subscription.line').move_create(cr, uid, line_ids, context=context) - moves_created.extend(moves) + cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],)) + line_ids = map(lambda x: x[0], cr.fetchall()) + moves = self.pool.get('account.subscription.line').move_create(cr, uid, line_ids, context=context) + moves_created.extend(moves) result = mod_obj.get_object_reference(cr, uid, 'account', 'action_move_line_form') id = result and result[1] or False result = act_obj.read(cr, uid, [id], context=context)[0] diff --git a/addons/account/wizard/account_tax_chart.py b/addons/account/wizard/account_tax_chart.py index adf09c4052c..16796a5d57c 100644 --- a/addons/account/wizard/account_tax_chart.py +++ b/addons/account/wizard/account_tax_chart.py @@ -51,7 +51,6 @@ class account_tax_chart(osv.osv_memory): """ mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') - period_obj = self.pool.get('account.period') if context is None: context = {} data = self.browse(cr, uid, ids, context=context)[0] diff --git a/addons/account_budget/wizard/account_budget_analytic.py b/addons/account_budget/wizard/account_budget_analytic.py index b2a33434016..3e3b4b0fa9d 100644 --- a/addons/account_budget/wizard/account_budget_analytic.py +++ b/addons/account_budget/wizard/account_budget_analytic.py @@ -36,7 +36,6 @@ class account_budget_analytic(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] diff --git a/addons/account_budget/wizard/account_budget_crossovered_report.py b/addons/account_budget/wizard/account_budget_crossovered_report.py index 5667a264d2a..ff6b6492a5a 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_report.py @@ -36,7 +36,6 @@ class account_budget_crossvered_report(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] 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 c2e34b2f2da..a5eeeb32ff9 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_summary_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_summary_report.py @@ -38,7 +38,6 @@ class account_budget_crossvered_summary_report(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] diff --git a/addons/account_budget/wizard/account_budget_report.py b/addons/account_budget/wizard/account_budget_report.py index a85ff42fe4d..fdae4c94adf 100644 --- a/addons/account_budget/wizard/account_budget_report.py +++ b/addons/account_budget/wizard/account_budget_report.py @@ -37,7 +37,6 @@ class account_budget_report(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] diff --git a/addons/account_invoice_layout/report/report_account_invoice_layout.py b/addons/account_invoice_layout/report/report_account_invoice_layout.py index f61a05fd5f4..3084cd8b564 100644 --- a/addons/account_invoice_layout/report/report_account_invoice_layout.py +++ b/addons/account_invoice_layout/report/report_account_invoice_layout.py @@ -38,7 +38,6 @@ class account_invoice_1(report_sxw.rml_parse): result = [] sub_total = {} info = [] - invoice_list = [] res = {} list_in_seq = {} ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)]) diff --git a/addons/account_invoice_layout/report/special_message_invoice.py b/addons/account_invoice_layout/report/special_message_invoice.py index 20943d01fe1..8aee48c4649 100644 --- a/addons/account_invoice_layout/report/special_message_invoice.py +++ b/addons/account_invoice_layout/report/special_message_invoice.py @@ -46,7 +46,6 @@ class account_invoice_with_message(report_sxw.rml_parse): result = [] sub_total = {} info = [] - invoice_list = [] res = {} list_in_seq = {} ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)]) diff --git a/addons/account_invoice_layout/wizard/account_invoice_special_message.py b/addons/account_invoice_layout/wizard/account_invoice_special_message.py index a0bd6b328c3..27f6044a964 100644 --- a/addons/account_invoice_layout/wizard/account_invoice_special_message.py +++ b/addons/account_invoice_layout/wizard/account_invoice_special_message.py @@ -30,7 +30,6 @@ class account_invoice_special_msg(osv.osv_memory): } def check_report(self, cr, uid, ids, context=None): - datas = {} if context is None: context = {} diff --git a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py index 5718a9fdaa7..fbdf954214b 100644 --- a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py +++ b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py @@ -20,7 +20,6 @@ ############################################################################## from osv import fields,osv -from osv import orm class analytic_journal_rate_grid(osv.osv): @@ -103,7 +102,6 @@ class account_invoice(osv.osv): def _get_analytic_lines(self, cr, uid, id): iml = super(account_invoice, self)._get_analytic_lines(cr, uid, id) - inv = self.browse(cr, uid, [id])[0] for il in iml: if il['account_analytic_id'] and il.get('analytic_lines', False): diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 04f66fb8daa..96da99386c7 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -20,7 +20,6 @@ ############################################################################## from osv import fields,osv -from osv import orm from tools.translate import _ class analytic_user_funct_grid(osv.osv): diff --git a/addons/auction/auction.py b/addons/auction/auction.py index 20442f16250..0b2fc467f88 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -293,13 +293,13 @@ class auction_lots(osv.osv): result = lot.buyer_price - lot.seller_price - lot.costs elif name == "gross_margin": - if ((lot.obj_price==0) and (lot.state=='draft')): - amount = lot.lot_est1 - else: - amount = lot.obj_price - if amount > 0: - result = (lot.gross_revenue * 100) / amount - result = round(result,2) + if ((lot.obj_price==0) and (lot.state=='draft')): + amount = lot.lot_est1 + else: + amount = lot.obj_price + if amount > 0: + result = (lot.gross_revenue * 100) / amount + result = round(result,2) elif name == "net_margin": if ((lot.obj_price==0) and (lot.state=='draft')): diff --git a/addons/auction/report/auction_artists.py b/addons/auction/report/auction_artists.py index b61f9a70e21..818724802f3 100644 --- a/addons/auction/report/auction_artists.py +++ b/addons/auction/report/auction_artists.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/auction_bids.py b/addons/auction/report/auction_bids.py index 7b0639e8849..8f4425a0e70 100644 --- a/addons/auction/report/auction_bids.py +++ b/addons/auction/report/auction_bids.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/auction_buyer_result.py b/addons/auction/report/auction_buyer_result.py index 9534fcdfb56..f979d541e97 100644 --- a/addons/auction/report/auction_buyer_result.py +++ b/addons/auction/report/auction_buyer_result.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/auction_catelog.py b/addons/auction/report/auction_catelog.py index bfa42d730d0..489859f9672 100644 --- a/addons/auction/report/auction_catelog.py +++ b/addons/auction/report/auction_catelog.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/auction_objects.py b/addons/auction/report/auction_objects.py index a83a75a873e..59b44ce4c2f 100644 --- a/addons/auction/report/auction_objects.py +++ b/addons/auction/report/auction_objects.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/auction_result.py b/addons/auction/report/auction_result.py index 0f77e456c28..79de1ccac6b 100644 --- a/addons/auction/report/auction_result.py +++ b/addons/auction/report/auction_result.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/auction_total_rml.py b/addons/auction/report/auction_total_rml.py index 576ed47a84d..610cb108cc4 100644 --- a/addons/auction/report/auction_total_rml.py +++ b/addons/auction/report/auction_total_rml.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/bids_lots.py b/addons/auction/report/bids_lots.py index 3bcc0fd4853..c6c93930455 100644 --- a/addons/auction/report/bids_lots.py +++ b/addons/auction/report/bids_lots.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/bids_phones_details.py b/addons/auction/report/bids_phones_details.py index 4356fff941e..3721fb84c37 100644 --- a/addons/auction/report/bids_phones_details.py +++ b/addons/auction/report/bids_phones_details.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/buyer_form_report.py b/addons/auction/report/buyer_form_report.py index ceffc87e557..37b82cd872e 100644 --- a/addons/auction/report/buyer_form_report.py +++ b/addons/auction/report/buyer_form_report.py @@ -20,10 +20,8 @@ ############################################################################## -import pooler import time from report import report_sxw -from osv import osv class buyer_form_report(report_sxw.rml_parse): count=0 @@ -51,7 +49,6 @@ class buyer_form_report(report_sxw.rml_parse): def buyer_info(self): objects = [object for object in self.localcontext.get('objects')] ret_dict = {} - ret_list = [] for object in objects: partner = ret_dict.get(object.ach_uid.id,False) if not partner: diff --git a/addons/auction/report/buyer_list.py b/addons/auction/report/buyer_list.py index dde5c6ede04..3829238a43f 100644 --- a/addons/auction/report/buyer_list.py +++ b/addons/auction/report/buyer_list.py @@ -19,11 +19,8 @@ # ############################################################################## -import pooler import time from report import report_sxw -from osv import osv -from tools.translate import _ class buyer_list(report_sxw.rml_parse): auc_lot_ids=[] @@ -66,7 +63,6 @@ class buyer_list(report_sxw.rml_parse): return auct_dat def lines_lots_auct_lot(self,obj): - auc_lot_ids = [] auc_date_ids = self.pool.get('auction.dates').search(self.cr, self.uid, ([('name','like',obj['name'])])) diff --git a/addons/auction/report/catalog2.py b/addons/auction/report/catalog2.py index 22b6ecb82f7..e36f4bb3c44 100644 --- a/addons/auction/report/catalog2.py +++ b/addons/auction/report/catalog2.py @@ -19,22 +19,12 @@ # ############################################################################## -import datetime -import time from report.interface import report_rml -from report.interface import toxml import pooler -from osv import osv,orm -from time import strptime from xml.dom import minidom -import sys -import os import re -import netsvc import base64 -import wizard import photo_shadow -from tools import config import addons def _to_unicode(s): @@ -75,11 +65,6 @@ class auction_catalog(report_rml): catalog=doc.createElement('catalog') doc.documentElement.appendChild(catalog) - - infodb='info' - commdb='comm' - tab_avoid = [] - tab_no_photo=[] auction_lot_pool = pooler.get_pool(cr.dbname).get('auction.lots') auction_dates_pool = pooler.get_pool(cr.dbname).get('auction.dates') for auction in auction_dates_pool.browse(cr, uid, ids, context=context): @@ -89,7 +74,7 @@ class auction_catalog(report_rml): categ.appendChild(doc.createTextNode(_to_decode(auction.name))) catalog.appendChild(categ) - #Auctuion Date element + #Auctuion Date element categ = doc.createElement("AuctionDate1") categ.appendChild(doc.createTextNode(_to_decode(auction.auction1))) catalog.appendChild(categ) @@ -133,7 +118,6 @@ class auction_catalog(report_rml): infos.appendChild(lnum) if cat.image: - import random import tempfile limg = doc.createElement('photo_small') diff --git a/addons/auction/report/catelogwithpictures.py b/addons/auction/report/catelogwithpictures.py index 4cfa5f3acc7..6b01c4c45d0 100644 --- a/addons/auction/report/catelogwithpictures.py +++ b/addons/auction/report/catelogwithpictures.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/deposit_seller.py b/addons/auction/report/deposit_seller.py index 01aeef83f33..d7460e5db3a 100644 --- a/addons/auction/report/deposit_seller.py +++ b/addons/auction/report/deposit_seller.py @@ -20,7 +20,6 @@ ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/huissier.py b/addons/auction/report/huissier.py index 1b5f7cc68d7..1d680548886 100644 --- a/addons/auction/report/huissier.py +++ b/addons/auction/report/huissier.py @@ -20,7 +20,6 @@ ############################################################################## import pooler -from osv.osv import osv, orm from report.interface import report_rml #FIXME: use the one from tools and delete the one from report from report.int_to_text import int_to_text diff --git a/addons/auction/report/lots_list.py b/addons/auction/report/lots_list.py index e21df216c64..0ce06f7b498 100644 --- a/addons/auction/report/lots_list.py +++ b/addons/auction/report/lots_list.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/lots_list_inventory.py b/addons/auction/report/lots_list_inventory.py index e740d6ac6c8..017d8598fa4 100644 --- a/addons/auction/report/lots_list_inventory.py +++ b/addons/auction/report/lots_list_inventory.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/lots_list_landscape.py b/addons/auction/report/lots_list_landscape.py index 84762fb8b05..4c50a3def92 100644 --- a/addons/auction/report/lots_list_landscape.py +++ b/addons/auction/report/lots_list_landscape.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/report_lot_bar_code.py b/addons/auction/report/report_lot_bar_code.py index 1337738eb22..338ddf0a539 100644 --- a/addons/auction/report/report_lot_bar_code.py +++ b/addons/auction/report/report_lot_bar_code.py @@ -19,7 +19,6 @@ # ############################################################################## -import pooler import time from report import report_sxw diff --git a/addons/auction/report/seller_form_report.py b/addons/auction/report/seller_form_report.py index 5a67d5be51a..06ff021dcc1 100644 --- a/addons/auction/report/seller_form_report.py +++ b/addons/auction/report/seller_form_report.py @@ -20,15 +20,12 @@ ############################################################################## -import pooler import time from report import report_sxw -from osv import osv class seller_form_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(seller_form_report, self).__init__(cr, uid, name, context=context) - lot=self.pool.get('auction.lots').browse(cr, uid, uid) self.localcontext.update({ 'time': time, @@ -52,7 +49,6 @@ class seller_form_report(report_sxw.rml_parse): def seller_info(self): objects = [object for object in self.localcontext.get('objects')] ret_dict = {} - ret_list = [] for object in objects: partner = ret_dict.get(object.bord_vnd_id.partner_id.id,False) diff --git a/addons/auction/report/total.py b/addons/auction/report/total.py index a198a7c4416..e878001c2e4 100644 --- a/addons/auction/report/total.py +++ b/addons/auction/report/total.py @@ -19,13 +19,9 @@ # ############################################################################## -import os, time, datetime +import time +import netsvc -import netsvc, tools - -import report.print_xml -import report.render -import report.common from report.interface import report_rml def toxml(val): @@ -47,7 +43,6 @@ class report_custom(report_rml): unpaid_ids = [] buyer = {} seller = {} - debit = 0 for l in lots: if l['lot_est2']: diff --git a/addons/auction/wizard/auction_aie_send.py b/addons/auction/wizard/auction_aie_send.py index 1caec13b852..b6a65a48ae8 100644 --- a/addons/auction/wizard/auction_aie_send.py +++ b/addons/auction/wizard/auction_aie_send.py @@ -140,7 +140,7 @@ class auction_lots_send_aie(osv.osv_memory): return post_multipart('auction-in-europe.com', "/bin/photo.cgi", (('uname',uname),('ref',ref),('passwd',passwd),('did',did)),(('file',photo_name,photo_data),)) - def _photos_send(cr, uid, uname, passwd, did, ids): + def _photos_send(self,cr, uid, uname, passwd, did, ids): service = netsvc.LocalService("object_proxy") for (ref,id) in ids: datas = service.execute(cr.db_name, uid, 'auction.lots', 'read', [id], ['name','image']) @@ -179,7 +179,7 @@ class auction_lots_send_aie(osv.osv_memory): } def _send(self, cr, uid, ids, context=None): - import pickle, thread, sql_db + import pickle, thread cr.execute('select name,aie_categ from auction_lot_category') vals = dict(cr.fetchall()) cr.close() diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 095a1654991..a0275cada4e 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -982,10 +982,9 @@ class calendar_event(osv.osv): """ if context is None: context = {} - for event_id in ids: - cr.execute("select id from %s where recurrent_uid=%%s" % (self._table), (event_id,)) - r_ids = map(lambda x: x[0], cr.fetchall()) - self.unlink(cr, uid, r_ids, context=context) + cr.execute('select id from %s where recurrent_uid in %s', (self._table, tuple(ids),)) + r_ids = map(lambda x: x[0], cr.fetchall()) + self.unlink(cr, uid, r_ids, context=context) return True def _set_rrulestring(self, cr, uid, id, name, value, arg, context=None): @@ -1208,7 +1207,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\ value = {} if edit_all and rrule_type: for id in ids: - base_calendar_id2real_id(id) + base_calendar_id2real_id(id) return value def modify_all(self, cr, uid, event_ids, defaults, context=None, *args): diff --git a/addons/crm/crm_action_rule.py b/addons/crm/crm_action_rule.py index 477f9132fab..9962f0025cc 100644 --- a/addons/crm/crm_action_rule.py +++ b/addons/crm/crm_action_rule.py @@ -19,17 +19,12 @@ # ############################################################################## -import time import re -import os -import base64 import tools from tools.translate import _ from osv import fields from osv import osv -from osv import orm -from osv.orm import except_orm import crm diff --git a/addons/crm/wizard/crm_lead_to_partner.py b/addons/crm/wizard/crm_lead_to_partner.py index ae9943cb6db..5dc7e489f26 100644 --- a/addons/crm/wizard/crm_lead_to_partner.py +++ b/addons/crm/wizard/crm_lead_to_partner.py @@ -51,7 +51,7 @@ class crm_lead2partner(osv.osv_memory): rec_ids = context and context.get('active_ids', []) for lead in lead_obj.browse(cr, uid, rec_ids, context=context): if lead.partner_id: - raise osv.except_osv(_('Warning !'), + raise osv.except_osv(_('Warning !'), _('A partner is already defined on this lead.')) def default_get(self, cr, uid, fields, context=None): @@ -68,7 +68,6 @@ class crm_lead2partner(osv.osv_memory): lead_obj = self.pool.get('crm.lead') partner_obj = self.pool.get('res.partner') - contact_obj = self.pool.get('res.partner.address') partner_id = False data = list(context and context.get('active_ids', []) or []) @@ -206,9 +205,6 @@ class crm_lead2partner(osv.osv_memory): context = {} partner_ids = self._create_partner(cr, uid, ids, context=context) - mod_obj = self.pool.get('ir.model.data') - result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter') - res = mod_obj.read(cr, uid, result, ['res_id']) return {'type': 'ir.actions.act_window_close'} crm_lead2partner() diff --git a/addons/crm/wizard/crm_merge_opportunities.py b/addons/crm/wizard/crm_merge_opportunities.py index 8cf1d14ce17..6330d05f9f5 100644 --- a/addons/crm/wizard/crm_merge_opportunities.py +++ b/addons/crm/wizard/crm_merge_opportunities.py @@ -51,7 +51,6 @@ class crm_merge_opportunity(osv.osv_memory): def get_attachments(self, cr, uid, id, context=None): attach_obj = self.pool.get('ir.attachment') - result = [] attach_ids = attach_obj.search(cr, uid, [('res_model' , '=', 'crm.lead'), ('res_id', '=', id)]) return attach_ids diff --git a/addons/crm/wizard/crm_partner_to_opportunity.py b/addons/crm/wizard/crm_partner_to_opportunity.py index bbede21a682..4d24bd5b78f 100644 --- a/addons/crm/wizard/crm_partner_to_opportunity.py +++ b/addons/crm/wizard/crm_partner_to_opportunity.py @@ -67,8 +67,12 @@ class crm_partner2opportunity(osv.osv_memory): data = context and context.get('active_ids', []) or [] make_opportunity = self.pool.get('crm.partner2opportunity') + data_obj = self.pool.get('ir.model.data') + part_obj = self.pool.get('res.partner') + categ_obj = self.pool.get('crm.case.categ') + case_obj = self.pool.get('crm.lead') + for make_opportunity_obj in make_opportunity.browse(cr, uid, ids, context=context): - data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter') res = data_obj.read(cr, uid, result, ['res_id']) @@ -79,14 +83,9 @@ class crm_partner2opportunity(osv.osv_memory): if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id - part_obj = self.pool.get('res.partner') address = part_obj.address_get(cr, uid, data) - - - categ_obj = self.pool.get('crm.case.categ') categ_ids = categ_obj.search(cr, uid, [('object_id.model','=','crm.lead')]) - case_obj = self.pool.get('crm.lead') opp_id = case_obj.create(cr, uid, { 'name' : make_opportunity_obj.name, 'planned_revenue' : make_opportunity_obj.planned_revenue, diff --git a/addons/crm/wizard/wizard_history_event.py b/addons/crm/wizard/wizard_history_event.py index b71ee0d6cd0..caaf37a88d8 100644 --- a/addons/crm/wizard/wizard_history_event.py +++ b/addons/crm/wizard/wizard_history_event.py @@ -22,7 +22,6 @@ import wizard import pooler -import time def _open_history_event(self, cr, uid, data, context=None): pool = pooler.get_pool(cr.dbname) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index e69e3134e0b..33c394d430e 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -243,7 +243,6 @@ class mrp_bom(osv.osv): def _check_product(self, cr, uid, ids, context=None): all_prod = [] - bom_obj = self.pool.get('mrp.bom') boms = self.browse(cr, uid, ids, context=context) def check_bom(boms): res = True @@ -672,10 +671,10 @@ class mrp_production(osv.osv): res = True for production in self.browse(cr, uid, ids): if production.move_lines: - res = False + res = False if production.move_created_ids: - res = False + res = False return res def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): @@ -748,7 +747,7 @@ class mrp_production(osv.osv): produced_qty = produced_products.get(produce_product.product_id.id, 0) rest_qty = production.product_qty - produced_qty if rest_qty <= production_qty: - production_qty = rest_qty + production_qty = rest_qty if rest_qty > 0 : stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, context=context) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index b19c2c0e15e..41a9d7993a2 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -24,9 +24,7 @@ from dateutil.relativedelta import relativedelta from osv import fields from osv import osv from tools.translate import _ -import ir import netsvc -import time class procurement_order(osv.osv): _inherit = 'procurement.order' @@ -81,7 +79,6 @@ class procurement_order(osv.osv): procurement_obj = self.pool.get('procurement.order') for procurement in procurement_obj.browse(cr, uid, ids, context=context): res_id = procurement.move_id.id - loc_id = procurement.location_id.id newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0) newdate = newdate - relativedelta(days=company.manufacturing_lead) produce_id = production_obj.create(cr, uid, { diff --git a/addons/project/project.py b/addons/project/project.py index 7fbe39219a8..50b5c463284 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -82,7 +82,6 @@ class project(osv.osv): def _progress_rate(self, cr, uid, ids, names, arg, context=None): res = {}.fromkeys(ids, 0.0) - progress = {} if not ids: return res cr.execute('''SELECT @@ -161,9 +160,9 @@ class project(osv.osv): # TODO: Why not using a SQL contraints ? def _check_dates(self, cr, uid, ids, context=None): for leave in self.read(cr, uid, ids, ['date_start', 'date'], context=context): - if leave['date_start'] and leave['date']: - if leave['date_start'] > leave['date']: - return False + if leave['date_start'] and leave['date']: + if leave['date_start'] > leave['date']: + return False return True _constraints = [ @@ -241,7 +240,6 @@ class project(osv.osv): def duplicate_template(self, cr, uid, ids, context=None): if context is None: context = {} - task_pool = self.pool.get('project.task') data_obj = self.pool.get('ir.model.data') result = [] for proj in self.browse(cr, uid, ids, context=context): @@ -401,8 +399,8 @@ class task(osv.osv): if not default.get('name', False): default['name'] = self.browse(cr, uid, id, context=context).name or '' if not context.get('copy',False): - new_name = _("%s (copy)")%default.get('name','') - default.update({'name':new_name}) + new_name = _("%s (copy)")%default.get('name','') + default.update({'name':new_name}) return super(task, self).copy_data(cr, uid, id, default, context) @@ -572,7 +570,7 @@ class task(osv.osv): project = task.project_id res = self.do_close(cr, uid, [project_id], context=context) if project.warn_manager or project.warn_customer: - return { + return { 'name': _('Send Email after close task'), 'view_type': 'form', 'view_mode': 'form',