From 942875ea535476fa3641568b36fa254d73edec4f Mon Sep 17 00:00:00 2001 From: George Daramouskas Date: Thu, 13 Sep 2018 15:03:14 +0200 Subject: [PATCH] [FIX] [no task] Fix linting issues --- crm_claim_rma/data/crm_case_categ.xml | 4 +-- crm_claim_rma/data/crm_case_section.xml | 2 +- crm_claim_rma/models/claim_line.py | 8 ++--- crm_claim_rma/security/ir.model.access.csv | 8 ++--- crm_claim_rma/tests/test_picking_creation.py | 3 +- crm_claim_rma/views/crm_claim.xml | 1 + .../tests/test_crm_rma_lot_mass_return.py | 2 +- .../tests/test_crm_rma_lot_mass_return_2.py | 4 +-- .../wizards/returned_lines_from_serial.py | 28 ++++++++---------- .../models/stock_production_lot.py | 4 +-- .../tests/test_crm_rma_prodlot_invoice.py | 2 +- .../models/product_product.py | 12 ++++---- .../models/product_template.py | 24 +++++++-------- .../tests/test_crm_rma_stock_location.py | 1 + .../tests/test_make_picking_from_picking.py | 12 ++++---- .../claim_make_picking_from_picking.py | 10 +++---- product_warranty/__openerp__.py | 1 - .../models/product_supplierinfo.py | 29 +++++++++---------- .../tests/test_product_warranty.py | 6 ++++ 19 files changed, 83 insertions(+), 78 deletions(-) diff --git a/crm_claim_rma/data/crm_case_categ.xml b/crm_claim_rma/data/crm_case_categ.xml index d9f88745..4f605943 100644 --- a/crm_claim_rma/data/crm_case_categ.xml +++ b/crm_claim_rma/data/crm_case_categ.xml @@ -1,13 +1,13 @@ - + No Inventory - + Customer Return diff --git a/crm_claim_rma/data/crm_case_section.xml b/crm_claim_rma/data/crm_case_section.xml index fea22f4d..3c1da9d0 100644 --- a/crm_claim_rma/data/crm_case_section.xml +++ b/crm_claim_rma/data/crm_case_section.xml @@ -1,7 +1,7 @@ - + After Sales Service ASV diff --git a/crm_claim_rma/models/claim_line.py b/crm_claim_rma/models/claim_line.py index 7ac94b1c..5b907e56 100644 --- a/crm_claim_rma/models/claim_line.py +++ b/crm_claim_rma/models/claim_line.py @@ -89,7 +89,7 @@ class ClaimLine(models.Model): ('2_high', 'High'), ('3_very_high', 'Very High')], 'Priority', default='0_not_define', - compute='_set_priority', + compute='_compute_set_priority', store=True, readonly=False, help="Priority attention of claim line") @@ -135,7 +135,7 @@ class ClaimLine(models.Model): warning = fields.Selection(WARRANT_COMMENT, 'Warranty', readonly=True, help="If warranty has expired") - display_name = fields.Char('Name', compute='_get_display_name') + display_name = fields.Char('Name', compute='_compute_get_display_name') @api.model def get_warranty_return_partner(self): @@ -220,7 +220,7 @@ class ClaimLine(models.Model): return super(ClaimLine, self).copy(default=std_default) @api.depends('invoice_date', 'date') - def _set_priority(self): + def _compute_set_priority(self): """ To determine the priority of claim line """ @@ -429,7 +429,7 @@ class ClaimLine(models.Model): return res @api.multi - def _get_display_name(self): + def _compute_get_display_name(self): for line_id in self: line_id.display_name = "%s - %s" % ( line_id.claim_id.code, line_id.name) diff --git a/crm_claim_rma/security/ir.model.access.csv b/crm_claim_rma/security/ir.model.access.csv index 08cd096b..d83f1d35 100644 --- a/crm_claim_rma/security/ir.model.access.csv +++ b/crm_claim_rma/security/ir.model.access.csv @@ -1,7 +1,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_substate_user,substate.substate.user,model_substate_substate,base.group_sale_salesman_all_leads,1,1,1,0 -access_claim_line_user,claim.line.user,model_claim_line,base.group_sale_salesman_all_leads,1,1,1,0 +access_substate_user_salesman_all_leads,substate.substate.user,model_substate_substate,base.group_sale_salesman_all_leads,1,1,1,0 +access_claim_line_user_salesman_all_leads,claim.line.user,model_claim_line,base.group_sale_salesman_all_leads,1,1,1,0 access_substate_manager,substate.substate.manager,model_substate_substate,base.group_sale_manager,1,1,1,1 access_claim_line_manager,claim.line.manager,model_claim_line,base.group_sale_manager,1,1,1,1 -access_substate_user,substate.substate.user,model_substate_substate,base.group_sale_salesman,1,1,1,0 -access_claim_line_user,claim.line.user,model_claim_line,base.group_sale_salesman,1,1,1,0 +access_substate_user_salesman,substate.substate.user,model_substate_substate,base.group_sale_salesman,1,1,1,0 +access_claim_line_user_salesman,claim.line.user,model_claim_line,base.group_sale_salesman,1,1,1,0 diff --git a/crm_claim_rma/tests/test_picking_creation.py b/crm_claim_rma/tests/test_picking_creation.py index f0bdcf6a..21b8fcaf 100644 --- a/crm_claim_rma/tests/test_picking_creation.py +++ b/crm_claim_rma/tests/test_picking_creation.py @@ -21,6 +21,7 @@ # ############################################################################## from openerp.tests import common +from openerp.tools import safe_eval class TestPickingCreation(common.TransactionCase): @@ -185,7 +186,7 @@ class TestPickingCreation(common.TransactionCase): self.assertTrue(res) self.assertEquals(res['res_model'], 'account.invoice') - self.assertEquals(eval(res['context'])['type'], 'out_refund') + self.assertEquals(safe_eval(res['context'])['type'], 'out_refund') def test_04_display_name(self): """ diff --git a/crm_claim_rma/views/crm_claim.xml b/crm_claim_rma/views/crm_claim.xml index c886c29a..e6eb6c58 100644 --- a/crm_claim_rma/views/crm_claim.xml +++ b/crm_claim_rma/views/crm_claim.xml @@ -63,6 +63,7 @@ CRM - Claim product return Form crm.claim + 99 diff --git a/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return.py b/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return.py index 4edfd2cc..70d93df1 100644 --- a/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return.py +++ b/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return.py @@ -95,7 +95,7 @@ class TestCrmRmaLotMassReturn(TransactionCase): self.assertEqual(len(lines_list_id), int(self.invoice_id.invoice_line.quantity)) - wizard_id._set_message() + wizard_id._compute_set_message() wizard_id.add_claim_lines() diff --git a/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return_2.py b/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return_2.py index 22e40f3f..9ab0d757 100644 --- a/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return_2.py +++ b/crm_rma_lot_mass_return/tests/test_crm_rma_lot_mass_return_2.py @@ -92,7 +92,7 @@ class TestCrmRmaLotMassReturn2(TransactionCase): # Validate it has exactly as much records as the taken invoice has self.assertEqual(len(lines_list_id), int(qty)) - wizard_id._set_message() + wizard_id._compute_set_message() wizard_id.add_claim_lines() # 2 Macs @@ -200,7 +200,7 @@ class TestCrmRmaLotMassReturn2(TransactionCase): wizard_id.lines_list_id = [(6, 0, [clw_id.id])] self.assertEqual(len(lines_list_id), 1) - wizard_id._set_message() + wizard_id._compute_set_message() wizard_id.add_claim_lines() self.assertEqual(len(self.claim_id_2.claim_line_ids), 1) diff --git a/crm_rma_lot_mass_return/wizards/returned_lines_from_serial.py b/crm_rma_lot_mass_return/wizards/returned_lines_from_serial.py index 9d972fb0..57220ae8 100644 --- a/crm_rma_lot_mass_return/wizards/returned_lines_from_serial.py +++ b/crm_rma_lot_mass_return/wizards/returned_lines_from_serial.py @@ -39,7 +39,7 @@ class ClaimLineWizard(models.TransientModel): required=True, string="Invoice Line", help="Invoice Line") - name = fields.Char(compute="_get_complete_name", + name = fields.Char(compute="_compute_get_complete_name", string="Complete Lot Name",) @api.constrains('product_id', 'invoice_line_id') @@ -47,14 +47,14 @@ class ClaimLineWizard(models.TransientModel): for record in self: if record.product_id != \ record.invoice_line_id.product_id: - raise ValidationError("The product of the" - " invoice %s is not same" - " that product %s" % + raise ValidationError(_("The product of the" + " invoice %s is not same" + " that product %s" % (record.invoice_line_id.product_id.name, - record.product_id.name)) + record.product_id.name))) @api.depends('invoice_line_id', 'lot_id', 'product_id') - def _get_complete_name(self): + def _compute_get_complete_name(self): for wizard in self: invoice_number = wizard.invoice_line_id.invoice_id.number product_name = wizard.product_id.name @@ -534,14 +534,10 @@ class ReturnedLinesFromSerial(models.TransientModel): self.env[ 'claim.line']._get_subject(num), product_id, clw_id, 1, name) - - # Clean items in wizard model - if len(clw_ids) == 1: - ids_to_delete = "(%s)" % str(clw_ids[0].id) - else: - ids_to_delete = "%s" % str(tuple([clw.id for clw in clw_ids])) - self._cr.execute("DELETE FROM claim_line_wizard where id IN %s" - % ids_to_delete) + ids_to_delete = tuple([clw.id for clw in clw_ids]) + self._cr.execute( + "DELETE FROM claim_line_wizard where id IN %s", + (ids_to_delete, )) # normal execution self.action_cancel() @@ -555,11 +551,11 @@ class ReturnedLinesFromSerial(models.TransientModel): } message = fields.Text(string='Message', - compute='_set_message' + compute='_compute_set_message' ) @api.depends('current_status', 'lines_list_id', 'scan_data') - def _set_message(self): + def _compute_set_message(self): """ Notify for missing (not added) claim lines that are in use in others claims diff --git a/crm_rma_prodlot_invoice/models/stock_production_lot.py b/crm_rma_prodlot_invoice/models/stock_production_lot.py index 0cbceb0a..fbc66b93 100644 --- a/crm_rma_prodlot_invoice/models/stock_production_lot.py +++ b/crm_rma_prodlot_invoice/models/stock_production_lot.py @@ -31,11 +31,11 @@ class StockProductionLot(models.Model): help="Invoice Line Of " "Product to Customer Invoice") - lot_complete_name = fields.Char(compute="_get_lot_complete_name", + lot_complete_name = fields.Char(compute="_compute_get_lot_complete_name", string="Complete Lot Name") @api.depends('invoice_line_id', 'name') - def _get_lot_complete_name(self): + def _compute_get_lot_complete_name(self): name = _("%s - Lot Number: %s - %s") % \ (self.invoice_line_id.invoice_id.number, self.name or _('No lot number'), diff --git a/crm_rma_prodlot_invoice/tests/test_crm_rma_prodlot_invoice.py b/crm_rma_prodlot_invoice/tests/test_crm_rma_prodlot_invoice.py index c58d34eb..81761aec 100644 --- a/crm_rma_prodlot_invoice/tests/test_crm_rma_prodlot_invoice.py +++ b/crm_rma_prodlot_invoice/tests/test_crm_rma_prodlot_invoice.py @@ -183,7 +183,7 @@ class TestCrmRmaProdLotInvoice(TransactionCase): 'name': 'Lot for %s' % (purchase_order_id.name), 'product_id': self.product_id.id, }) - lot_id._get_lot_complete_name() + lot_id._compute_get_lot_complete_name() self.do_whole_transfer_process( lot_id=lot_id, diff --git a/crm_rma_stock_location/models/product_product.py b/crm_rma_stock_location/models/product_product.py index 719606cf..d510f0af 100644 --- a/crm_rma_stock_location/models/product_product.py +++ b/crm_rma_stock_location/models/product_product.py @@ -19,7 +19,7 @@ # ############################################################################## -from openerp import _, api, fields, models +from openerp import api, fields, models import openerp.addons.decimal_precision as dp from openerp.tools.float_utils import float_round from openerp.tools.safe_eval import safe_eval as eval @@ -30,16 +30,16 @@ class ProductProduct(models.Model): _inherit = 'product.product' rma_qty_available = fields.Float( - compute='_rma_product_available', + compute='_compute_rma_product_available', digits_compute=dp.get_precision('Product Unit of Measure'), search='_search_rma_product_quantity', - string=_('RMA Quantity On Hand')) + string='RMA Quantity On Hand') rma_virtual_available = fields.Float( - compute='_rma_product_available', + compute='_compute_rma_product_available', digits_compute=dp.get_precision('Product Unit of Measure'), search='_search_rma_product_quantity', - string=_('RMA Forecasted Quantity')) + string='RMA Forecasted Quantity') def _search_rma_product_quantity(self, operator, value): res = [] @@ -65,7 +65,7 @@ class ProductProduct(models.Model): return res @api.multi - def _rma_product_available(self): + def _compute_rma_product_available(self): """ Finds the incoming and outgoing quantity of product for the RMA locations. diff --git a/crm_rma_stock_location/models/product_template.py b/crm_rma_stock_location/models/product_template.py index 5b922747..434e76e2 100644 --- a/crm_rma_stock_location/models/product_template.py +++ b/crm_rma_stock_location/models/product_template.py @@ -21,7 +21,7 @@ # ############################################################################## -from openerp import _, api, fields, models +from openerp import api, fields, models import openerp.addons.decimal_precision as dp @@ -29,20 +29,20 @@ class ProductTemplate(models.Model): _inherit = 'product.template' - rma_qty_available = fields.Float(compute='_rma_template_available', - digits_compute=dp. - get_precision('Product Unit ' - 'of Measure'), - string=_('RMA Quantity On Hand')) + rma_qty_available = fields.Float( + compute='_compute_rma_template_available', + digits_compute=dp.get_precision('Product Unit of Measure'), + string='RMA Quantity On Hand', + ) - rma_virtual_available = fields.Float(compute='_rma_template_available', - digits_compute=dp. - get_precision('Product Unit' - ' of Measure'), - string=_('RMA Forecasted Quantity')) + rma_virtual_available = fields.Float( + compute='_compute_rma_template_available', + digits_compute=dp.get_precision('Product Unit of Measure'), + string='RMA Forecasted Quantity', + ) @api.multi - def _rma_template_available(self): + def _compute_rma_template_available(self): for product in self: product.rma_qty_available = sum( product.mapped('product_variant_ids.rma_virtual_available')) diff --git a/crm_rma_stock_location/tests/test_crm_rma_stock_location.py b/crm_rma_stock_location/tests/test_crm_rma_stock_location.py index f743eff3..ab499192 100644 --- a/crm_rma_stock_location/tests/test_crm_rma_stock_location.py +++ b/crm_rma_stock_location/tests/test_crm_rma_stock_location.py @@ -23,6 +23,7 @@ from openerp.tests.common import TransactionCase class TestCrmRmaStockLocation(TransactionCase): + post_install = True def setUp(self): super(TestCrmRmaStockLocation, self).setUp() diff --git a/crm_rma_stock_location/tests/test_make_picking_from_picking.py b/crm_rma_stock_location/tests/test_make_picking_from_picking.py index c39ebbe4..1fa30c19 100644 --- a/crm_rma_stock_location/tests/test_make_picking_from_picking.py +++ b/crm_rma_stock_location/tests/test_make_picking_from_picking.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## - +from openerp.tools.safe_eval import safe_eval from openerp.tests.common import TransactionCase @@ -133,9 +133,10 @@ class TestPickingFromPicking(TransactionCase): } wizard_id = self.wizardmakepicking.with_context(new_context).create({}) - default_location_dest_id = eval( + default_location_dest_id = safe_eval( 'self.claim_id.warehouse_id.' - 'rma_%s_type_id.default_location_dest_id' % picking_type_str) + 'rma_%s_type_id.default_location_dest_id' % picking_type_str, + {'self': self}) self.assertEquals( wizard_id.claim_line_dest_location_id, default_location_dest_id) @@ -153,7 +154,8 @@ class TestPickingFromPicking(TransactionCase): } wizard_id = self.wizardmakepicking.with_context(new_context).create({}) - default_location_dest_id = eval( - 'self.claim_id.warehouse_id.loss_loc_id') + default_location_dest_id = safe_eval( + 'self.claim_id.warehouse_id.loss_loc_id', + {'self': self}) self.assertEquals( wizard_id.claim_line_dest_location_id, default_location_dest_id) diff --git a/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py b/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py index d33c0ac8..5a308641 100644 --- a/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py +++ b/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py @@ -21,7 +21,7 @@ # ############################################################################## -from openerp import _, models, fields, api +from openerp import models, fields, api from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp import workflow import time @@ -82,12 +82,12 @@ class ClaimMakePickingFromPicking(models.TransientModel): return loc_id picking_line_source_location = fields.Many2one( - 'stock.location', _('Source Location'), - help=_("Source location where the returned products are"), + 'stock.location', 'Source Location', + help="Source location where the returned products are", required=True, default=_get_source_loc) picking_line_dest_location = fields.Many2one( - 'stock.location', _('Dest. Location'), - help=_("Target location to send returned products"), + 'stock.location', 'Dest. Location', + help="Target location to send returned products", required=True, default=_get_dest_loc) picking_line_ids = fields.Many2many( 'stock.move', 'claim_picking_line_picking', 'claim_picking_id', diff --git a/product_warranty/__openerp__.py b/product_warranty/__openerp__.py index 77f075cb..018a28cb 100644 --- a/product_warranty/__openerp__.py +++ b/product_warranty/__openerp__.py @@ -39,6 +39,5 @@ ], 'test': [], 'installable': True, - 'active': False, 'images': ['images/product_warranty.png'], } diff --git a/product_warranty/models/product_supplierinfo.py b/product_warranty/models/product_supplierinfo.py index fcc7b0fc..4aacd15d 100644 --- a/product_warranty/models/product_supplierinfo.py +++ b/product_warranty/models/product_supplierinfo.py @@ -43,26 +43,25 @@ class ProductSupplierInfo(models.Model): .search([('is_default', '=', True)], limit=1) return instruction_ids - @api.one + @api.multi @api.depends('warranty_return_partner') def _compute_warranty_return_address(self): """ Method to return the partner delivery address or if none, the default address """ - return_partner = self.warranty_return_partner - partner_id = self.company_id.partner_id.id - if return_partner: - if return_partner == 'supplier': - partner_id = self.name.id - elif return_partner == 'company': - if self.company_id.crm_return_address_id: - partner_id = self.company_id.\ - crm_return_address_id.id - elif return_partner == 'other': - if self.warranty_return_other_address: - partner_id = self.\ - warranty_return_other_address.id - self.warranty_return_address = partner_id + for rec in self: + return_partner = rec.warranty_return_partner + partner_id = rec.company_id.partner_id.id + if return_partner: + if return_partner == 'supplier': + partner_id = rec.name.id + elif return_partner == 'company': + if rec.company_id.crm_return_address_id: + partner_id = rec.company_id.crm_return_address_id.id + elif return_partner == 'other': + if rec.warranty_return_other_address: + partner_id = rec.warranty_return_other_address.id + rec.warranty_return_address = partner_id warranty_duration = fields.Float( 'Period', diff --git a/product_warranty/tests/test_product_warranty.py b/product_warranty/tests/test_product_warranty.py index b6eb670c..621cbc56 100644 --- a/product_warranty/tests/test_product_warranty.py +++ b/product_warranty/tests/test_product_warranty.py @@ -45,6 +45,7 @@ class TestProductWarranty(TransactionCase): min_qty=4, delay=5, warranty_return_partner='supplier', + warranty_return_other_address=partner_id.id, product_tmpl_id=product_tmpl_id.id,) self.supplierinfo_brw = \ self.supplierinfo.create(supplierinfo_data) @@ -78,3 +79,8 @@ class TestProductWarranty(TransactionCase): self.assertEquals(self.supplierinfo_brw.warranty_return_address.id, self.supplierinfo_brw.company_id. crm_return_address_id.id) + + self.supplierinfo_brw.write({'warranty_return_partner': 'other'}) + self.assertEquals( + self.supplierinfo_brw.warranty_return_address.id, + self.supplierinfo_brw.warranty_return_other_address.id)