From c2de4e255cfce2f2fdf035d240bfdb819bc16520 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 16 Apr 2015 13:45:33 +0200 Subject: [PATCH] [REF] py linter --- addons/website_sale/models/sale_order.py | 29 ++++++++++++-------- openerp/addons/base/res/res_country.py | 35 ++++++++++++------------ 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 7b68750e69e..23e2563829e 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -49,7 +49,8 @@ class sale_order(osv.Model): def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, line_id=None, context=None): so = self.pool.get('sale.order').browse(cr, uid, order_id, context=context) - values = self.pool.get('sale.order.line').product_id_change(cr, SUPERUSER_ID, [], + values = self.pool.get('sale.order.line').product_id_change( + cr, SUPERUSER_ID, [], pricelist=so.pricelist_id.id, product=product_id, partner_id=so.partner_id.id, @@ -69,7 +70,7 @@ class sale_order(osv.Model): values['product_id'] = product_id values['order_id'] = order_id - if values.get('tax_id') != None: + if values.get('tax_id') is not None: values['tax_id'] = [(6, 0, values['tax_id'])] return values @@ -79,7 +80,7 @@ class sale_order(osv.Model): quantity = 0 for so in self.browse(cr, uid, ids, context=context): - if line_id != False: + if line_id is not False: line_ids = so._cart_find_product_line(product_id, line_id, context=context, **kwargs) if line_ids: line_id = line_ids[0] @@ -94,7 +95,7 @@ class sale_order(osv.Model): # compute new quantity if set_qty: quantity = set_qty - elif add_qty != None: + elif add_qty is not None: quantity = sol.browse(cr, SUPERUSER_ID, line_id, context=context).product_uom_qty + (add_qty or 0) # Remove zero of negative lines @@ -112,19 +113,22 @@ class sale_order(osv.Model): for order in self.browse(cr, uid, ids, context=context): s = set(j.id for l in (order.website_order_line or []) for j in (l.product_id.accessory_product_ids or [])) s -= set(l.product_id.id for l in order.order_line) - product_ids = random.sample(s, min(len(s),3)) + product_ids = random.sample(s, min(len(s), 3)) return self.pool['product.product'].browse(cr, uid, product_ids, context=context) + class website(orm.Model): _inherit = 'website' _columns = { - 'pricelist_id': fields.related('user_id','partner_id','property_product_pricelist', + 'pricelist_id': fields.related( + 'user_id', 'partner_id', 'property_product_pricelist', type='many2one', relation='product.pricelist', string='Default Pricelist'), - 'currency_id': fields.related('pricelist_id','currency_id', + 'currency_id': fields.related( + 'pricelist_id', 'currency_id', type='many2one', relation='res.currency', string='Default Currency'), - 'salesperson_id': fields.many2one('res.users', 'Salesperson'), - 'salesteam_id': fields.many2one('crm.team', 'Sales Team'), + 'salesperson_id': fields.many2one('res.users', 'Salesperson'), + 'salesteam_id': fields.many2one('crm.team', 'Sales Team'), } def sale_product_domain(self, cr, uid, ids, context=None): @@ -180,8 +184,9 @@ class website(orm.Model): values = sale_order_obj.onchange_partner_id(cr, SUPERUSER_ID, [sale_order_id], partner.id, context=context)['value'] if values.get('fiscal_position_id'): - order_lines = map(int,sale_order.order_line) - values.update(sale_order_obj.onchange_fiscal_position(cr, SUPERUSER_ID, [], + order_lines = map(int, sale_order.order_line) + values.update(sale_order_obj.onchange_fiscal_position( + cr, SUPERUSER_ID, [], values['fiscal_position_id'], [[6, 0, order_lines]], context=context)['value']) values['partner_id'] = partner.id @@ -199,7 +204,7 @@ class website(orm.Model): sale_order._cart_update(product_id=line.product_id.id, line_id=line.id, add_qty=0) # update browse record - if (code and code != sale_order.pricelist_id.code) or sale_order.partner_id.id != partner.id: + if (code and code != sale_order.pricelist_id.code) or sale_order.partner_id.id != partner.id: sale_order = sale_order_obj.browse(cr, SUPERUSER_ID, sale_order.id, context=context) return sale_order diff --git a/openerp/addons/base/res/res_country.py b/openerp/addons/base/res/res_country.py index baf9b6f4134..c8d0940721c 100644 --- a/openerp/addons/base/res/res_country.py +++ b/openerp/addons/base/res/res_country.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,12 +15,13 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## from openerp.osv import fields, osv + def location_name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): if not args: @@ -32,22 +33,24 @@ def location_name_search(self, cr, user, name='', args=None, operator='ilike', limit=limit, context=context) search_domain = [('name', operator, name)] - if ids: search_domain.append(('id', 'not in', ids)) + if ids: + search_domain.append(('id', 'not in', ids)) ids.extend(self.search(cr, user, search_domain + args, limit=limit, context=context)) locations = self.name_get(cr, user, ids, context) return sorted(locations, key=lambda (id, name): ids.index(id)) + class Country(osv.osv): _name = 'res.country' _description = 'Country' _columns = { 'name': fields.char('Country Name', - help='The full name of the country.', required=True, translate=True), + help='The full name of the country.', required=True, translate=True), 'code': fields.char('Country Code', size=2, - help='The ISO country code in two chars.\n' - 'You can use this field for quick search.'), + help='The ISO country code in two chars.\n' + 'You can use this field for quick search.'), 'address_format': fields.text('Address Format', help="""You can state here the usual format to use for the \ addresses belonging to this country.\n\nYou can use the python-style string patern with all the field of the address \ (for example, use '%(street)s' to display the field 'street') plus @@ -68,41 +71,39 @@ addresses belonging to this country.\n\nYou can use the python-style string pate _defaults = { 'address_format': "%(street)s\n%(street2)s\n%(city)s %(state_code)s %(zip)s\n%(country_name)s", } - _order='name' + _order = 'name' name_search = location_name_search def create(self, cursor, user, vals, context=None): if vals.get('code'): vals['code'] = vals['code'].upper() - return super(Country, self).create(cursor, user, vals, - context=context) + return super(Country, self).create(cursor, user, vals, context=context) def write(self, cursor, user, ids, vals, context=None): if vals.get('code'): vals['code'] = vals['code'].upper() - return super(Country, self).write(cursor, user, ids, vals, - context=context) + return super(Country, self).write(cursor, user, ids, vals, context=context) class CountryGroup(osv.osv): - _description="Country Group" + _description = "Country Group" _name = 'res.country.group' _columns = { 'name': fields.char('Name', required=True), 'country_ids': fields.many2many('res.country', 'res_country_res_country_group_rel', 'res_country_group_id', 'res_country_id', string='Countries'), } + class CountryState(osv.osv): - _description="Country state" + _description = "Country state" _name = 'res.country.state' _columns = { - 'country_id': fields.many2one('res.country', 'Country', - required=True), - 'name': fields.char('State Name', required=True, + 'country_id': fields.many2one('res.country', 'Country', required=True), + 'name': fields.char('State Name', required=True, help='Administrative divisions of a country. E.g. Fed. State, Departement, Canton'), 'code': fields.char('State Code', size=3, - help='The state code in max. three chars.', required=True), + help='The state code in max. three chars.', required=True), } _order = 'code'