From 1853216e80f3b8fda41703f7b44b12ce915e2658 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Fri, 8 Oct 2021 11:05:07 +0200 Subject: [PATCH] [IMP] rma_filter_lot: onchange returned by domain should use ids * rename field to `valid_lot_ids`. * add small readme --- rma_filter_lot/README.rst | 37 +++++++++++++++++++++++++ rma_filter_lot/models/rma_order_line.py | 10 +++---- rma_filter_lot/views/rma_order_view.xml | 2 +- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 rma_filter_lot/README.rst diff --git a/rma_filter_lot/README.rst b/rma_filter_lot/README.rst new file mode 100644 index 00000000..e36debc6 --- /dev/null +++ b/rma_filter_lot/README.rst @@ -0,0 +1,37 @@ +============== +RMA Filter Lot +============== + +Filter RMA lots in customer RMA to only allow lots sent to customer. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow S.L. + +Contributors +~~~~~~~~~~~~ + +* Mateu Griful +* Lois Rilo + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the ForgeFlow. + +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. + diff --git a/rma_filter_lot/models/rma_order_line.py b/rma_filter_lot/models/rma_order_line.py index f54dd0c8..d3283271 100644 --- a/rma_filter_lot/models/rma_order_line.py +++ b/rma_filter_lot/models/rma_order_line.py @@ -9,10 +9,9 @@ class RmaOrderLine(models.Model): _inherit = "rma.order.line" lot_id = fields.Many2one( - comodel_name="stock.production.lot", - domain="[('id', 'in', valid_lots_ids)]", + domain="[('id', 'in', valid_lot_ids)]", ) - valid_lots_ids = fields.One2many( + valid_lot_ids = fields.One2many( comodel_name="stock.production.lot", compute="_compute_domain_lot_ids", ) @@ -40,8 +39,9 @@ class RmaOrderLine(models.Model): valid_ids |= quant.lot_id if valid_ids: lots = valid_ids - rec.valid_lots_ids = lots + rec.valid_lot_ids = lots def _onchange_product_id(self): super()._onchange_product_id() - return {"domain": {"lot_id": [("id", "in", self.valid_lots_ids)]}} + # Override domain added in base `rma` module. + return {"domain": {"lot_id": [("id", "in", self.valid_lot_ids.ids)]}} diff --git a/rma_filter_lot/views/rma_order_view.xml b/rma_filter_lot/views/rma_order_view.xml index fef36976..cef3c835 100644 --- a/rma_filter_lot/views/rma_order_view.xml +++ b/rma_filter_lot/views/rma_order_view.xml @@ -6,7 +6,7 @@ - +