From 8afb31c8836716d643c6fb43a59c050e1f644c2c Mon Sep 17 00:00:00 2001 From: Chafique Date: Fri, 3 Sep 2021 12:42:24 +0200 Subject: [PATCH] [IMP] rma_sale: black, isort, prettier --- rma_sale/models/res_config_settings.py | 3 ++- rma_sale/models/rma.py | 15 ++++++++++----- rma_sale/models/sale.py | 9 +++++++-- rma_sale/static/src/js/rma_portal_form.js | 12 ++++++------ rma_sale/tests/test_rma_sale.py | 3 ++- rma_sale/wizard/sale_order_rma_wizard.py | 19 ++++++++++++++----- setup/rma_sale/odoo/addons/rma_sale | 1 + setup/rma_sale/setup.py | 6 ++++++ 8 files changed, 48 insertions(+), 20 deletions(-) create mode 120000 setup/rma_sale/odoo/addons/rma_sale create mode 100644 setup/rma_sale/setup.py diff --git a/rma_sale/models/res_config_settings.py b/rma_sale/models/res_config_settings.py index dd42c753..5b809adb 100644 --- a/rma_sale/models/res_config_settings.py +++ b/rma_sale/models/res_config_settings.py @@ -7,5 +7,6 @@ class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" show_full_page_sale_rma = fields.Boolean( - related="company_id.show_full_page_sale_rma", readonly=False, + related="company_id.show_full_page_sale_rma", + readonly=False, ) diff --git a/rma_sale/models/rma.py b/rma_sale/models/rma.py index 70c0dfcd..d3e251b3 100644 --- a/rma_sale/models/rma.py +++ b/rma_sale/models/rma.py @@ -18,16 +18,21 @@ class Rma(models.Model): states={"draft": [("readonly", False)]}, ) allowed_picking_ids = fields.Many2many( - comodel_name="stock.picking", compute="_compute_allowed_picking_ids", + comodel_name="stock.picking", + compute="_compute_allowed_picking_ids", ) picking_id = fields.Many2one(domain="[('id', 'in', allowed_picking_ids)]") allowed_move_ids = fields.Many2many( - comodel_name="sale.order.line", compute="_compute_allowed_move_ids", + comodel_name="sale.order.line", + compute="_compute_allowed_move_ids", ) move_id = fields.Many2one(domain="[('id', 'in', allowed_move_ids)]") - sale_line_id = fields.Many2one(related="move_id.sale_line_id",) + sale_line_id = fields.Many2one( + related="move_id.sale_line_id", + ) allowed_product_ids = fields.Many2many( - comodel_name="product.product", compute="_compute_allowed_product_ids", + comodel_name="product.product", + compute="_compute_allowed_product_ids", ) product_id = fields.Many2one(domain="[('id', 'in', allowed_product_ids)]") @@ -93,7 +98,7 @@ class Rma(models.Model): def _get_refund_line_product(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""" if not self.sale_line_id: return super()._get_refund_line_product() return self.sale_line_id.product_id diff --git a/rma_sale/models/sale.py b/rma_sale/models/sale.py index 56bc4ca9..78b65170 100644 --- a/rma_sale/models/sale.py +++ b/rma_sale/models/sale.py @@ -10,7 +10,10 @@ class SaleOrder(models.Model): # RMAs that were created from a sale order rma_ids = fields.One2many( - comodel_name="rma", inverse_name="order_id", string="RMAs", copy=False, + comodel_name="rma", + inverse_name="order_id", + string="RMAs", + copy=False, ) rma_count = fields.Integer(string="RMA count", compute="_compute_rma_count") @@ -61,7 +64,9 @@ class SaleOrder(models.Model): rma = self.rma_ids if len(rma) == 1: action.update( - res_id=rma.id, view_mode="form", views=[], + res_id=rma.id, + view_mode="form", + views=[], ) else: action["domain"] = [("id", "in", rma.ids)] diff --git a/rma_sale/static/src/js/rma_portal_form.js b/rma_sale/static/src/js/rma_portal_form.js index e904d44a..f407ed47 100644 --- a/rma_sale/static/src/js/rma_portal_form.js +++ b/rma_sale/static/src/js/rma_portal_form.js @@ -1,7 +1,7 @@ /* Copyright 2021 Tecnativa - David Vidal License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ -odoo.define("rma_sale.animation", function(require) { +odoo.define("rma_sale.animation", function (require) { "use strict"; var sAnimation = require("website.content.snippets.animation"); @@ -10,16 +10,16 @@ odoo.define("rma_sale.animation", function(require) { // selector so the user doesn't miss the chance to add his comments sAnimation.registry.rma_operation_portal = sAnimation.Class.extend({ selector: ".rma-operation", - start: function() { + start: function () { this.id = this.el.name.replace("-operation_id", ""); this.$comment = $("#comment-" + this.id); this.$comment_input = $("[name='" + this.id + "-description']"); var _this = this; - this.$el.on("change", function() { + this.$el.on("change", function () { _this._onChangeOperationId(); }); }, - _show_comment: function() { + _show_comment: function () { if (this.$comment) { this.$comment.removeClass("show"); this.$comment.addClass("show"); @@ -28,12 +28,12 @@ odoo.define("rma_sale.animation", function(require) { } } }, - _hide_comment: function() { + _hide_comment: function () { if (this.$comment) { this.$comment.removeClass("show"); } }, - _onChangeOperationId: function() { + _onChangeOperationId: function () { // Toggle comment on or off if an operation is requested if (this.$el && this.$el.val()) { this._show_comment(); diff --git a/rma_sale/tests/test_rma_sale.py b/rma_sale/tests/test_rma_sale.py index 7a22c22b..236a5a5f 100644 --- a/rma_sale/tests/test_rma_sale.py +++ b/rma_sale/tests/test_rma_sale.py @@ -97,7 +97,8 @@ class TestRmaSale(SavepointCase): ) 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 = rma.product_uom_qty diff --git a/rma_sale/wizard/sale_order_rma_wizard.py b/rma_sale/wizard/sale_order_rma_wizard.py index 436bcc8d..338f1eca 100644 --- a/rma_sale/wizard/sale_order_rma_wizard.py +++ b/rma_sale/wizard/sale_order_rma_wizard.py @@ -75,7 +75,10 @@ class SaleOrderRmaWizard(models.TransientModel): action["domain"] = [("id", "in", rma.ids)] elif rma: 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, ) return action @@ -101,10 +104,13 @@ class SaleOrderLineRmaWizard(models.TransientModel): domain="[('id', 'in', allowed_product_ids)]", ) uom_category_id = fields.Many2one( - comodel_name="uom.category", related="product_id.uom_id.category_id", + comodel_name="uom.category", + related="product_id.uom_id.category_id", ) quantity = fields.Float( - string="Quantity", digits="Product Unit of Measure", required=True, + string="Quantity", + digits="Product Unit of Measure", + required=True, ) uom_id = fields.Many2one( comodel_name="uom.uom", @@ -122,9 +128,12 @@ class SaleOrderLineRmaWizard(models.TransientModel): ) move_id = fields.Many2one(comodel_name="stock.move", compute="_compute_move_id") operation_id = fields.Many2one( - comodel_name="rma.operation", string="Requested operation", + comodel_name="rma.operation", + string="Requested operation", + ) + sale_line_id = fields.Many2one( + comodel_name="sale.order.line", ) - sale_line_id = fields.Many2one(comodel_name="sale.order.line",) description = fields.Text() @api.onchange("product_id") diff --git a/setup/rma_sale/odoo/addons/rma_sale b/setup/rma_sale/odoo/addons/rma_sale new file mode 120000 index 00000000..243aef4e --- /dev/null +++ b/setup/rma_sale/odoo/addons/rma_sale @@ -0,0 +1 @@ +../../../../rma_sale \ No newline at end of file diff --git a/setup/rma_sale/setup.py b/setup/rma_sale/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/rma_sale/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)