Check if the current document can be print

Registered by Christophe CHAUVET

In some circumstance, we must block printing because there is missing information on the document (eg bad price on the quotation)

to made this customize as possible, we define some specification

If the osv.osv model have a function check_print, we execute it on the current document.
If this function return True we launch the report execution
If this function return False, we raise an error with a message define on the report definition
Otherwise we can raise a JasperException

eg

from osv import osv
from jasper_server.report.report_exception import JasperException
from tools.translate import _

class SaleOrder(osv.osv):
    _inherit = 'sale.order'

    def check_print(self, cr, uid, obj, context=None):
        if obj.state != 'draft':
            raise JasperException(_('Oups'), _('Game Over'))
        return True

SaleOrder()

Blueprint information

Status:
Complete
Approver:
Christophe CHAUVET
Priority:
Medium
Drafter:
Christophe CHAUVET
Direction:
Needs approval
Assignee:
Christophe CHAUVET
Definition:
Approved
Series goal:
Accepted for 6.0
Implementation:
Implemented
Milestone target:
milestone icon 6.5.9
Started by
Christophe CHAUVET
Completed by
Christophe CHAUVET

Related branches

Sprints

Whiteboard

See rev 208 and 209

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.