How to Configure the Print Button Access Right in Odoo

Based on my experience as an odoo programmer so far, many client requests are related to access rights. For example, user A can perform X action while user B can’t, including print button access right. This is the reason why I create this print button access right module.

Odoo itself has many reports, almost every form has a print button to print this report, so I tried to make a module that can be adjusted as dynamically as possible. My hope is that the user can easily manage the print button access right via the user interface. No need to create a module or addon to configure the access right of each print button on each form. Of course this module is only for solving common problems, the needs of each company are certainly different from other companies, and of course it is not easy to make a module that solve every companies needs and problems 🙂

You can download the module at my github page. The following are some scenarios that you can do with this module.

Makes All Users Unable to Print the XXX Report

For example, if you want that all users can not print the Quotation / Order report, you can do this easily. First, make sure that the module has been installed, sign in as Administrator then enter to debug mode. Open the Settings >> Technical >> Reporting >> Print Access Right menu. Create a new record, fill in the Name field with any words as you want. In the Document field, select the report name that will be affected by the access rights, for example the Quotation / Order. In the Type field select Fixed. Check the Apply To All User field. And finally, in the Error Message field, fill in with the message that will appear to user when they clicks the print button. Don’t forget to click the Save button to save the configuration.

If there are users who try to print the Quotation / Order report, including Administrator, an error message will appear as shown below.

Makes User XXX Unable to Print YYY Report

In the previous scenario, the Quotation / Order report is configured that it cannot be printed by all users. So what if we want that the restriction above to be applied to certain users only ? The method is quite easy, just uncheck the Apply To All User field, then a new field with the name of Apply to Specific User will appear. Select which users will be affected by the access rights, as shown below.

If a user which his name exist in the Apply to Specific User field configuration tries to print a report, an error message will appear as shown below.

Makes User XXX Can Print the YYY Report ZZZ Times Only

The next scenario that can be applied using this module is to limit the user so that they can print a report a few times only. For example, if you want to configure that the Marc Demo user can print the Delivery Slip report 2 times only, you can select the Fixed Print Count in the Type field, then a new field with the name of Max Print Count will appear, enter the maximum number that the user can print the report.

If an affected user tries to print a report more than the Max Print Count configuration an error message will appear.

You can enter to the Settings >> Technical >> Reports menu, then select one of the report names that you have give the access right, then look at the Print Count tab to monitor how many times the user XXX have printed the documents with the YYY id.

The Record ID field in the picture above is the id or primary key of the transaction that has been printed by the user. Of course, you can change the value of the Count field, for example, in certain cases the user has exceeded the maximum limit for printing a report, but you want to give the user the opportunity to print the report again.

Of course if you want that the above permissions to affect all users, you can just check the Apply to All User field.

Makes User XXX Unable to Print YYY Report If ZZZ Condition Matched

The easiest example of this scenario is, for example, if you want that user XXX can not print an invoice if the partner (customer or vendor) on the invoice has the name of Azure Interior. To do this, in the Type field select the By Condition then a new field named Condition will appear. Click the Edit Domain button, a window will appear, then make a domain as you need.

How to create a domain is the same as when you create a condition on the Promotion Program menu to configure the coupons or discounts on sales order. You can create a domain in a few clicks by clicking the Add Filter button then a line with 3 fields will appear. In the field on the left, you can choose what fields that you will use as the basis for the filter. For example, select partner_id. The field in the middle is used to compare between the fields on the left and the right, for example to compare whether the left field is smaller than the right field, whether the left field contains words like the right field and other conditions. The options you can select in the middle field depend on the type of field you select in the left field. While the right field itself is the value that will be used as a comparison, fill in as needed.

You can also write the domain directly in the Code Editor section.

Similar to previous scenarios, if a user with affected access rights tries to print a transaction and the conditions are matched, in this case trying to print an invoice with a partner named Azure Interior an error message will appear.

Of course, if the user tries to print an invoice with a partner other than Azure Interior the error message will not appear, normal as usual.

The fields that you can choose as condition are the fields in the main model associated with the report that you configure, for example if you want that user XXX can not print the invoice if there is a line with YYY product on the invoice, then this cannot be applied.

Makes User XXX Unable to Print YYY Report If ZZZ Conditions Are Matched and He Has Printed the Report AAA Times

This is the last scenario you can do with this module. This scenario is actually a combination of previous scenarios, namely a combination of the By Condition and Fixed Print Count types. As a case study, for example, if you want that user XXX can print the Purchase Order document with the vendor name of Deco Addict 2 times only.

To do this, in the Type field, select the By Condition and Print Count then 2 new fields will appear, namely the Max Print Count and the Condition field. Fill in the limit of the number of times the user can print documents in the Max Print Count field. Then fill in the Condition field with the conditions as you want.

Related Article

Leave a Reply

Your email address will not be published.