diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py
index 7da6170858c..0e2bd09d2ee 100644
--- a/addons/repair/models/repair.py
+++ b/addons/repair/models/repair.py
@@ -115,8 +115,8 @@ class Repair(models.Model):
copy=False, help="Sale Order from which the product to be repaired comes from.")
picking_id = fields.Many2one(
'stock.picking', 'Return', check_company=True,
- domain="[('is_repairable', '!=', False), ('company_id', '=', company_id)]",
copy=False, help="Return Order from which the product to be repaired comes from.")
+ allowed_picking_type_ids = fields.Many2many('stock.picking.type', compute='_compute_allowed_picking_type_ids')
is_returned = fields.Boolean(
"Returned", compute='_compute_is_returned',
help="True if this repair is linked to a Return Order and the order is 'Done'. False otherwise.")
@@ -130,6 +130,14 @@ class Repair(models.Model):
invoice_state = fields.Selection(string='Invoice State', related='invoice_id.state')
priority = fields.Selection([('0', 'Normal'), ('1', 'Urgent')], default='0', string="Priority", help="Important repair order")
+ def _compute_allowed_picking_type_ids(self):
+ '''
+ computes the ids of return picking types
+ '''
+ out_picking_types = self.env['stock.picking.type'].search_read(domain=[('code', '=', 'outgoing')],
+ fields=['return_picking_type_id'], load='')
+ self.allowed_picking_type_ids = [pick_type['return_picking_type_id'] for pick_type in out_picking_types]
+
@api.depends('partner_id')
def _compute_default_address_id(self):
for order in self:
@@ -179,6 +187,15 @@ class Repair(models.Model):
('name', 'unique (name)', 'The name of the Repair Order must be unique!'),
]
+ @api.onchange('location_id', 'picking_id')
+ def _onchange_location_picking(self):
+ location_warehouse = self.location_id.warehouse_id
+ picking_warehouse = self.picking_id.location_dest_id.warehouse_id
+ if location_warehouse and picking_warehouse and location_warehouse != picking_warehouse:
+ return {
+ 'warning': {'title': "Warning", 'message': "Note that the warehouse of the return and repair locations don't match!"},
+ }
+
@api.onchange('product_id')
def onchange_product_id(self):
self.guarantee_limit = False
diff --git a/addons/repair/views/repair_views.xml b/addons/repair/views/repair_views.xml
index 777566424a0..f5b2568ec82 100644
--- a/addons/repair/views/repair_views.xml
+++ b/addons/repair/views/repair_views.xml
@@ -86,11 +86,12 @@
-
-
+
+
+