From c4677c4640b7807f48853dcfa6d186aacffbe3bd Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 May 2014 16:10:56 +0200 Subject: [PATCH 1/6] [FIX] type=string? --- addons/crm/sales_team.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/sales_team.py b/addons/crm/sales_team.py index 8a1e9f938af15..013793ed4cfbf 100644 --- a/addons/crm/sales_team.py +++ b/addons/crm/sales_team.py @@ -41,10 +41,10 @@ def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None): help="The first contact you get with a potential customer is a lead you qualify before converting it into a real business opportunity. Check this box to manage leads in this sales team."), 'use_opportunities': fields.boolean('Opportunities', help="Check this box to manage opportunities in this sales team."), 'monthly_open_leads': fields.function(_get_opportunities_data, - type="string", readonly=True, multi='_get_opportunities_data', + type="char", readonly=True, multi='_get_opportunities_data', string='Open Leads per Month'), 'monthly_planned_revenue': fields.function(_get_opportunities_data, - type="string", readonly=True, multi='_get_opportunities_data', + type="char", readonly=True, multi='_get_opportunities_data', string='Planned Revenue per Month'), 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="The email address associated with this team. New emails received will automatically create new leads assigned to the team."), } From 8ec2661e083cbc06361e02939eed6048d09e2c75 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 May 2014 16:11:39 +0200 Subject: [PATCH 2/6] [FIX] don't initialize a non-bool variable to a boolean shall we? --- addons/calendar/calendar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 46e8b024dd62f..80bd951e311ce 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -297,7 +297,7 @@ def get_attendee_detail(self, cr, uid, ids, meeting_id, context=None): Used by web_calendar.js : Many2ManyAttendee """ datas = [] - meeting = False + meeting = None if meeting_id: meeting = self.pool['calendar.event'].browse(cr, uid, get_real_ids(meeting_id), context=context) for partner in self.browse(cr, uid, ids, context=context): From 9c9b0a904c24a748f3227743925aec9598304b41 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 May 2014 16:56:33 +0200 Subject: [PATCH 3/6] [FIX] account: reference to non-existent name --- addons/account/account_invoice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 4b2586117b657..3eddf1a9bd44a 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -578,8 +578,11 @@ def onchange_company_id(self, company_id, part_id, type, invoice_line, currency_ if not values.get('journal_id'): field_desc = journals.fields_get(['journal_id']) type_label = next(t for t, label in field_desc['journal_id']['selection'] if t == journal_type) - raise except_orm(_('Configuration Error!'), - _('Cannot find any account journal of "%s" type for this company.\n\nYou can create one in the menu: \nConfiguration\Journals\Journals.') % journal_type_label) + raise except_orm( + _('Configuration Error!'), + _('Cannot find any account journal of "%s" type for this company.\n\n' + 'You can create one in the menu: \n' + 'Configuration\Journals\Journals.') % type_label) domain = {'journal_id': [('id', 'in', journals.ids)]} return {'value': values, 'domain': domain} From c4eeca1c6410f9389fa41153ff0a13bf09a08a25 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 May 2014 16:57:11 +0200 Subject: [PATCH 4/6] [IMP] account: initialize list to an actual list, not a bool --- addons/account/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 3eddf1a9bd44a..ef3896d4c3b29 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -853,7 +853,7 @@ def action_move_create(self): total, total_currency, iml = inv.sudo(context=ctx).compute_invoice_totals(company_currency, ref, iml) name = inv.name or inv.supplier_invoice_number or '/' - totlines = False + totlines = [] if inv.payment_term: totlines = inv.sudo(context=ctx).payment_term.compute(total, inv.date_invoice)[0] if totlines: From 223c2d4fc238197f4f2803418ef110b0fd3115e9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 May 2014 17:03:02 +0200 Subject: [PATCH 5/6] [FIX] account: reference to non-existent context local variable --- addons/account/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index ef3896d4c3b29..e8a0818c8b118 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1242,7 +1242,7 @@ def _default_price_unit(self): if taxes and len(taxes[0]) >= 3 and taxes[0][2]: taxes = self.env['account.tax'].browse(taxes[0][2]) tax_res = taxes.compute_all(price, vals.get('quantity'), - product=vals.get('product_id'), partner=context.get('partner_id')) + product=vals.get('product_id'), partner=self._context.get('partner_id')) for tax in tax_res['taxes']: total = total - tax['amount'] return total From 246cf40808698ae9d9f72f0527df6406701a2d80 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 May 2014 17:03:13 +0200 Subject: [PATCH 6/6] [IMP] various style issues --- addons/account/account_invoice.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index e8a0818c8b118..16870266be0a6 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -516,13 +516,9 @@ def onchange_company_id(self, company_id, part_id, type, invoice_line, currency_ values = {} domain = {} - obj_journal = self.env['account.journal'] - account_obj = self.env['account.account'] - inv_line_obj = self.env['account.invoice.line'] if company_id and part_id and type: p = self.env['res.partner'].browse(part_id) - acc_id = False if p.property_account_payable and p.property_account_receivable and \ p.property_account_payable.company_id.id != company_id and \ p.property_account_receivable.company_id.id != company_id: @@ -826,7 +822,7 @@ def action_move_create(self): # I disabled the check_total feature group_check_total = self.env.ref('account.group_supplier_inv_check_total') if self.env.user in group_check_total.users: - if (inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding / 2.0)): + if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding / 2.0): raise except_orm(_('Bad Total!'), _('Please verify the price of the invoice!\nThe encoded total does not match the computed total.')) if inv.payment_term: @@ -890,7 +886,7 @@ def action_move_create(self): 'amount_currency': diff_currency and total_currency, 'currency_id': diff_currency and inv.currency_id.id, 'ref': ref - }) + }) date = inv.date_invoice or Date.today() @@ -964,7 +960,7 @@ def line_get_convert(self, line, part, date): @multi def action_number(self): - #TODO: not correct fix but required a frech values before reading it. + #TODO: not correct fix but required a fresh values before reading it. self.write({}) for inv in self: @@ -1310,7 +1306,7 @@ def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None): context = context or {} - company_id = company_id if company_id != None else context.get('company_id', False) + company_id = company_id if company_id is not None else context.get('company_id', False) self = self.sudo(company_id=company_id, force_company=company_id) if not partner_id: