From 90964175ad032f67475b00e37c584be5fd1c8d01 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 17 Dec 2020 17:04:05 +0100 Subject: [PATCH] [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/__manifest__.py | 2 +- rma_sale/i18n/es.po | 5 +++++ rma_sale/i18n/nl.po | 8 +++++++- rma_sale/i18n/pt_BR.po | 5 +++++ rma_sale/i18n/rma_sale.pot | 5 +++++ rma_sale/i18n/ro.po | 12 +++++++++--- rma_sale/models/sale.py | 5 ++++- rma_sale/views/sale_portal_template.xml | 6 ++++++ rma_sale/wizard/sale_order_rma_wizard.py | 4 +++- 9 files changed, 45 insertions(+), 7 deletions(-) diff --git a/rma_sale/__manifest__.py b/rma_sale/__manifest__.py index c63d3bdb..7bb2e2bf 100644 --- a/rma_sale/__manifest__.py +++ b/rma_sale/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management - Link with Sales", "summary": "Sale Order - Return Merchandise Authorization (RMA)", - "version": "13.0.1.0.0", + "version": "13.0.1.1.0", "development_status": "Production/Stable", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma_sale/i18n/es.po b/rma_sale/i18n/es.po index f599abd7..95b9f981 100644 --- a/rma_sale/i18n/es.po +++ b/rma_sale/i18n/es.po @@ -289,6 +289,11 @@ msgstr "Solicitar RMAs" msgid "Requested operation" msgstr "Operación solicitada" +#. module: rma_sale +#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__sale_line_id +msgid "Sale Line" +msgstr "" + #. module: rma_sale #: model:ir.model.fields,field_description:rma_sale.field_rma__order_id msgid "Sale Order" diff --git a/rma_sale/i18n/nl.po b/rma_sale/i18n/nl.po index c78abb5b..94152c56 100644 --- a/rma_sale/i18n/nl.po +++ b/rma_sale/i18n/nl.po @@ -56,7 +56,8 @@ msgstr "" #. module: rma_sale #: model_terms:ir.ui.view,arch_db:rma_sale.sale_order_portal_content -msgid "" +msgid "" +"" msgstr "" #. module: rma_sale @@ -283,6 +284,11 @@ msgstr "aangevraagde RMA's" msgid "Requested operation" msgstr "Verzochte handeling" +#. module: rma_sale +#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__sale_line_id +msgid "Sale Line" +msgstr "" + #. module: rma_sale #: model:ir.model.fields,field_description:rma_sale.field_rma__order_id msgid "Sale Order" diff --git a/rma_sale/i18n/pt_BR.po b/rma_sale/i18n/pt_BR.po index 9e259eb1..c3643041 100644 --- a/rma_sale/i18n/pt_BR.po +++ b/rma_sale/i18n/pt_BR.po @@ -284,6 +284,11 @@ msgstr "Requisição de RMAs" msgid "Requested operation" msgstr "Operação Requisitada" +#. module: rma_sale +#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__sale_line_id +msgid "Sale Line" +msgstr "" + #. module: rma_sale #: model:ir.model.fields,field_description:rma_sale.field_rma__order_id msgid "Sale Order" diff --git a/rma_sale/i18n/rma_sale.pot b/rma_sale/i18n/rma_sale.pot index 24e9f61e..2d37b23e 100644 --- a/rma_sale/i18n/rma_sale.pot +++ b/rma_sale/i18n/rma_sale.pot @@ -277,6 +277,11 @@ msgstr "" msgid "Requested operation" msgstr "" +#. module: rma_sale +#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__sale_line_id +msgid "Sale Line" +msgstr "" + #. module: rma_sale #: model:ir.model.fields,field_description:rma_sale.field_rma__order_id msgid "Sale Order" diff --git a/rma_sale/i18n/ro.po b/rma_sale/i18n/ro.po index 405e3dd2..7a6a3383 100644 --- a/rma_sale/i18n/ro.po +++ b/rma_sale/i18n/ro.po @@ -57,10 +57,11 @@ msgstr " Anulat" #. module: rma_sale #: model_terms:ir.ui.view,arch_db:rma_sale.sale_order_portal_content -msgid "" +msgid "" +"" msgstr "" -"" +"" #. module: rma_sale #: model_terms:ir.ui.view,arch_db:rma_sale.sale_order_portal_content @@ -289,6 +290,11 @@ msgstr "Cereri retur" msgid "Requested operation" msgstr "Operație solicitată" +#. module: rma_sale +#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__sale_line_id +msgid "Sale Line" +msgstr "" + #. module: rma_sale #: model:ir.model.fields,field_description:rma_sale.field_rma__order_id msgid "Sale Order" 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 ) )