9.6 KiB
9.6 KiB
Odoo Troubleshooting
Odoo-Client-Fehler
Problem
After restoring an Odoo instance the following error occurs
Fehler:
Zurückverfolgung
_generateActionViews/<@https://metallprojekt.mintsys.ch/web/content/625-ed50555/web.assets_backend.js:447:298
_.forEach@https://metallprojekt.mintsys.ch/web/content/606-2d12e2f/web.assets_common.js:108:566
_generateActionViews@https://metallprojekt.mintsys.ch/web/content/625-ed50555/web.assets_backend.js:447:229
_executeWindowAction/<@https://metallprojekt.mintsys.ch/web/content/625-ed50555/web.assets_backend.js:442:497
Solution
Reassmble all assets. Alernatively delete assets entries.
Python OSError
Problem
When generating a report with p3yo this error occurs:
OSError: [Errno 8] Exec format error: '/usr/local/bin/libreoffice'
Solution
Apply shebang line #!/bin/sh in shell script.
**
wkhtmlpdf unpatched
Problem
wkhtmltopdf: b'The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.'
Solution
cd ~
# Select an appropriate link for your system (32 or 64 bit) from the page https://wkhtmltopdf.org/downloads.html and past to the next line
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4\_linux-generic-amd64.tar.xz
tar xvf wkhtmltox\*.tar.xz
sudo mv wkhtmltox/bin/wkhtmlto\* /usr/bin
sudo apt-get install -y openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig
Watch limit reached
Problem
OSError(errno.ENOSPC, "inotify watch limit reached")
Solution
Temporary:
sudo sysctl fs.inotify.max_user_watches=524288
Cannot unreserve product in stock
Problem
It is not possible to unreserve more products of $PRODUCT_NAME than you have in stock.
Es ist nicht möglich, die Reservierung für mehr Produkte von $PRODUKTNAME auzuheben als im Lager vorhanden sind.
Solution
- Enable debug mode
- Open technical > server actions
- Click create
- Set action name: e.g. report unreserved qty
- Select model: ir.actions.server
- Set action to do: "execute python code"
- Copy/paste the fix underneath the pre-existing code
- Click "save"
- Start the action
- Wait for log message
The script https://gist.github.com/amoyaux/279aee13eaddacbddb435dafbc0a6295.
Report Unreserved Qty
quants = env['stock.quant'].search([])
move_line_ids = []
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)
])
move_line_ids += move_lines.ids
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:
warning += "Problematic quant found: %s (quantity: %s, reserved_quantity: %s)\n" % (quant.id, quant.quantity, quant.reserved_quantity)
warning += "its `reserved_quantity` field is not 0 while its location should bypass the reservation\n"
if move_lines:
warning += "These move lines are reserved on it: %s (sum of the reservation: %s)\n" % (move_line_str, reserved_on_move_lines)
else:
warning += "no move lines are reserved on it, you can safely reset its `reserved_quantity` to 0\n"
warning += '******************\n'
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:
warning += "Problematic quant found: %s (quantity: %s, reserved_quantity: %s)\n" % (quant.id, quant.quantity, quant.reserved_quantity)
warning += "its `reserved_quantity` field is 0 while these move lines are reserved on it: %s (sum of the reservation: %s)\n" % (move_line_str, reserved_on_move_lines)
warning += '******************\n'
elif quant.reserved_quantity < 0:
warning += "Problematic quant found: %s (quantity: %s, reserved_quantity: %s)\n" % (quant.id, quant.quantity, quant.reserved_quantity)
warning += "its `reserved_quantity` field is negative while it should not happen\n"
if move_lines:
warning += "These move lines are reserved on it: %s (sum of the reservation: %s)\n" % (move_line_str, reserved_on_move_lines)
warning += '******************\n'
else:
if reserved_on_move_lines != quant.reserved_quantity:
warning += "Problematic quant found: %s (quantity: %s, reserved_quantity: %s)\n" % (quant.id, quant.quantity, quant.reserved_quantity)
warning += "its `reserved_quantity` does not reflect the move lines reservation\n"
warning += "These move lines are reserved on it: %s (sum of the reservation: %s)\n" % (move_line_str, reserved_on_move_lines)
warning += '******************\n'
else:
if any(move_line.product_qty < 0 for move_line in move_lines):
warning += "Problematic quant found: %s (quantity: %s, reserved_quantity: %s)\n" % (quant.id, quant.quantity, quant.reserved_quantity)
warning += "its `reserved_quantity` correctly reflects the move lines reservation but some are negatives\n"
warning += "These move lines are reserved on it: %s (sum of the reservation: %s)\n" % (move_line_str, reserved_on_move_lines)
warning += '******************\n'
move_lines = env['stock.move.line'].search([('product_id.type', '=', 'product'), ('product_qty', '!=', 0), ('id', 'not in', move_line_ids)])
for move_line in move_lines:
if not move_line.location_id.should_bypass_reservation():
warning += "Problematic move line found: %s (reserved_quantity: %s)\n" % (move_line.id, move_line.product_qty)
warning += "There is no exiting quants despite its `reserved_quantity`\n"
warning += '******************\n'
if warning == '':
warning = 'nothing seems wrong'
raise Warning(warning)
The next script will resolve the issues:
Fix Unreserved Qty
Run as superuser.
#!/usr/bin/python
quants = env['stock.quant'].search([])
move_line_ids = []
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),
])
move_line_ids += move_lines.ids
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})
move_lines = env['stock.move.line'].search([('product_id.type', '=', 'product'), ('product_qty', '!=', 0), ('id', 'not in', move_line_ids)])
move_lines_to_unreserve = []
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])