From 0f917165508264e8baa00ba433191c31c9953a36 Mon Sep 17 00:00:00 2001 From: sergio-teruel Date: Wed, 17 Feb 2021 16:08:55 +0100 Subject: [PATCH] [IMP] stock_picking_report_undelivered_product: black, isort --- .../__manifest__.py | 14 +- .../models/product_template.py | 5 +- .../models/res_config_settings.py | 36 ++-- .../models/res_partner.py | 5 +- .../models/stock_move.py | 8 +- ...tock_picking_report_undelivered_product.py | 196 ++++++++++-------- 6 files changed, 150 insertions(+), 114 deletions(-) diff --git a/stock_picking_report_undelivered_product/__manifest__.py b/stock_picking_report_undelivered_product/__manifest__.py index 90ac16e..be63486 100644 --- a/stock_picking_report_undelivered_product/__manifest__.py +++ b/stock_picking_report_undelivered_product/__manifest__.py @@ -9,14 +9,12 @@ "website": "https://www.tecnativa.com", "category": "Warehouse", "license": "AGPL-3", - "depends": [ - "stock", - ], + "depends": ["stock"], "data": [ - 'views/product_views.xml', - 'views/report_deliveryslip.xml', - 'views/res_config_settings_views.xml', - 'views/res_partner_view.xml', + "views/product_views.xml", + "views/report_deliveryslip.xml", + "views/res_config_settings_views.xml", + "views/res_partner_view.xml", ], - 'installable': True, + "installable": True, } diff --git a/stock_picking_report_undelivered_product/models/product_template.py b/stock_picking_report_undelivered_product/models/product_template.py index 6a1b0dd..e9090d0 100644 --- a/stock_picking_report_undelivered_product/models/product_template.py +++ b/stock_picking_report_undelivered_product/models/product_template.py @@ -5,9 +5,8 @@ from odoo import fields, models class ProductTemplate(models.Model): - _inherit = 'product.template' + _inherit = "product.template" display_undelivered_in_picking = fields.Boolean( - string='Display undelivered in picking', - default=True, + string="Display undelivered in picking", default=True ) diff --git a/stock_picking_report_undelivered_product/models/res_config_settings.py b/stock_picking_report_undelivered_product/models/res_config_settings.py index 0a4b3cb..a67c968 100644 --- a/stock_picking_report_undelivered_product/models/res_config_settings.py +++ b/stock_picking_report_undelivered_product/models/res_config_settings.py @@ -5,17 +5,21 @@ from odoo import fields, models class ResConfigSettings(models.TransientModel): - _inherit = 'res.config.settings' + _inherit = "res.config.settings" undelivered_product_slip_report_method = fields.Selection( [ - ('all', 'Display all undelivered product lines'), - ('partially_undelivered', - 'Display only partially undelivered product lines'), - ('completely_undelivered', - 'Display only completely undelivered product lines'), + ("all", "Display all undelivered product lines"), + ( + "partially_undelivered", + "Display only partially undelivered product lines", + ), + ( + "completely_undelivered", + "Display only completely undelivered product lines", + ), ], - string='Method to display undelivered product lines in report picking', + string="Method to display undelivered product lines in report picking", related="company_id.undelivered_product_slip_report_method", readonly=False, ) @@ -26,12 +30,16 @@ class Company(models.Model): undelivered_product_slip_report_method = fields.Selection( [ - ('all', 'Display all undelivered product lines'), - ('partially_undelivered', - 'Display only partially undelivered product lines'), - ('completely_undelivered', - 'Display only completely undelivered product lines'), + ("all", "Display all undelivered product lines"), + ( + "partially_undelivered", + "Display only partially undelivered product lines", + ), + ( + "completely_undelivered", + "Display only completely undelivered product lines", + ), ], - string='Method to display undelivered product lines in report picking', - default='all' + string="Method to display undelivered product lines in report picking", + default="all", ) diff --git a/stock_picking_report_undelivered_product/models/res_partner.py b/stock_picking_report_undelivered_product/models/res_partner.py index fd76573..9443efe 100644 --- a/stock_picking_report_undelivered_product/models/res_partner.py +++ b/stock_picking_report_undelivered_product/models/res_partner.py @@ -5,9 +5,8 @@ from odoo import fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" display_undelivered_in_picking = fields.Boolean( - string='Display undelivered in picking', - default=True, + string="Display undelivered in picking", default=True ) diff --git a/stock_picking_report_undelivered_product/models/stock_move.py b/stock_picking_report_undelivered_product/models/stock_move.py index 29419ab..d6efae3 100644 --- a/stock_picking_report_undelivered_product/models/stock_move.py +++ b/stock_picking_report_undelivered_product/models/stock_move.py @@ -5,12 +5,10 @@ from odoo import fields, models class StockMove(models.Model): - _inherit = 'stock.move' + _inherit = "stock.move" splitted_stock_move_orig_id = fields.Many2one( - comodel_name='stock.move', - string="Splitted from", - readonly=True, + comodel_name="stock.move", string="Splitted from", readonly=True ) def _prepare_move_split_vals(self, qty): @@ -18,5 +16,5 @@ class StockMove(models.Model): Store origin stock move which create splitted move. """ vals = super(StockMove, self)._prepare_move_split_vals(qty) - vals['splitted_stock_move_orig_id'] = self.id + vals["splitted_stock_move_orig_id"] = self.id return vals diff --git a/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py b/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py index aa1a8b8..568f0d6 100644 --- a/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py +++ b/stock_picking_report_undelivered_product/tests/test_stock_picking_report_undelivered_product.py @@ -5,50 +5,61 @@ from odoo.tests.common import Form class TestStockPickingReportUndeliveredProduct(common.TransactionCase): - def setUp(self): super().setUp() - self.ResPartner = self.env['res.partner'] - self.ProductProduct = self.env['product.product'] - self.StockPicking = self.env['stock.picking'] - self.StockQuant = self.env['stock.quant'] + self.ResPartner = self.env["res.partner"] + self.ProductProduct = self.env["product.product"] + self.StockPicking = self.env["stock.picking"] + self.StockQuant = self.env["stock.quant"] - self.warehouse = self.env.ref('stock.warehouse0') - self.stock_location = self.env.ref('stock.stock_location_stock') - self.customer_location = self.env.ref('stock.stock_location_customers') - self.picking_type_out = self.env.ref('stock.picking_type_out') + self.warehouse = self.env.ref("stock.warehouse0") + self.stock_location = self.env.ref("stock.stock_location_stock") + self.customer_location = self.env.ref("stock.stock_location_customers") + self.picking_type_out = self.env.ref("stock.picking_type_out") - self.partner_display = self.ResPartner.create({ - 'name': 'Partner for test display', - 'customer': True, - 'display_undelivered_in_picking': True, - }) - self.partner_no_display = self.ResPartner.create({ - 'name': 'Partner for test on display', - 'customer': True, - 'display_undelivered_in_picking': False, - }) + self.partner_display = self.ResPartner.create( + { + "name": "Partner for test display", + "customer": True, + "display_undelivered_in_picking": True, + } + ) + self.partner_no_display = self.ResPartner.create( + { + "name": "Partner for test on display", + "customer": True, + "display_undelivered_in_picking": False, + } + ) - self.product_display = self.ProductProduct.create({ - 'name': 'Test product undelivered display', - 'display_undelivered_in_picking': True, - 'type': 'product', - }) - self.product_no_display = self.ProductProduct.create({ - 'name': 'Test product undelivered no display', - 'display_undelivered_in_picking': False, - 'type': 'product', - }) - self.product_no_display_wo_stock = self.ProductProduct.create({ - 'name': 'Test product undelivered no display without stock', - 'display_undelivered_in_picking': False, - 'type': 'product', - }) - self.StockQuant.create({ - 'product_id': self.product_no_display.id, - 'location_id': self.warehouse.lot_stock_id.id, - 'quantity': 2000, - }) + self.product_display = self.ProductProduct.create( + { + "name": "Test product undelivered display", + "display_undelivered_in_picking": True, + "type": "product", + } + ) + self.product_no_display = self.ProductProduct.create( + { + "name": "Test product undelivered no display", + "display_undelivered_in_picking": False, + "type": "product", + } + ) + self.product_no_display_wo_stock = self.ProductProduct.create( + { + "name": "Test product undelivered no display without stock", + "display_undelivered_in_picking": False, + "type": "product", + } + ) + self.StockQuant.create( + { + "product_id": self.product_no_display.id, + "location_id": self.warehouse.lot_stock_id.id, + "quantity": 2000, + } + ) def _create_picking(self, partner): picking_form = Form(self.StockPicking) @@ -74,9 +85,11 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase): picking.action_done() # Cancel backorder picking.backorder_ids.action_cancel() - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertIn("undelivered_product", str(res[0])) def test_no_displayed_customer(self): @@ -87,42 +100,53 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase): picking.action_done() # Cancel backorder picking.backorder_ids.action_cancel() - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertNotIn("undelivered_product", str(res[0])) def test_no_displayed_product(self): picking = self._create_picking(self.partner_display) picking.move_lines.filtered( - lambda l: l.product_id == self.product_display).unlink() + lambda l: l.product_id == self.product_display + ).unlink() picking.action_confirm() picking.action_assign() picking.move_line_ids.qty_done = 10.00 picking.action_done() # Cancel backorder picking.backorder_ids.action_cancel() - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertNotIn("undelivered_product", str(res[0])) def test_picking_report_method(self): - product = self.ProductProduct.create({ - 'name': 'test01', - 'display_undelivered_in_picking': True, - 'type': 'product', - }) - product2 = self.ProductProduct.create({ - 'name': 'test02', - 'display_undelivered_in_picking': True, - 'type': 'product', - }) - self.StockQuant.create({ - 'product_id': product.id, - 'location_id': self.warehouse.lot_stock_id.id, - 'quantity': 2000, - }) + product = self.ProductProduct.create( + { + "name": "test01", + "display_undelivered_in_picking": True, + "type": "product", + } + ) + product2 = self.ProductProduct.create( + { + "name": "test02", + "display_undelivered_in_picking": True, + "type": "product", + } + ) + self.StockQuant.create( + { + "product_id": product.id, + "location_id": self.warehouse.lot_stock_id.id, + "quantity": 2000, + } + ) picking_form = Form(self.StockPicking) picking_form.picking_type_id = self.picking_type_out picking_form.partner_id = self.partner_display @@ -143,30 +167,40 @@ class TestStockPickingReportUndeliveredProduct(common.TransactionCase): # Empty setting method field picking.company_id.undelivered_product_slip_report_method = False - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertIn("test02", str(res[0])) # Print all undelivered lines, partial and completely lines - picking.company_id.undelivered_product_slip_report_method = 'all' - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + picking.company_id.undelivered_product_slip_report_method = "all" + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertIn("test02", str(res[0])) # Print only partial undelivered lines - picking.company_id.\ - undelivered_product_slip_report_method = 'partially_undelivered' - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + picking.company_id.undelivered_product_slip_report_method = ( + "partially_undelivered" + ) + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertNotIn("test02", str(res[0])) # Print only completely undelivered lines - picking.company_id.\ - undelivered_product_slip_report_method = 'completely_undelivered' - res = self.env['ir.actions.report']._get_report_from_name( - 'stock.report_deliveryslip' - ).render_qweb_html(picking.ids) + picking.company_id.undelivered_product_slip_report_method = ( + "completely_undelivered" + ) + res = ( + self.env["ir.actions.report"] + ._get_report_from_name("stock.report_deliveryslip") + .render_qweb_html(picking.ids) + ) self.assertNotIn("partially_undelivered_line", str(res[0]))