In the contact form, I notice a field named "Credit limit" in the Accounting tab. But if I set a value, nothing happens when I override this limit during a sale operation? How can I set up a blocking mechanism in the sales order validation?
You need to add a condition in the first transitions of the sales workflow: i.e. Credit limit > Total receivable (the amount the customer owes you) + Amount of the new SO.
So open the sales workflow (either from the developer drop-down menu, or from Settings > Technical > Workflows > Workflows). Then, add the following condition in the two order_confirm transitions (between draft & sent to routernodes): partner_id.credit_limit > partner_id.credit + amount_total (replacing True). Use the Diagram view to find them in an easier way.
From now on, everytime you try to validate a sales order, the SO status remains on "Quotation" if the sum of the amount the customer owes you and the new SO amount is higher than his credit limit.
however I changed the formula slightly to
"partner_invoice_id.credit_limit > partner_invoice_id.credit + amount_total"
Reason is we give give credit to the company not each employee of that company! We use OpenERP this way - Sales>Sales>Quotations> Create
The customer is "Fred Blogs" who works for "Smiths Industries" this person has 0 Credit The Invoice Address is "Smiths Industries" who has a credit of XXX GBP
This way we track who placed the order and can communicate with that individual, but all invoices go the company.
For each transition in a workflow, you can add a condition
Go in the menu 'Settings > Technical > Workflow > Transitions' and select a transition such as 'invoice_open'
Replace the default condition 'True' by this one 'partner_id.credit-amount_total>partner_id.credit_limit'
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!