Well this is not completly right. There is an execption to handle and is the user who should handle it. Here is an scenario to reproduce the problem:
- Create a sale with invoice method set to “On shipment”
- Add a product without accounting configuration set
- Quote, Confirm and process the sale
- Open the related shipment and deliver it.
Once the shipment is done, the following exception is raised at the server log:
Traceback (most recent call last):
File "/home/pokoli/projectes/nclone/trytond/trytond/worker.py", line 114, in run_task
File "/home/pokoli/projectes/nclone/trytond/trytond/ir/queue.py", line 176, in run
File "/home/pokoli/projectes/nclone/trytond/trytond/model/modelview.py", line 773, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/pokoli/projectes/nclone/trytond/trytond/modules/sale/sale.py", line 985, in process
File "/home/pokoli/projectes/nclone/trytond/trytond/modules/sale/sale.py", line 815, in create_invoice
File "/home/pokoli/projectes/nclone/trytond/trytond/modules/sale/sale.py", line 1482, in get_invoice_line
invoice_line.account = self.product.account_revenue_used
File "/home/pokoli/projectes/nclone/trytond/trytond/modules/account_product/product.py", line 51, in prop
return getattr(self.template, field_name)
File "/home/pokoli/projectes/nclone/trytond/trytond/modules/account_product/product.py", line 38, in wrapper
trytond.modules.account_product.exceptions.AccountError: There is no "Account Category" defined for "[PD000023]Product without accounting". -
But the user nevers sees that this error is raised. This does not sound wrong to me because the stock workflow should not be blocked because of wrong configuration.
The problem is that if you go back to the sale, you will see:
- State is “Processing”
- Invoice state is “None”
- Shipment state is “Waiting”
From there you can not know that there is a problem with this sale so it’s very complex to find it for the end user and it will have wrong consequences for the company.
You are right, resuing the same invoice_state or shipment_state will be complex and will raise the handle exception wizards when there is nothing to do with it. But this does not means that we should hide the error to the end user.
So I think we only have another option here: Add a new “Error” state on the document workflow.
Absolutly right, but we should find a way to trigger another transaction in the case there is an error with the task. For the sale/purchase workflow I think it can be a function like:
def process_exception(cls, sales):
for sale in sales:
sale.state = 'error'
And then show the sales with error on the exception tab.
From there, the user will be able to click the process button and the error will be shown to their screen. So he will be able to fix and create the invoice.
Also it should be possible to trigger notifications (using notification_email) to send an email to the responsible of the current sale.
This is very tailored to the sale purchase workflow, but as far as we have a way to trigger an “exception task” when there is an error on the main task it can be reused for any task queue.
I’m open to any other solution that may fix the problem if you have any but I think this is something that we need to deal with once we have the background processing.