fix return wizard "set qty to 0"
Add method to auto unpack on return
This commit is contained in:
@@ -170,6 +170,32 @@ class StockIncoterms(models.Model):
|
||||
return res
|
||||
|
||||
|
||||
class StockQuant(models.Model):
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
@api.model
|
||||
def _cron_auto_unpack_on_internal_locations(self):
|
||||
# Problem in v10: when you manage packs in Odoo for customer pickings,
|
||||
# you have the following problem: when you return a customer picking,
|
||||
# if you return all the products that were in the same pack, the pack
|
||||
# is returned, so you have in your stock one or several quants
|
||||
# inside a pack. This is a problem when you want to ship those
|
||||
# products again.
|
||||
# I provide the code in this module, but not the cron, because in some
|
||||
# scenarios, you may want to have packs in your stock.
|
||||
# Just add the cron in the specific module of your project.
|
||||
# Underlying problem solved in Odoo v11. Don't port that to v14 !
|
||||
logger.info('START cron auto unpack on internal locations')
|
||||
int_locs = self.env['stock.location'].search([('usage', '=', 'internal')])
|
||||
quants = self.search([
|
||||
('location_id', 'in', int_locs.ids),
|
||||
('package_id', '!=', False)])
|
||||
packages = quants.mapped('package_id')
|
||||
logger.info('Unpacking %d packages on internal locations', len(packages))
|
||||
packages.unpack()
|
||||
logger.info('END cron auto unpack on internal locations')
|
||||
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
_inherit = 'procurement.group'
|
||||
|
||||
|
||||
@@ -14,4 +14,5 @@ class StockReturnPicking(models.TransientModel):
|
||||
self.product_return_moves.write({'quantity': 0})
|
||||
action = self.env.ref('stock.act_stock_return_picking').read()[0]
|
||||
action['res_id'] = self.id
|
||||
action['context'] = self._context
|
||||
return action
|
||||
|
||||
Reference in New Issue
Block a user