Template Print Model Copies on Business Objects

A new feature allows creating a copy of a template print model for a specific business object.

To use this feature:

  1. Add a many-to-one field templatePrintModel on your business object domain:

    <many-to-one name="templatePrintModel" title="Template print model" ref="com.axelor.template.db.TemplatePrintModel"/>
  2. Add the field to your XML view:

    <field name="templatePrintModel" domain="self.uploadStatus = 'ok' AND self.original = NULL AND self.templateSettings.model = :_xModelName"/>
    <field name="_xModelName" x-dirty="false" hidden="true"/>
  3. When onLoad event is triggered, call this action (after the actions already called by default):

    <action-record name="action-[modelName]-record-set-model-name" model="[model FQN]">
      <field name="_xModelName" expr="eval: _model?.substring(_model?.lastIndexOf('.') + 1)"/>
    </action-record>

    Example for Invoice model:

    <action-record name="action-invoice-record-set-model-name" model="com.axelor.apps.account.db.Invoice">
      <field name="_xModelName" expr="eval: _model?.substring(_model?.lastIndexOf('.') + 1)"/>
    </action-record>

    The action name can be customized as needed.

  4. Add a button to create the copy:

    <button name="createCopyBtn" title="Copy" onClick="action-template-print-model-group-copy-template"/>
  5. Add the studio panel dashlet:

    <panel-dashlet colSpan="12" height="800" action="action.template.print.model.view.generic.studio"/>
The field name must be templatePrintModel. Names, titles, and component sizes can be customized as needed.