From a1827c05906cfc1cfccbd66e14df0e12354ef36f Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Tue, 18 Feb 2014 11:34:22 +0100 Subject: [PATCH] [PEP8] --- crm_claim_rma/account_invoice.py | 2 +- crm_claim_rma/crm_claim_rma.py | 90 ++++++++++++------- crm_claim_rma/stock.py | 5 +- .../wizard/account_invoice_refund.py | 2 +- crm_claim_rma/wizard/claim_make_picking.py | 12 +-- 5 files changed, 68 insertions(+), 43 deletions(-) diff --git a/crm_claim_rma/account_invoice.py b/crm_claim_rma/account_invoice.py index 4b2db22f..b6ca9285 100644 --- a/crm_claim_rma/account_invoice.py +++ b/crm_claim_rma/account_invoice.py @@ -42,7 +42,7 @@ class account_invoice(orm.Model): claim_line_obj = self.pool.get('claim.line') # check if is an invoice_line and we are from a claim if not (context.get('claim_line_ids') and lines and - lines[0]._name =='account.invoice.line'): + lines[0]._name == 'account.invoice.line'): return super(account_invoice, self)._refund_cleanup_lines( cr, uid, lines, context=None) diff --git a/crm_claim_rma/crm_claim_rma.py b/crm_claim_rma/crm_claim_rma.py index 4b616d3a..fdd9760c 100644 --- a/crm_claim_rma/crm_claim_rma.py +++ b/crm_claim_rma/crm_claim_rma.py @@ -31,6 +31,7 @@ from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT, from openerp.tools.translate import _ from openerp import SUPERUSER_ID + class substate_substate(orm.Model): """ To precise a state (state=refused; substates= reason 1, 2,...) """ _name = "substate.substate" @@ -106,13 +107,13 @@ class claim_line(orm.Model): 'product_returned_quantity': fields.float( 'Quantity', digits=(12, 2), help="Quantity of product returned"), - 'unit_sale_price' : fields.float( + 'unit_sale_price': fields.float( 'Unit sale price', digits=(12, 2), help="Unit sale price of the product. Auto filled if retrun done " "by invoice selection. Be careful and check the automatic " "value as don't take into account previous refunds, invoice " "discount, can be for 0 if product for free,..."), - 'return_value' : fields.function( + 'return_value': fields.function( _line_total_amount, string='Total return', type='float', help="Quantity returned * Unit sold price",), 'prodlot_id': fields.many2one( @@ -133,23 +134,24 @@ class claim_line(orm.Model): 'Warranty', readonly=True, help="If warranty has expired"), - "warranty_type": fields.selection( + 'warranty_type': fields.selection( get_warranty_return_partner, 'Warranty type', readonly=True, - help="Who is in charge of the warranty return treatment towards the end customer. " - "Company will use the current company delivery or default address and so on for " - "supplier and brand manufacturer. Does not necessarily mean that the warranty to be " - "applied is the one of the return partner (ie: can be returned to the company and " - "be under the brand warranty"), - "warranty_return_partner" : fields.many2one( + help="Who is in charge of the warranty return treatment towards " + "the end customer. Company will use the current company " + "delivery or default address and so on for supplier and brand" + " manufacturer. Does not necessarily mean that the warranty " + "to be applied is the one of the return partner (ie: can be " + "returned to the company and be under the brand warranty"), + 'warranty_return_partner': fields.many2one( 'res.partner', string='Warranty Address', help="Where the customer has to send back the product(s)"), 'claim_id': fields.many2one( 'crm.claim', string='Related claim', help="To link to the case.claim object"), - 'state' : fields.selection( + 'state': fields.selection( [('draft', 'Draft'), ('refused', 'Refused'), ('confirmed', 'Confirmed, waiting for product'), @@ -160,8 +162,8 @@ class claim_line(orm.Model): 'substate_id': fields.many2one( 'substate.substate', string='Sub state', - help="Select a sub state to precise the standard state. Example 1: " - "state = refused; substate could be warranty over, not in " + help="Select a sub state to precise the standard state. Example 1:" + " state = refused; substate could be warranty over, not in " "warranty, no problem,... . Example 2: state = to treate; " "substate could be to refund, to exchange, to repair,..."), 'last_state_change': fields.date( @@ -245,10 +247,11 @@ class claim_line(orm.Model): warning = _(self.WARRANT_COMMENT['expired']) else: warning = _(self.WARRANT_COMMENT['valid']) - self.write(cr, uid, ids, - {'guarantee_limit': limit.strftime(DEFAULT_SERVER_DATE_FORMAT), - 'warning': warning}, - context=context) + self.write( + cr, uid, ids, + {'guarantee_limit': limit.strftime(DEFAULT_SERVER_DATE_FORMAT), + 'warning': warning}, + context=context) return True def get_destination_location(self, cr, uid, product_id, @@ -270,13 +273,14 @@ class claim_line(orm.Model): return location_dest_id # Method to calculate warranty return address - def set_warranty_return_address(self, cr, uid, ids, claim_line, context=None): + def set_warranty_return_address(self, cr, uid, ids, claim_line, + context=None): """Return the partner to be used as return destination and the destination stock location of the line in case of return. We can have various case here: - - company or other: return to company partner or crm_return_address_id - if specified + - company or other: return to company partner or + crm_return_address_id if specified - supplier: return to the supplier address """ @@ -318,7 +322,8 @@ class claim_line(orm.Model): return True -#TODO add the option to split the claim_line in order to manage the same product separately +#TODO add the option to split the claim_line in order to manage the same +# product separately class crm_claim(orm.Model): _inherit = 'crm.claim' @@ -350,7 +355,8 @@ class crm_claim(orm.Model): def create(self, cr, uid, vals, context=None): if ('number' not in vals) or (vals.get('number') == '/'): - vals['number'] = self._get_sequence_number(cr, uid, context=context) + vals['number'] = self._get_sequence_number(cr, uid, + context=context) new_id = super(crm_claim, self).create(cr, uid, vals, context=context) return new_id @@ -388,7 +394,8 @@ class crm_claim(orm.Model): 'planned_cost': fields.float('Expected cost'), 'real_revenue': fields.float('Real revenue'), 'real_cost': fields.float('Real cost'), - 'invoice_ids': fields.one2many('account.invoice', 'claim_id', 'Refunds'), + 'invoice_ids': fields.one2many( + 'account.invoice', 'claim_id', 'Refunds'), 'picking_ids': fields.one2many('stock.picking', 'claim_id', 'RMA'), 'invoice_id': fields.many2one( 'account.invoice', string='Invoice', @@ -413,11 +420,14 @@ class crm_claim(orm.Model): 'Number/Reference must be unique per Company!'), ] - def onchange_partner_address_id(self, cr, uid, ids, add, email=False, context=None): - res = super(crm_claim, self).onchange_partner_address_id( - cr, uid, ids, add, email=email) + def onchange_partner_address_id(self, cr, uid, ids, add, email=False, + context=None): + res = super(crm_claim, self + ).onchange_partner_address_id(cr, uid, ids, add, + email=email) if add: - if not res['value']['email_from'] or not res['value']['partner_phone']: + if (not res['value']['email_from'] + or not res['value']['partner_phone']): partner_obj = self.pool.get('res.partner') address = partner_obj.browse(cr, uid, add, context=context) for other_add in address.partner_id.address: @@ -427,7 +437,8 @@ class crm_claim(orm.Model): res['value']['partner_phone'] = other_add.phone return res - def onchange_invoice_id(self, cr, uid, ids, invoice_id, warehouse_id, context=None): + def onchange_invoice_id(self, cr, uid, ids, invoice_id, warehouse_id, + context=None): invoice_line_obj = self.pool.get('account.invoice.line') invoice_obj = self.pool.get('account.invoice') claim_line_obj = self.pool.get('claim.line') @@ -438,7 +449,8 @@ class crm_claim(orm.Model): claim_lines = [] value = {} if not warehouse_id: - warehouse_id = self._get_default_warehouse(cr, uid, context=context) + warehouse_id = self._get_default_warehouse(cr, uid, + context=context) invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids, context=context) for invoice_line in invoice_lines: @@ -466,17 +478,27 @@ class crm_claim(orm.Model): def message_get_reply_to(self, cr, uid, ids, context=None): """ Override to get the reply_to of the parent project. """ - return [claim.section_id.message_get_reply_to()[0] if claim.section_id else False - for claim in self.browse(cr, SUPERUSER_ID, ids, context=context)] + return [claim.section_id.message_get_reply_to()[0] + if claim.section_id else False + for claim in self.browse(cr, SUPERUSER_ID, ids, + context=context)] def message_get_suggested_recipients(self, cr, uid, ids, context=None): - recipients = super(crm_claim, self).message_get_suggested_recipients(cr, uid, ids, context=context) + recipients = super(crm_claim, self + ).message_get_suggested_recipients(cr, uid, ids, + context=context) try: for claim in self.browse(cr, uid, ids, context=context): if claim.partner_id: - self._message_add_suggested_recipient(cr, uid, recipients, claim, partner=claim.partner_id, reason=_('Customer')) + self._message_add_suggested_recipient( + cr, uid, recipients, claim, + partner=claim.partner_id, reason=_('Customer')) elif claim.email_from: - self._message_add_suggested_recipient(cr, uid, recipients, claim, email=claim.email_from, reason=_('Customer Email')) - except (osv.except_osv, orm.except_orm): # no read access rights -> just ignore suggested recipients because this imply modifying followers + self._message_add_suggested_recipient( + cr, uid, recipients, claim, + email=claim.email_from, reason=_('Customer Email')) + except (osv.except_osv, orm.except_orm): + # no read access rights -> just ignore suggested recipients + # because this imply modifying followers pass return recipients diff --git a/crm_claim_rma/stock.py b/crm_claim_rma/stock.py index a502f8ef..ca8ab35e 100644 --- a/crm_claim_rma/stock.py +++ b/crm_claim_rma/stock.py @@ -54,7 +54,7 @@ class stock_picking_out(orm.Model): } -class stock_picking_out(orm.Model): +class stock_picking_in(orm.Model): _inherit = "stock.picking.in" @@ -72,7 +72,8 @@ class stock_move(orm.Model): _inherit = "stock.move" def create(self, cr, uid, vals, context=None): - move_id = super(stock_move, self).create(cr, uid, vals, context=context) + move_id = super(stock_move, self + ).create(cr, uid, vals, context=context) if vals.get('picking_id'): picking_obj = self.pool.get('stock.picking') picking = picking_obj.browse(cr, uid, vals['picking_id'], diff --git a/crm_claim_rma/wizard/account_invoice_refund.py b/crm_claim_rma/wizard/account_invoice_refund.py index 3248089a..568e3774 100644 --- a/crm_claim_rma/wizard/account_invoice_refund.py +++ b/crm_claim_rma/wizard/account_invoice_refund.py @@ -29,7 +29,7 @@ class account_invoice_refund(orm.TransientModel): def compute_refund(self, cr, uid, ids, mode='refund', context=None): if context is None: - context={} + context = {} if context.get('invoice_ids'): context['active_ids'] = context.get('invoice_ids') return super(account_invoice_refund, self).compute_refund( diff --git a/crm_claim_rma/wizard/claim_make_picking.py b/crm_claim_rma/wizard/claim_make_picking.py index a98503f9..33e6d65f 100644 --- a/crm_claim_rma/wizard/claim_make_picking.py +++ b/crm_claim_rma/wizard/claim_make_picking.py @@ -51,7 +51,8 @@ class claim_make_picking(orm.TransientModel): } def _get_claim_lines(self, cr, uid, context): - #TODO use custom states to show buttons of this wizard or not instead of raise an error + #TODO use custom states to show buttons of this wizard or not instead + # of raise an error if context is None: context = {} line_obj = self.pool.get('claim.line') @@ -112,7 +113,8 @@ class claim_make_picking(orm.TransientModel): line_obj = self.pool.get('claim.line') line_partner = [] for line in line_obj.browse(cr, uid, line_ids, context=context): - if (line.warranty_return_partner and line.warranty_return_partner.id + if (line.warranty_return_partner + and line.warranty_return_partner.id not in line_partner): line_partner.append(line.warranty_return_partner.id) if len(line_partner) == 1: @@ -123,8 +125,8 @@ class claim_make_picking(orm.TransientModel): def _get_dest_loc(self, cr, uid, context): """Return the location_id to use as destination. If it's an outoing shippment: take the customer stock property - If it's an incomming shippment take the location_dest_id common to all lines, or - if different, return None.""" + If it's an incomming shippment take the location_dest_id common to all + lines, or if different, return None.""" if context is None: context = {} loc_id = False @@ -220,7 +222,7 @@ class claim_make_picking(orm.TransientModel): 'location_dest_id': wizard.claim_line_dest_location.id, 'note': note, 'claim_id': claim.id, - }, + }, context=context) # Create picking lines for wizard_claim_line in wizard.claim_line_ids: