shopinvader / odoo-shopinvader

Odoo Modules. Sorry Magento, Shopinvader is coming
GNU Affero General Public License v3.0
121 stars 104 forks source link

better error management when Odoo raises a UserError #163

Closed rvalyi closed 1 year ago

rvalyi commented 6 years ago

so for instance, when trying to pay a shopping cart, I have this Odoo error log:

2018-07-11 17:00:05,398 30248 ERROR shopinvader odoo.addons.sale_automatic_workflow.models.automatic_workflow_job: Error during an automatic workflow action.
Traceback (most recent call last):
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/sale-workflow/sale_automatic_workflow/models/automatic_workflow_job.py", line 23, in savepoint
    yield
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/sale-workflow/sale_automatic_workflow/models/automatic_workflow_job.py", line 64, in _create_invoices
    payment.with_context(active_ids=sale.ids).create_invoices()
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/odoo/addons/sale/wizard/sale_make_invoice_advance.py", line 134, in create_invoices
    sale_orders.action_invoice_create(final=True)
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/sale-workflow/sale_automatic_workflow/models/sale_order.py", line 73, in action_invoice_create
    final=final)
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/odoo/addons/sale/models/sale.py", line 346, in action_invoice_create
    inv_data = order._prepare_invoice()
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/sale-workflow/sale_automatic_workflow/models/sale_order.py", line 39, in _prepare_invoice
    invoice_vals = super(SaleOrder, self)._prepare_invoice()
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/odoo/addons/sale_stock/models/sale_order.py", line 71, in _prepare_invoice
    invoice_vals = super(SaleOrder, self)._prepare_invoice()
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/bank-payment/account_payment_sale/models/sale_order.py", line 27, in _prepare_invoice
    vals = super(SaleOrder, self)._prepare_invoice()
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/odoo-shopinvader/shopinvader/models/sale.py", line 66, in _prepare_invoice
    res = super(SaleOrder, self)._prepare_invoice()
  File "/home/rvalyi/DEV/shopinvader-voodoo/external-src/odoo/addons/sale/models/sale.py", line 287, in _prepare_invoice
    raise UserError(_('Please define an accounting sale journal for this company.'))
UserError: (u'Please define an accounting sale journal for this company.', '')

Such error may happen if Odoo is unable to deal with the request, that is fine. What is not user/developper friendly however is what happens then in the Rails part of ShopInvader with this stack trace:

#<NoMethodError: undefined method `include?' for nil:NilClass>
  Error: undefined method `include?' for nil:NilClass
  /home/rvalyi/.rvm/gems/ruby-2.5.1/bundler/gems/shopinvader-bb5ae0b118e2/lib/shop_invader/middlewares/erp_proxy.rb:32:in `_render_html'
/home/rvalyi/.rvm/gems/ruby-2.5.1/bundler/gems/shopinvader-bb5ae0b118e2/lib/shop_invader/middlewares/erp_proxy.rb:15:in `_call'
/home/rvalyi/.rvm/gems/ruby-2.5.1/bundler/gems/steam-0da298978835/lib/locomotive/steam/middlewares/thread_safe.rb:12:in `call'
/home/rvalyi/.rvm/gems/ruby-2.5.1/bundler/gems/steam-0da298978835/lib/locomotive/steam/middlewares/path.rb:13:in `call'

So the problem is that data is null and we don't re-catch the Odoo error in a decent way.

simahawk commented 3 years ago

still valid?

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.