From 5b741b64b2d80f83b202c9c34df294a584dbd64a Mon Sep 17 00:00:00 2001 From: Ernesto Tejeda Date: Sat, 12 Dec 2020 10:18:13 -0500 Subject: [PATCH 1/3] [IMP] *rma*: Avoid RMAs of kits until rma_mrp is installed --- rma_sale/views/sale_portal_template.xml | 5 +++-- website_rma/controllers/main.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rma_sale/views/sale_portal_template.xml b/rma_sale/views/sale_portal_template.xml index 3063a429..3bd5b1c8 100644 --- a/rma_sale/views/sale_portal_template.xml +++ b/rma_sale/views/sale_portal_template.xml @@ -87,7 +87,9 @@ - + Date: Sat, 12 Dec 2020 10:21:44 -0500 Subject: [PATCH 2/3] [IMP] *rma*: some improvements --- rma_sale/wizard/sale_order_rma_wizard.py | 3 +++ website_rma/models/rma.py | 1 + 2 files changed, 4 insertions(+) diff --git a/rma_sale/wizard/sale_order_rma_wizard.py b/rma_sale/wizard/sale_order_rma_wizard.py index e20bc97c..cd0b922b 100644 --- a/rma_sale/wizard/sale_order_rma_wizard.py +++ b/rma_sale/wizard/sale_order_rma_wizard.py @@ -53,6 +53,8 @@ class SaleOrderRmaWizard(models.TransientModel): def create_and_open_rma(self): self.ensure_one() rma = self.create_rma() + if not rma: + return for rec in rma: rec.action_confirm() action = self.env.ref("rma.rma_action").read()[0] @@ -114,6 +116,7 @@ class SaleOrderLineRmaWizard(models.TransientModel): @api.onchange("product_id") def onchange_product_id(self): self.picking_id = False + self.uom_id = self.product_id.uom_id @api.depends("picking_id") def _compute_move_id(self): diff --git a/website_rma/models/rma.py b/website_rma/models/rma.py index 8f841880..d55e638e 100644 --- a/website_rma/models/rma.py +++ b/website_rma/models/rma.py @@ -12,5 +12,6 @@ class Rma(models.Model): team_id=values.get("team_id") or request.website.rma_default_team_id.id, user_id=values.get("user_id") or request.website.rma_default_user_id.id, partner_id=values.get("partner_id") or request.env.user.partner_id.id, + origin="Website form", ) return values From 1abcd11493818c7a73bfbda7c7614439acc28eec Mon Sep 17 00:00:00 2001 From: david Date: Thu, 17 Dec 2020 17:04:05 +0100 Subject: [PATCH 3/3] [FIX] rma_sale: product in multiple lines If there are several stock moves with the same product in the picking we won't be able to make the RMA --- rma_sale/models/sale.py | 5 ++++- rma_sale/views/sale_portal_template.xml | 6 ++++++ rma_sale/wizard/sale_order_rma_wizard.py | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/rma_sale/models/sale.py b/rma_sale/models/sale.py index d2b58601..bfc14243 100644 --- a/rma_sale/models/sale.py +++ b/rma_sale/models/sale.py @@ -36,6 +36,7 @@ class SaleOrder(models.Model): { "product_id": data["product"].id, "quantity": data["quantity"], + "sale_line_id": data["sale_line_id"].id, "uom_id": data["uom"].id, "picking_id": data["picking"] and data["picking"].id, }, @@ -83,7 +84,7 @@ class SaleOrderLine(models.Model): self.ensure_one() return self.move_ids.filtered( lambda r: ( - self.product_id == r.product_id + self == r.sale_line_id and r.state == "done" and not r.scrapped and r.location_dest_id.usage == "customer" @@ -114,6 +115,7 @@ class SaleOrderLine(models.Model): "quantity": qty, "uom": move.product_uom, "picking": move.picking_id, + "sale_line_id": self, } ) else: @@ -123,6 +125,7 @@ class SaleOrderLine(models.Model): "quantity": self.qty_delivered, "uom": self.product_uom, "picking": False, + "sale_line_id": self, } ) return data diff --git a/rma_sale/views/sale_portal_template.xml b/rma_sale/views/sale_portal_template.xml index 3bd5b1c8..14d36396 100644 --- a/rma_sale/views/sale_portal_template.xml +++ b/rma_sale/views/sale_portal_template.xml @@ -100,6 +100,12 @@ t-attf-name="#{data_index}-product_id" t-att-value="data['product'].id" /> +
diff --git a/rma_sale/wizard/sale_order_rma_wizard.py b/rma_sale/wizard/sale_order_rma_wizard.py index cd0b922b..537c72e7 100644 --- a/rma_sale/wizard/sale_order_rma_wizard.py +++ b/rma_sale/wizard/sale_order_rma_wizard.py @@ -111,6 +111,7 @@ class SaleOrderLineRmaWizard(models.TransientModel): operation_id = fields.Many2one( comodel_name="rma.operation", string="Requested operation", ) + sale_line_id = fields.Many2one(comodel_name="sale.order.line",) description = fields.Text() @api.onchange("product_id") @@ -124,7 +125,8 @@ class SaleOrderLineRmaWizard(models.TransientModel): if record.picking_id: record.move_id = record.picking_id.move_lines.filtered( lambda r: ( - r.sale_line_id.product_id == record.product_id + r.sale_line_id == record.sale_line_id + and r.sale_line_id.product_id == record.product_id and r.sale_line_id.order_id == record.order_id ) )