From fa36d0f47a929ebd6d05b2c362d88a5a6f8eec6a Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 18 May 2022 09:04:08 +0200 Subject: [PATCH] OD-1773 Klaviyo email events for the Customer RMA operations --- rma_sale/models/__init__.py | 1 + rma_sale/models/stock_rule.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 rma_sale/models/stock_rule.py diff --git a/rma_sale/models/__init__.py b/rma_sale/models/__init__.py index d5e8d22fc..0da5ec84c 100644 --- a/rma_sale/models/__init__.py +++ b/rma_sale/models/__init__.py @@ -5,3 +5,4 @@ from . import rma_order_line from . import rma_order from . import rma_operation +from . import stock_rule diff --git a/rma_sale/models/stock_rule.py b/rma_sale/models/stock_rule.py new file mode 100644 index 000000000..4443e4564 --- /dev/null +++ b/rma_sale/models/stock_rule.py @@ -0,0 +1,19 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import models + + +class StockRule(models.Model): + _inherit = 'stock.rule' + + def _get_stock_move_values(self, product_id, product_qty, product_uom, + location_id, name, origin, values, group_id): + """ Pass sale line if defined """ + res = super()._get_stock_move_values( + product_id, product_qty, product_uom, location_id, name, origin, values, group_id + ) + if 'rma_line_id' in values: + line = self.env['rma.order.line'].browse(values.get('rma_line_id')) + if line.sale_line_id: + res['sale_line_id'] = line.sale_line_id.id + return res