Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
4 Replies
16400 Tampilan

When trying to validate the delivery/picking you get an error message.

Usually happens when dealing with products with serial numbers. This will be permanently fixed in the future but in the meantime, here is how to handle it.

Avatar
Buang
Jawaban Terbai

The way i did is in the fallowing video  and it worked .. 

you will endup having a component not consumed, but you can at least mark as done the MO
https://screencast-o-matic.com/watch/c3jZlDVTONK


Avatar
Buang

Thank you sir, this worked for me and you made my day happier :-)

the link is not working, could you please update it? thanks

Penulis Jawaban Terbai

When trying to validate the delivery/picking you get an error message.

Usually happens when dealing with products with serial numbers. This will be permanently fixed in the future but in the meantime, here is how to handle it.



ARM created a fix for this. In order to implement it you need to follow these steps:

1. debug mode
2. technical/server actions
3. create
4. action name: e.g. fix unreserved qty
5. model: ir.actions.server
6. action to do: "execute python code"
7. copy/paste the fix underneath the pre-existing code
8. "save"
9. "create contextual action"
10. refresh page
11. action/fix "fix unreserved qty"
12. wait for it to load
13. "remove contextual action"
14. action/delete

______

You can explain this to the client (so that they do it themselves or you do it following the steps mentioned above)

It happens because the reserved quantity in your inventory does not reflect the one on your pickings.It's probably due to a small configuration change while some pickings where open.
An easy way to remove it is to create a server action that executes this code

It should repair all the inconsistencies in your data.

If you need help in order to create the server action. Do not hesitate to ask.
__________________________________________________________________________


quants = env['stock.quant'].search([])

warning = ''
for quant in quants:
move_lines = env["stock.move.line"].search([
('product_id', '=', quant.product_id.id),
('location_id', '=', quant.location_id.id),
('lot_id', '=', quant.lot_id.id),
('package_id', '=', quant.package_id.id),
('owner_id', '=', quant.owner_id.id),
('product_qty', '!=', 0)
])
reserved_on_move_lines = sum(move_lines.mapped('product_qty'))
move_line_str = str.join(', ', [str(move_line_id) for move_line_id in move_lines.ids])

if quant.location_id.should_bypass_reservation():
# If a quant is in a location that should bypass the reservation, its `reserved_quantity` field
# should be 0.
if quant.reserved_quantity != 0:
quant.write({'reserved_quantity': 0})
else:
# If a quant is in a reservable location, its `reserved_quantity` should be exactly the sum
# of the `product_qty` of all the partially_available / assigned move lines with the same
# characteristics.
if quant.reserved_quantity == 0:
if move_lines:
move_lines.with_context(bypass_reservation_update=True).write({'product_uom_qty': 0})
elif quant.reserved_quantity < 0:
quant.write({'reserved_quantity': 0})
if move_lines:
move_lines.with_context(bypass_reservation_update=True).write({'product_uom_qty': 0})
else:
if reserved_on_move_lines != quant.reserved_quantity:
move_lines.with_context(bypass_reservation_update=True).write({'product_uom_qty': 0})
quant.write({'reserved_quantity': 0})
else:
if any(move_line.product_qty < 0 for move_line in move_lines):
move_lines.with_context(bypass_reservation_update=True).write({'product_uom_qty': 0})
quant.write({'reserved_quantity': 0})

product_without_quants = env['product.product'].search([('type', '=', 'product')]) - quants.mapped('product_id')

move_lines_to_unreserve = []

for product in product_without_quants:
move_lines = env['stock.move.line'].search([
('product_qty', '!=', 0),
('product_id', '=', product.id),
])

for move_line in move_lines:
if not move_line.location_id.should_bypass_reservation():
move_lines_to_unreserve.append(move_line.id)

if len(move_lines_to_unreserve) > 1:
env.cr.execute(""" UPDATE stock_move_line SET product_uom_qty = 0, product_qty = 0 WHERE id in %s ;""" % (tuple(move_lines_to_unreserve), ))
elif len(move_lines_to_unreserve) == 1:
env.cr.execute(""" UPDATE stock_move_line SET product_uom_qty = 0, product_qty = 0 WHERE id = %s ;""" % (move_lines_to_unreserve[0]))



Avatar
Buang

Not working odoo13 Enterprise Edition

Jawaban Terbai

Hi,

Enable debug mode and navigate to server action menu under settings and see if there is a server action named:  Correct inconsistencies for reservation

If found, click on Run button, which will solve the issue, if server action is not found, pull the latest source code of corresponding odoo version and upgrade the stock module.


More info:  https://github.com/odoo/odoo/commit/e0e63be484b0ebddc7d498a4a13b2ba7a7f1a1f4#diff-c0d27a4adc8bbd305125f4e2729e30fe444fdd4e5ca0f96f2dd7f1fab19fe80eR17


Thanks

Avatar
Buang
Jawaban Terbai

Hello we have tried the above solution, but we still keep getting the above error on an odoo.sh instance. Kindly assist us accordingly.

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Mar 23
4352
2
Sep 24
30234
1
Feb 25
16147
0
Mei 21
15
1
Mei 25
844