From 32b569ee4ce5176ff2964d65b632418cb0596f91 Mon Sep 17 00:00:00 2001 From: Chafique Date: Sun, 6 Jun 2021 19:21:31 +0200 Subject: [PATCH] [IMP] rma: black, isort, prettier --- rma/__manifest__.py | 2 +- rma/hooks.py | 4 +- rma/models/account_move.py | 9 +- rma/models/res_config_settings.py | 6 +- rma/models/res_partner.py | 14 ++- rma/models/rma.py | 143 +++++++++++++++++++---------- rma/models/rma_tag.py | 7 +- rma/models/rma_team.py | 9 +- rma/models/stock_move.py | 20 ++-- rma/models/stock_picking.py | 10 +- rma/models/stock_warehouse.py | 15 ++- rma/tests/test_rma.py | 43 ++++++--- rma/wizard/rma_delivery.py | 10 +- rma/wizard/rma_split.py | 9 +- rma/wizard/stock_picking_return.py | 2 +- 15 files changed, 209 insertions(+), 94 deletions(-) diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 33e9ed8a..36e6185c 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management", "summary": "Return Merchandise Authorization (RMA)", - "version": "13.0.1.2.0", + "version": "14.0.1.0.0", "development_status": "Production/Stable", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma/hooks.py b/rma/hooks.py index dbdbf75a..9aafcaf0 100644 --- a/rma/hooks.py +++ b/rma/hooks.py @@ -50,7 +50,9 @@ def post_init_hook(cr, registry): picking_sequence = sequence_data[picking_type] sequence = ir_sequence_sudo.create(picking_sequence) values.update( - warehouse_id=whs.id, color=color, sequence_id=sequence.id, + warehouse_id=whs.id, + color=color, + sequence_id=sequence.id, ) data[picking_type] = stock_picking_type.create(values).id diff --git a/rma/models/account_move.py b/rma/models/account_move.py index 7c8d0af8..d71aeca4 100644 --- a/rma/models/account_move.py +++ b/rma/models/account_move.py @@ -11,7 +11,7 @@ class AccountMove(models.Model): def _check_rma_invoice_lines_qty(self): """We can't refund a different qty than the stated in the RMA. - Extend to change criteria """ + Extend to change criteria""" precision = self.env["decimal.precision"].precision_get( "Product Unit of Measure" ) @@ -28,7 +28,7 @@ class AccountMove(models.Model): ) def post(self): - """ Avoids to validate a refund with less quantity of product than + """Avoids to validate a refund with less quantity of product than quantity in the linked RMA. """ if self._check_rma_invoice_lines_qty(): @@ -49,4 +49,7 @@ class AccountMove(models.Model): class AccountMoveLine(models.Model): _inherit = "account.move.line" - rma_id = fields.Many2one(comodel_name="rma", string="RMA",) + rma_id = fields.Many2one( + comodel_name="rma", + string="RMA", + ) diff --git a/rma/models/res_config_settings.py b/rma/models/res_config_settings.py index d18ce044..303044cb 100644 --- a/rma/models/res_config_settings.py +++ b/rma/models/res_config_settings.py @@ -7,8 +7,10 @@ class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" send_rma_confirmation = fields.Boolean( - related="company_id.send_rma_confirmation", readonly=False, + related="company_id.send_rma_confirmation", + readonly=False, ) rma_mail_confirmation_template_id = fields.Many2one( - related="company_id.rma_mail_confirmation_template_id", readonly=False, + related="company_id.rma_mail_confirmation_template_id", + readonly=False, ) diff --git a/rma/models/res_partner.py b/rma/models/res_partner.py index 45ff8f1b..d6bed155 100644 --- a/rma/models/res_partner.py +++ b/rma/models/res_partner.py @@ -8,9 +8,14 @@ class ResPartner(models.Model): _inherit = "res.partner" rma_ids = fields.One2many( - comodel_name="rma", inverse_name="partner_id", string="RMAs", + comodel_name="rma", + inverse_name="partner_id", + string="RMAs", + ) + rma_count = fields.Integer( + string="RMA count", + compute="_compute_rma_count", ) - rma_count = fields.Integer(string="RMA count", compute="_compute_rma_count",) def _compute_rma_count(self): rma_data = self.env["rma"].read_group( @@ -26,7 +31,10 @@ class ResPartner(models.Model): rma = self.rma_ids if len(rma) == 1: action.update( - res_id=rma.id, view_mode="form", view_id=False, views=False, + res_id=rma.id, + view_mode="form", + view_id=False, + views=False, ) else: action["domain"] = [("partner_id", "in", self.ids)] diff --git a/rma/models/rma.py b/rma/models/rma.py index c125f93d..e4017eca 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -90,7 +90,8 @@ class Rma(models.Model): help="Refund address for current RMA.", ) commercial_partner_id = fields.Many2one( - comodel_name="res.partner", related="partner_id.commercial_partner_id", + comodel_name="res.partner", + related="partner_id.commercial_partner_id", ) picking_id = fields.Many2one( comodel_name="stock.picking", @@ -114,7 +115,8 @@ class Rma(models.Model): states={"draft": [("readonly", False)]}, ) product_id = fields.Many2one( - comodel_name="product.product", domain=[("type", "in", ["consu", "product"])], + comodel_name="product.product", + domain=[("type", "in", ["consu", "product"])], ) product_uom_qty = fields.Float( string="Quantity", @@ -150,7 +152,8 @@ class Rma(models.Model): states={"draft": [("readonly", False)]}, ) operation_id = fields.Many2one( - comodel_name="rma.operation", string="Requested operation", + comodel_name="rma.operation", + string="Requested operation", ) state = fields.Selection( [ @@ -180,14 +183,21 @@ class Rma(models.Model): states={"draft": [("readonly", False)]}, ) warehouse_id = fields.Many2one( - comodel_name="stock.warehouse", compute="_compute_warehouse_id", store=True, + comodel_name="stock.warehouse", + compute="_compute_warehouse_id", + store=True, ) reception_move_id = fields.Many2one( - comodel_name="stock.move", string="Reception move", copy=False, + comodel_name="stock.move", + string="Reception move", + copy=False, ) # Refund fields refund_id = fields.Many2one( - comodel_name="account.move", string="Refund", readonly=True, copy=False, + comodel_name="account.move", + string="Refund", + readonly=True, + copy=False, ) refund_line_id = fields.Many2one( comodel_name="account.move.line", @@ -205,7 +215,8 @@ class Rma(models.Model): copy=False, ) delivery_picking_count = fields.Integer( - string="Delivery count", compute="_compute_delivery_picking_count", + string="Delivery count", + compute="_compute_delivery_picking_count", ) delivered_qty = fields.Float( string="Delivered qty", @@ -219,9 +230,15 @@ class Rma(models.Model): compute="_compute_delivered_qty", compute_sudo=True, ) - can_be_returned = fields.Boolean(compute="_compute_can_be_returned",) - can_be_replaced = fields.Boolean(compute="_compute_can_be_replaced",) - can_be_locked = fields.Boolean(compute="_compute_can_be_locked",) + can_be_returned = fields.Boolean( + compute="_compute_can_be_returned", + ) + can_be_replaced = fields.Boolean( + compute="_compute_can_be_replaced", + ) + can_be_locked = fields.Boolean( + compute="_compute_can_be_locked", + ) remaining_qty = fields.Float( string="Remaining delivered qty", digits="Product Unit of Measure", @@ -233,9 +250,14 @@ class Rma(models.Model): compute="_compute_remaining_qty", ) # Split fields - can_be_split = fields.Boolean(compute="_compute_can_be_split",) + can_be_split = fields.Boolean( + compute="_compute_can_be_split", + ) origin_split_rma_id = fields.Many2one( - comodel_name="rma", string="Extracted from", readonly=True, copy=False, + comodel_name="rma", + string="Extracted from", + readonly=True, + copy=False, ) def _compute_delivery_picking_count(self): @@ -263,7 +285,7 @@ class Rma(models.Model): "product_uom", ) def _compute_delivered_qty(self): - """ Compute 'delivered_qty' and 'delivered_qty_done' fields. + """Compute 'delivered_qty' and 'delivered_qty_done' fields. delivered_qty: represents the quantity delivery or to be delivery. For each move in delivery_move_ids the quantity done @@ -301,7 +323,7 @@ class Rma(models.Model): @api.depends("product_uom_qty", "delivered_qty", "delivered_qty_done") def _compute_remaining_qty(self): - """ Compute 'remaining_qty' and 'remaining_qty_to_done' fields. + """Compute 'remaining_qty' and 'remaining_qty_to_done' fields. remaining_qty: is used to set a default quantity of replacing or returning of product to the customer. @@ -316,9 +338,11 @@ class Rma(models.Model): r.remaining_qty = r.product_uom_qty - r.delivered_qty r.remaining_qty_to_done = r.product_uom_qty - r.delivered_qty_done - @api.depends("state",) + @api.depends( + "state", + ) def _compute_can_be_refunded(self): - """ Compute 'can_be_refunded'. This field controls the visibility + """Compute 'can_be_refunded'. This field controls the visibility of 'Refund' button in the rma form view and determinates if an rma can be refunded. It is used in rma.action_refund method. """ @@ -327,7 +351,7 @@ class Rma(models.Model): @api.depends("remaining_qty", "state") def _compute_can_be_returned(self): - """ Compute 'can_be_returned'. This field controls the visibility + """Compute 'can_be_returned'. This field controls the visibility of the 'Return to customer' button in the rma form view and determinates if an rma can be returned to the customer. This field is used in: @@ -341,7 +365,7 @@ class Rma(models.Model): @api.depends("state") def _compute_can_be_replaced(self): - """ Compute 'can_be_replaced'. This field controls the visibility + """Compute 'can_be_replaced'. This field controls the visibility of 'Replace' button in the rma form view and determinates if an rma can be replaced. This field is used in: @@ -357,7 +381,7 @@ class Rma(models.Model): @api.depends("product_uom_qty", "state", "remaining_qty", "remaining_qty_to_done") def _compute_can_be_split(self): - """ Compute 'can_be_split'. This field controls the + """Compute 'can_be_split'. This field controls the visibility of 'Split' button in the rma form view and determinates if an rma can be split. This field is used in: @@ -397,7 +421,7 @@ class Rma(models.Model): "state", "partner_id", "partner_shipping_id", "partner_invoice_id", "product_id" ) def _check_required_after_draft(self): - """ Check that RMAs are being created or edited with the + """Check that RMAs are being created or edited with the necessary fields filled out. Only applies to 'Draft' and 'Cancelled' states. """ @@ -576,7 +600,8 @@ class Rma(models.Model): origin = ", ".join(rmas.mapped("name")) invoice_form = Form( self.env["account.move"].with_context( - default_type="out_refund", company_id=rmas[0].company_id.id, + default_type="out_refund", + company_id=rmas[0].company_id.id, ), "account.view_move_form", ) @@ -621,7 +646,9 @@ class Rma(models.Model): action["name"] = "Replace product(s)" action["context"] = dict(self.env.context) action["context"].update( - active_id=self.id, active_ids=self.ids, rma_delivery_type="replace", + active_id=self.id, + active_ids=self.ids, + rma_delivery_type="replace", ) return action @@ -640,7 +667,9 @@ class Rma(models.Model): ) action["context"] = dict(self.env.context) action["context"].update( - active_id=self.id, active_ids=self.ids, rma_delivery_type="return", + active_id=self.id, + active_ids=self.ids, + rma_delivery_type="return", ) return action @@ -729,13 +758,16 @@ class Rma(models.Model): action["domain"] = [("id", "in", picking.ids)] elif picking: action.update( - res_id=picking.id, view_mode="form", view_id=False, views=False, + res_id=picking.id, + view_mode="form", + view_id=False, + views=False, ) return action # Validation business methods def _ensure_required_fields(self): - """ This method is used to ensure the following fields are not empty: + """This method is used to ensure the following fields are not empty: [ 'partner_id', 'partner_invoice_id', 'partner_shipping_id', 'product_id', 'location_id' @@ -762,7 +794,7 @@ class Rma(models.Model): raise ValidationError(_("Required field(s):%s") % desc) def _ensure_can_be_returned(self): - """ This method is intended to be invoked after user click on + """This method is intended to be invoked after user click on 'Replace' or 'Return to customer' button (before the delivery wizard is launched) and after confirm the wizard. @@ -779,7 +811,7 @@ class Rma(models.Model): raise ValidationError(_("None of the selected RMAs can perform a return.")) def _ensure_can_be_replaced(self): - """ This method is intended to be invoked after user click on + """This method is intended to be invoked after user click on 'Replace' button (before the delivery wizard is launched) and after confirm the wizard. @@ -806,7 +838,7 @@ class Rma(models.Model): raise ValidationError(_("This RMA cannot be split.")) def _ensure_qty_to_return(self, qty=None, uom=None): - """ This method is intended to be invoked after confirm the wizard. + """This method is intended to be invoked after confirm the wizard. invoked by: rma.create_return """ if qty and uom: @@ -818,7 +850,7 @@ class Rma(models.Model): ) def _ensure_qty_to_extract(self, qty, uom): - """ This method is intended to be invoked after confirm the wizard. + """This method is intended to be invoked after confirm the wizard. invoked by: rma.extract_quantity """ to_split_uom_qty = qty @@ -839,11 +871,15 @@ class Rma(models.Model): create_vals = {} if self.location_id: create_vals.update( - location_id=self.location_id.id, picking_id=self.picking_id.id, + location_id=self.location_id.id, + picking_id=self.picking_id.id, ) return_wizard = ( self.env["stock.return.picking"] - .with_context(active_id=self.picking_id.id, active_ids=self.picking_id.ids,) + .with_context( + active_id=self.picking_id.id, + active_ids=self.picking_id.ids, + ) .create(create_vals) ) return_wizard._onchange_picking_id() @@ -924,13 +960,16 @@ class Rma(models.Model): 'Split: %s has been created.' ) - % (extracted_rma.id, extracted_rma.name,) + % ( + extracted_rma.id, + extracted_rma.name, + ) ) return extracted_rma # Refund business methods def _prepare_refund(self, invoice_form, origin): - """ Hook method for preparing the refund Form. + """Hook method for preparing the refund Form. This method could be override in order to add new custom field values in the refund creation. @@ -942,7 +981,7 @@ class Rma(models.Model): invoice_form.partner_id = self.partner_invoice_id def _prepare_refund_line(self, line_form): - """ Hook method for preparing a refund line Form. + """Hook method for preparing a refund line Form. This method could be override in order to add new custom field values in the refund line creation. @@ -965,7 +1004,7 @@ class Rma(models.Model): def _get_refund_line_quantity(self): """To be overriden in a third module with the proper origin values - in case a kit is linked with the rma """ + in case a kit is linked with the rma""" return (self.product_uom_qty, self.product_uom) def _get_refund_line_price_unit(self): @@ -1088,9 +1127,14 @@ class Rma(models.Model): self.state = "waiting_replacement" def _action_launch_stock_rule( - self, scheduled_date, warehouse, product, qty, uom, + self, + scheduled_date, + warehouse, + product, + qty, + uom, ): - """ Creates a delivery picking and launch stock rule. It is invoked by: + """Creates a delivery picking and launch stock rule. It is invoked by: rma.create_replace """ self.ensure_one() @@ -1125,7 +1169,10 @@ class Rma(models.Model): return True def _prepare_procurement_values( - self, group_id, scheduled_date, warehouse, + self, + group_id, + scheduled_date, + warehouse, ): self.ensure_one() return { @@ -1189,7 +1236,7 @@ class Rma(models.Model): @api.returns("mail.message", lambda value: value.id) def message_post(self, **kwargs): - """ Set 'sent' field to True when an email is sent from rma form + """Set 'sent' field to True when an email is sent from rma form view. This field (sent) is used to set the appropriate style to the 'Send by Email' button in the rma form view. """ @@ -1218,20 +1265,20 @@ class Rma(models.Model): # Other business methods def update_received_state(self): - """ Invoked by: - [stock.move].unlink - [stock.move]._action_cancel - """ + """Invoked by: + [stock.move].unlink + [stock.move]._action_cancel + """ rma = self.filtered(lambda r: r.delivered_qty == 0) if rma: rma.write({"state": "received"}) def update_replaced_state(self): - """ Invoked by: - [stock.move]._action_done - [stock.move].unlink - [stock.move]._action_cancel - """ + """Invoked by: + [stock.move]._action_done + [stock.move].unlink + [stock.move]._action_cancel + """ rma = self.filtered( lambda r: ( r.state == "waiting_replacement" diff --git a/rma/models/rma_tag.py b/rma/models/rma_tag.py index 9f96059e..12960025 100644 --- a/rma/models/rma_tag.py +++ b/rma/models/rma_tag.py @@ -12,7 +12,12 @@ class RmaTag(models.Model): default=True, help="The active field allows you to hide the category without " "removing it.", ) - name = fields.Char(string="Tag Name", required=True, translate=True, copy=False,) + name = fields.Char( + string="Tag Name", + required=True, + translate=True, + copy=False, + ) color = fields.Integer(string="Color Index") rma_ids = fields.Many2many(comodel_name="rma") diff --git a/rma/models/rma_team.py b/rma/models/rma_team.py index 4bb2e7d7..f46b3d4b 100644 --- a/rma/models/rma_team.py +++ b/rma/models/rma_team.py @@ -11,7 +11,10 @@ class RmaTeam(models.Model): _order = "sequence, name" sequence = fields.Integer() - name = fields.Char(required=True, translate=True,) + name = fields.Char( + required=True, + translate=True, + ) active = fields.Boolean( default=True, help="If the active field is set to false, it will allow you " @@ -29,7 +32,9 @@ class RmaTeam(models.Model): default=lambda self: self.env.user, ) member_ids = fields.One2many( - comodel_name="res.users", inverse_name="rma_team_id", string="Team Members", + comodel_name="res.users", + inverse_name="rma_team_id", + string="Team Members", ) def copy(self, default=None): diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py index ade29234..e6ca9df3 100644 --- a/rma/models/stock_move.py +++ b/rma/models/stock_move.py @@ -10,7 +10,10 @@ class StockMove(models.Model): # RMAs that were created from the delivery move rma_ids = fields.One2many( - comodel_name="rma", inverse_name="move_id", string="RMAs", copy=False, + comodel_name="rma", + inverse_name="move_id", + string="RMAs", + copy=False, ) # RMAs linked to the incoming movement from client rma_receiver_ids = fields.One2many( @@ -20,7 +23,11 @@ class StockMove(models.Model): copy=False, ) # RMA that create the delivery movement to the customer - rma_id = fields.Many2one(comodel_name="rma", string="RMA return", copy=False,) + rma_id = fields.Many2one( + comodel_name="rma", + string="RMA return", + copy=False, + ) def unlink(self): # A stock user could have no RMA permissions, so the ids wouldn't @@ -44,7 +51,7 @@ class StockMove(models.Model): return res def _action_done(self, cancel_backorder=False): - """ Avoids to validate stock.move with less quantity than the + """Avoids to validate stock.move with less quantity than the quantity in the linked receiver RMA. It also set the appropriated linked RMA to 'received' or 'delivered'. """ @@ -76,13 +83,13 @@ class StockMove(models.Model): @api.model def _prepare_merge_moves_distinct_fields(self): - """ The main use is that launched delivery RMAs doesn't merge + """The main use is that launched delivery RMAs doesn't merge two moves if they are linked to a different RMAs. """ return super()._prepare_merge_moves_distinct_fields() + ["rma_id"] def _prepare_move_split_vals(self, qty): - """ Intended to the backport of picking linked to RMAs propagates the + """Intended to the backport of picking linked to RMAs propagates the RMA link id. """ res = super()._prepare_move_split_vals(qty) @@ -90,8 +97,7 @@ class StockMove(models.Model): return res def _prepare_return_rma_vals(self, original_picking): - """ hook method for preparing an RMA from the 'return picking wizard'. - """ + """hook method for preparing an RMA from the 'return picking wizard'.""" self.ensure_one() partner = original_picking.partner_id if hasattr(original_picking, "sale_id") and original_picking.sale_id: diff --git a/rma/models/stock_picking.py b/rma/models/stock_picking.py index e343ae3a..8b5b7683 100644 --- a/rma/models/stock_picking.py +++ b/rma/models/stock_picking.py @@ -7,7 +7,10 @@ from odoo import fields, models class StockPicking(models.Model): _inherit = "stock.picking" - rma_count = fields.Integer(string="RMA count", compute="_compute_rma_count",) + rma_count = fields.Integer( + string="RMA count", + compute="_compute_rma_count", + ) def _compute_rma_count(self): for rec in self: @@ -30,7 +33,10 @@ class StockPicking(models.Model): rma = self.move_lines.mapped("rma_ids") if len(rma) == 1: action.update( - res_id=rma.id, view_mode="form", view_id=False, views=False, + res_id=rma.id, + view_mode="form", + view_id=False, + views=False, ) else: action["domain"] = [("id", "in", rma.ids)] diff --git a/rma/models/stock_warehouse.py b/rma/models/stock_warehouse.py index 0b1c3091..1398faec 100644 --- a/rma/models/stock_warehouse.py +++ b/rma/models/stock_warehouse.py @@ -16,16 +16,21 @@ class StockWarehouse(models.Model): help="RMA related products can be stored in this warehouse.", ) rma_in_type_id = fields.Many2one( - comodel_name="stock.picking.type", string="RMA In Type", + comodel_name="stock.picking.type", + string="RMA In Type", ) rma_out_type_id = fields.Many2one( - comodel_name="stock.picking.type", string="RMA Out Type", + comodel_name="stock.picking.type", + string="RMA Out Type", + ) + rma_loc_id = fields.Many2one( + comodel_name="stock.location", + string="RMA Location", ) - rma_loc_id = fields.Many2one(comodel_name="stock.location", string="RMA Location",) @api.model_create_multi def create(self, vals_list): - """ To create an RMA location and link it with a new warehouse, + """To create an RMA location and link it with a new warehouse, this method is overridden instead of '_get_locations_values' method because the locations that are created with the values ​​returned by that method are forced to be children @@ -39,7 +44,7 @@ class StockWarehouse(models.Model): return res def _get_rma_location_values(self): - """ this method is intended to be used by 'create' method + """this method is intended to be used by 'create' method to create a new RMA location to be linked to a new warehouse. """ return { diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 1f07b7be..7857eaae 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -327,17 +327,20 @@ class TestRma(SavepointCase): # One refund per partner self.assertNotEqual(refund_1.partner_id, refund_2.partner_id) self.assertEqual( - refund_1.partner_id, (rma_1 | rma_2 | rma_3).mapped("partner_invoice_id"), + refund_1.partner_id, + (rma_1 | rma_2 | rma_3).mapped("partner_invoice_id"), ) self.assertEqual(refund_2.partner_id, rma_4.partner_invoice_id) # Each RMA (rma_1, rma_2 and rma_3) is linked with a different # line of refund_1 self.assertEqual(len(refund_1.invoice_line_ids), 3) self.assertEqual( - refund_1.invoice_line_ids.mapped("rma_id"), (rma_1 | rma_2 | rma_3), + refund_1.invoice_line_ids.mapped("rma_id"), + (rma_1 | rma_2 | rma_3), ) self.assertEqual( - (rma_1 | rma_2 | rma_3).mapped("refund_line_id"), refund_1.invoice_line_ids, + (rma_1 | rma_2 | rma_3).mapped("refund_line_id"), + refund_1.invoice_line_ids, ) # rma_4 is linked with the unique line of refund_2 self.assertEqual(len(refund_2.invoice_line_ids), 1) @@ -369,7 +372,8 @@ class TestRma(SavepointCase): ) delivery_form = Form( self.env["rma.delivery.wizard"].with_context( - active_ids=rma.ids, rma_delivery_type="replace", + active_ids=rma.ids, + rma_delivery_type="replace", ) ) delivery_form.product_id = product_2 @@ -396,7 +400,8 @@ class TestRma(SavepointCase): ) delivery_form = Form( self.env["rma.delivery.wizard"].with_context( - active_ids=rma.ids, rma_delivery_type="replace", + active_ids=rma.ids, + rma_delivery_type="replace", ) ) delivery_form.product_id = product_3 @@ -439,7 +444,8 @@ class TestRma(SavepointCase): # Return the same product with quantity 2 to the customer. delivery_form = Form( self.env["rma.delivery.wizard"].with_context( - active_ids=rma.ids, rma_delivery_type="return", + active_ids=rma.ids, + rma_delivery_type="return", ) ) delivery_form.product_uom_qty = 2 @@ -471,7 +477,8 @@ class TestRma(SavepointCase): # Return the remaining quantity to the customer delivery_form = Form( self.env["rma.delivery.wizard"].with_context( - active_ids=rma.ids, rma_delivery_type="return", + active_ids=rma.ids, + rma_delivery_type="return", ) ) delivery_wizard = delivery_form.save() @@ -538,17 +545,20 @@ class TestRma(SavepointCase): # One picking per partner self.assertNotEqual(pick_1.partner_id, pick_2.partner_id) self.assertEqual( - pick_1.partner_id, (rma_1 | rma_2 | rma_3).mapped("partner_shipping_id"), + pick_1.partner_id, + (rma_1 | rma_2 | rma_3).mapped("partner_shipping_id"), ) self.assertEqual(pick_2.partner_id, rma_4.partner_id) # Each RMA of (rma_1, rma_2 and rma_3) is linked to a different # line of picking_1 self.assertEqual(len(pick_1.move_lines), 3) self.assertEqual( - pick_1.move_lines.mapped("rma_id"), (rma_1 | rma_2 | rma_3), + pick_1.move_lines.mapped("rma_id"), + (rma_1 | rma_2 | rma_3), ) self.assertEqual( - (rma_1 | rma_2 | rma_3).mapped("delivery_move_ids"), pick_1.move_lines, + (rma_1 | rma_2 | rma_3).mapped("delivery_move_ids"), + pick_1.move_lines, ) # rma_4 is linked with the unique move of pick_2 self.assertEqual(len(pick_2.move_lines), 1) @@ -569,7 +579,10 @@ class TestRma(SavepointCase): origin_delivery = self._create_delivery() return_wizard = ( self.env["stock.return.picking"] - .with_context(active_id=origin_delivery.id, active_ids=origin_delivery.ids,) + .with_context( + active_id=origin_delivery.id, + active_ids=origin_delivery.ids, + ) .create({"create_rma": True, "picking_id": origin_delivery.id}) ) return_wizard._onchange_picking_id() @@ -607,7 +620,8 @@ class TestRma(SavepointCase): # Return quantity 4 of the same product to the customer delivery_form = Form( self.env["rma.delivery.wizard"].with_context( - active_ids=rma.ids, rma_delivery_type="return", + active_ids=rma.ids, + rma_delivery_type="return", ) ) delivery_form.product_uom_qty = 4 @@ -620,7 +634,10 @@ class TestRma(SavepointCase): self.assertTrue(rma.can_be_split) split_wizard = ( self.env["rma.split.wizard"] - .with_context(active_id=rma.id, active_ids=rma.ids,) + .with_context( + active_id=rma.id, + active_ids=rma.ids, + ) .create({}) ) action = split_wizard.action_split() diff --git a/rma/wizard/rma_delivery.py b/rma/wizard/rma_delivery.py index ae7c0f42..251e73e4 100644 --- a/rma/wizard/rma_delivery.py +++ b/rma/wizard/rma_delivery.py @@ -16,15 +16,19 @@ class RmaReDeliveryWizard(models.TransientModel): required=True, ) product_id = fields.Many2one( - comodel_name="product.product", string="Replace Product", + comodel_name="product.product", + string="Replace Product", ) product_uom_qty = fields.Float( - string="Product qty", digits="Product Unit of Measure", + string="Product qty", + digits="Product Unit of Measure", ) product_uom = fields.Many2one(comodel_name="uom.uom", string="Unit of measure") scheduled_date = fields.Datetime(required=True, default=fields.Datetime.now()) warehouse_id = fields.Many2one( - comodel_name="stock.warehouse", string="Warehouse", required=True, + comodel_name="stock.warehouse", + string="Warehouse", + required=True, ) @api.constrains("product_uom_qty") diff --git a/rma/wizard/rma_split.py b/rma/wizard/rma_split.py index 1ac646a9..e30d204c 100644 --- a/rma/wizard/rma_split.py +++ b/rma/wizard/rma_split.py @@ -8,7 +8,10 @@ class RmaReSplitWizard(models.TransientModel): _name = "rma.split.wizard" _description = "RMA Split Wizard" - rma_id = fields.Many2one(comodel_name="rma", string="RMA",) + rma_id = fields.Many2one( + comodel_name="rma", + string="RMA", + ) product_uom_qty = fields.Float( string="Quantity to extract", digits="Product Unit of Measure", @@ -16,7 +19,9 @@ class RmaReSplitWizard(models.TransientModel): help="Quantity to extract to a new RMA.", ) product_uom = fields.Many2one( - comodel_name="uom.uom", string="Unit of measure", required=True, + comodel_name="uom.uom", + string="Unit of measure", + required=True, ) _sql_constraints = [ diff --git a/rma/wizard/stock_picking_return.py b/rma/wizard/stock_picking_return.py index b337e73a..a331c288 100644 --- a/rma/wizard/stock_picking_return.py +++ b/rma/wizard/stock_picking_return.py @@ -51,7 +51,7 @@ class ReturnPicking(models.TransientModel): return {"domain": {"location_id": rma_loc_domain}} def create_returns(self): - """ Override create_returns method for creating one or more + """Override create_returns method for creating one or more 'confirmed' RMAs after return a delivery picking in case 'Create RMAs' checkbox is checked in this wizard. New RMAs will be linked to the delivery picking as the origin