[FIX] repair: manually set return picking on repair form
User Can now manually set return picking on repair form, only pickings of return type Part-of: odoo/odoo#91879
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -86,11 +86,12 @@
|
||||
<field name="partner_id" widget="res_partner_many2one" attrs="{'required':[('invoice_method','!=','none')]}" context="{'res_partner_search_mode': 'customer', 'show_vat': True}"/>
|
||||
<field name="address_id" groups="account.group_delivery_invoice_address"/>
|
||||
<field name="sale_order_id"/>
|
||||
<field name="picking_id" options="{'no_create': True}"/>
|
||||
<field name="user_id" domain="[('share', '=', False)]"/>
|
||||
<field name="allowed_picking_type_ids" invisible="1"/>
|
||||
<field name="picking_id" domain="[('picking_type_id','in', allowed_picking_type_ids)]" options="{'no_create': True}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="schedule_date"/>
|
||||
<field name="user_id" domain="[('share', '=', False)]"/>
|
||||
<field name="location_id" options="{'no_create': True}"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
<field name="guarantee_limit"/>
|
||||
|
||||
Reference in New Issue
Block a user