From 82e0ab261de5e8b74629f84d6e84cb92bf751c9f Mon Sep 17 00:00:00 2001 From: majouda Date: Mon, 4 Mar 2024 13:44:41 -0500 Subject: [PATCH] TA#62879 [IMP] Correct flake8 errors --- .../tests/test_product_barcode_upc.py | 2 +- product_dimension/models/product.py | 25 +++++++++++------- .../tests/test_product_template.py | 26 ++++++++++++------- product_dimension/tests/test_weight_in_uom.py | 9 ++++--- .../__manifest__.py | 3 ++- .../wizards/product_pricelist_print.py | 4 +-- .../tests/test_product.py | 2 +- stock_barcode_upc/models/product_product.py | 2 +- 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/product_barcode_upc/tests/test_product_barcode_upc.py b/product_barcode_upc/tests/test_product_barcode_upc.py index c03d99e..67a7ccc 100644 --- a/product_barcode_upc/tests/test_product_barcode_upc.py +++ b/product_barcode_upc/tests/test_product_barcode_upc.py @@ -16,7 +16,7 @@ def setUpClass(cls): "name": "Product Template", "barcode": "123456789", }) - ptal = cls.env['product.template.attribute.line'].create({ + cls.env['product.template.attribute.line'].create({ 'attribute_id': product_attribute.id, 'product_tmpl_id': cls.product_template.id, 'value_ids': [(6, 0, [size_value_l.id])], diff --git a/product_dimension/models/product.py b/product_dimension/models/product.py index 682287f..9ae9fb1 100644 --- a/product_dimension/models/product.py +++ b/product_dimension/models/product.py @@ -73,28 +73,33 @@ def write(self, vals): """ vals_copy = vals.copy() super().write(vals) - - updating_weight_in_uom = 'weight_in_uom' in vals_copy or 'specific_weight_uom_id' in vals_copy - updating_weight_in_uom_from_weight = self._context.get('updating_weight_in_uom_from_weight') - + updating_weight_in_uom = ( + "weight_in_uom" in vals_copy or "specific_weight_uom_id" in vals_copy + ) + updating_weight_in_uom_from_weight = self._context.get( + "updating_weight_in_uom_from_weight" + ) updating_weight = 'weight' in vals_copy - updating_weight_from_weight_in_uom = self._context.get('updating_weight_from_weight_in_uom') - + updating_weight_from_weight_in_uom = self._context.get( + "updating_weight_from_weight_in_uom" + ) if updating_weight_in_uom and not updating_weight_in_uom_from_weight: for record in self: record.update_weight_from_weight_in_uom() - elif updating_weight and not updating_weight_from_weight_in_uom: for record in self: record.update_weight_in_uom_from_weight() - return True def update_weight_from_weight_in_uom(self): """Update the weight in kg from the weight in uom.""" uom_kg = self.env.ref('uom.product_uom_kgm') - weight = self.specific_weight_uom_id._compute_quantity(self.weight_in_uom, uom_kg) - self.with_context(updating_weight_from_weight_in_uom=True).write({'weight': weight}) + weight = self.specific_weight_uom_id._compute_quantity( + self.weight_in_uom, uom_kg + ) + self.with_context(updating_weight_from_weight_in_uom=True).write( + {"weight": weight} + ) def update_weight_in_uom_from_weight(self): """Update the weight in uom from the weight in kg.""" diff --git a/product_dimension/tests/test_product_template.py b/product_dimension/tests/test_product_template.py index 0a9adfc..a0fa430 100644 --- a/product_dimension/tests/test_product_template.py +++ b/product_dimension/tests/test_product_template.py @@ -22,7 +22,7 @@ def setUpClass(cls): cls.volume = 0.3 * 0.4 * 0.5 cls.density = cls.weight / cls.volume - def test_when_creating_product_template_then_dimensions_are_propagated_to_the_variant(self): + def test_create_product_template_with_dimensions_propagated_to_variant(self): self.template = self.env['product.template'].create({ 'name': 'Test Product', 'type': 'product', @@ -43,7 +43,7 @@ def test_when_creating_product_template_then_dimensions_are_propagated_to_the_va self.assertEqual(self.template.product_variant_ids.width, self.width) self.assertEqual(self.template.product_variant_ids.dimension_uom_id, self.cm) - def test_when_creating_product_template_then_weight_in_uom_is_propagated_to_the_variant(self): + def test_create_product_template_with_weight_uom_propagated_to_variant(self): self.template = self.env['product.template'].create({ 'name': 'Test Product', 'type': 'product', @@ -56,11 +56,15 @@ def test_when_creating_product_template_then_weight_in_uom_is_propagated_to_the_ self.assertEqual(self.template.specific_weight_uom_id, self.gram) self.assertEqual(self.template.weight, self.weight) - self.assertEqual(self.template.product_variant_ids.weight_in_uom, self.weight_in_uom) - self.assertEqual(self.template.product_variant_ids.specific_weight_uom_id, self.gram) + self.assertEqual( + self.template.product_variant_ids.weight_in_uom, self.weight_in_uom + ) + self.assertEqual( + self.template.product_variant_ids.specific_weight_uom_id, self.gram + ) self.assertEqual(self.template.product_variant_ids.weight, self.weight) - def test_when_creating_product_template_then_weight_is_propagated_to_the_variant(self): + def test_create_product_template_with_weight_propagated_to_variant(self): self.template = self.env['product.template'].create({ 'name': 'Test Product', 'type': 'product', @@ -73,10 +77,12 @@ def test_when_creating_product_template_then_weight_is_propagated_to_the_variant self.assertEqual(self.template.weight, 1) self.assertEqual(self.template.product_variant_ids.weight_in_uom, 1) - self.assertEqual(self.template.product_variant_ids.specific_weight_uom_id, self.kg) + self.assertEqual( + self.template.product_variant_ids.specific_weight_uom_id, self.kg + ) self.assertEqual(self.template.product_variant_ids.weight, 1) - def test_when_creating_product_template_then_volume_is_computed_on_the_variant(self): + def test_create_product_template_with_volume_computed_on_variant(self): self.template = self.env['product.template'].create({ 'name': 'Test Product', 'type': 'product', @@ -91,7 +97,7 @@ def test_when_creating_product_template_then_volume_is_computed_on_the_variant(s self.assertAlmostEqual(self.template.volume, self.volume, 2) self.assertAlmostEqual(self.template.product_variant_ids.volume, self.volume, 2) - def test_when_creating_product_template_then_density_is_computed_on_the_variant(self): + def test_create_product_template_then_density_computed_on_variant(self): self.template = self.env['product.template'].create({ 'name': 'Test Product', 'type': 'product', @@ -106,4 +112,6 @@ def test_when_creating_product_template_then_density_is_computed_on_the_variant( self.template.refresh() self.assertAlmostEqual(self.template.density, self.density, 2) - self.assertAlmostEqual(self.template.product_variant_ids.density, self.density, 2) + self.assertAlmostEqual( + self.template.product_variant_ids.density, self.density, 2 + ) diff --git a/product_dimension/tests/test_weight_in_uom.py b/product_dimension/tests/test_weight_in_uom.py index 1540bef..d86a539 100644 --- a/product_dimension/tests/test_weight_in_uom.py +++ b/product_dimension/tests/test_weight_in_uom.py @@ -27,7 +27,7 @@ def test_when_update_weight_then_weight_in_uom_is_updated(self): self.assertEqual(self.product.weight_in_uom, 10) self.assertEqual(self.product.specific_weight_uom_id, self.kg) - def test_when_update_weight_if_has_weight_uom_then_specific_weight_uom_id_is_not_changed(self): + def test_update_weight_if_weight_uom_then_not_changed(self): """Test that when the weight is set, the current uom on the product is kept.""" self.product.specific_weight_uom_id = self.gram @@ -39,7 +39,7 @@ def test_when_update_weight_if_has_weight_uom_then_specific_weight_uom_id_is_not self.assertEqual(self.product.specific_weight_uom_id, self.gram) def test_when_update_weight_in_uom_then_weight_is_updated(self): - """Test that when the weight in uom is set, then the weight in kg is also updated.""" + """Test that when the weight in uom is set, then the weight in kg is updated.""" self.product.write({ 'weight_in_uom': 10 * 1000, 'specific_weight_uom_id': self.gram.id, @@ -51,7 +51,7 @@ def test_when_update_weight_in_uom_then_weight_is_updated(self): self.assertEqual(self.product.specific_weight_uom_id, self.gram) def test_on_write_weight_in_uom_supersedes_weight(self): - """Test that on write, if weight and weight_in_uom are given, weight_in_uom is kept.""" + """Test on write if weight and weight_in_uom are given weight_in_uom is kept.""" self.product.write({ 'weight': 9, 'weight_in_uom': 10 * 1000, @@ -91,7 +91,8 @@ def test_on_create_if_weight_in_uom_is_given_then_weight_is_set(self): self.assertEqual(product.specific_weight_uom_id, self.gram) def test_on_create_weight_in_uom_supersedes_weight(self): - """Test that on create, if weight and weight_in_uom are given, weight_in_uom is kept.""" + """Test on create if weight and weight_in_uom are + given weight_in_uom is kept.""" product = self.env['product.product'].create({ 'name': 'New Product', 'type': 'product', diff --git a/product_manufacturer_quick_search/__manifest__.py b/product_manufacturer_quick_search/__manifest__.py index 0b7221a..13c7c24 100644 --- a/product_manufacturer_quick_search/__manifest__.py +++ b/product_manufacturer_quick_search/__manifest__.py @@ -10,7 +10,8 @@ "license": "AGPL-3", "category": "Product", "depends": ["product_manufacturer"], - "summary": "Add a quick search for items using their manufacturer name or code, as well as the manufacturer name.", + "summary": """Add a quick search for items using their manufacturer name or code, + as well as the manufacturer name.""", "data": [ "views/product_template.xml", ], diff --git a/product_pricelist_direct_print_chatter/wizards/product_pricelist_print.py b/product_pricelist_direct_print_chatter/wizards/product_pricelist_print.py index a128fad..fd7e77f 100755 --- a/product_pricelist_direct_print_chatter/wizards/product_pricelist_print.py +++ b/product_pricelist_direct_print_chatter/wizards/product_pricelist_print.py @@ -2,7 +2,7 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). import base64 -from odoo import api, models +from odoo import models from odoo.addons.product_pricelist_direct_print_extended.wizards.\ product_pricelist_print import ProductPricelistPrint @@ -26,7 +26,7 @@ class ProductPricelistPrintChatter(models.TransientModel): def generate_report(self, template_id): report = self.env.ref( 'product_pricelist_direct_print.action_report_product_pricelist') - result, _ = report._render_qweb_pdf([self.id]) + result, _ = report._render_qweb_pdf([self.id]) result = base64.b64encode(result) new_attachment_id = self.env['ir.attachment'].create({ 'name': self.pricelist_id.name, diff --git a/product_purchase_order_link/tests/test_product.py b/product_purchase_order_link/tests/test_product.py index bb44516..2e51558 100644 --- a/product_purchase_order_link/tests/test_product.py +++ b/product_purchase_order_link/tests/test_product.py @@ -5,7 +5,7 @@ class TestProduct(common.SavepointCase): - + @classmethod def setUpClass(cls): super().setUpClass() diff --git a/stock_barcode_upc/models/product_product.py b/stock_barcode_upc/models/product_product.py index 6d5d1ee..5269bc5 100644 --- a/stock_barcode_upc/models/product_product.py +++ b/stock_barcode_upc/models/product_product.py @@ -1,7 +1,7 @@ # © 2022 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import api, models class ProductProduct(models.Model):