Editor
Course content

How to add custom conditions


Custom conditions are python expression used to include/exclude approver to/from PO approval workflow. 



Examples:

If you want to include additional approver only for vendors from United States:
result = PO.partner_id.country_id.code == 'US'
("code" is the ISO country code in two chars)

Additional approver only for particular vendor: (Include)
result = PO.partner_id.name == 'Gemini Furniture'

If you want to exclude an approver for particular vendor.                                                                                                        result = PO.partner_id.name != 'partner name'  

Add additional approver only for particular period (using Order Date):
result = '2021-08-09' <= str(PO.date_order) <= '2021-08-15'

Add additional approver only for orders from particular company employee:
result = USER.company_id.name == 'YourCompany'

Add additional approver only for orders from particular department member:
result = USER.department_id.name == 'IT Department'
(Applicable only if HR module used)

Add additional approver only for particular product
result = PO.order_line.filtered(lambda line:line.product_id.name == 'Lychee Ice by Dinner Lady')

If you want to exclude an approver for particular vendor                                                                                                           




Lets see how we can apply python codes for any of the above examples.

Will get the following python code as a sample

Additional approver only for particular vendor:
result = PO.partner_id.name == 'Test Vendor'

If you want to include a particular vendor or vendors to an approver, 

01. Select an approver >> add the selected vendor to above mentioned Include python code. (result = PO.partner_id.name == 'Gemini Furniture') 

02. If you have multiple vendors you can add Comma (,) and add the name inside the inverted comma as seen in the above example. 

Now whenever you create a PO to included vendor this particular assignee must approve the PO

If you want to exclude any of the approver for particular vendor or vendors

01. Select an approver >> add the selected vendor to above mentioned exclude python code.  (result = PO.partner_id.name != 'partner name') 

02. If you have multiple vendors you can add Comma (,) and add the name inside the inverted comma as seen in the above example. 

Now whenever you create a PO to the mentioned vendor/s with the same PO team, specified approver with custom condition to exclude will excluded for approvals.


Rating
0 0
Views
74 Total Views
1 Members Views
73 Public Views