Odoo Help


[V8/9] Customer record approval

on 10/14/15, 11:19 AM 541 views

Any possibility to add workflow for customer module?

This workflow having purpose to make approval for new record and modification that's applied.

Before customer record have approved state, customer will not able to started create quotation, opportunity etc.




Akhil P Sivan

--Akhil P Sivan--
| 5 3 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 10/15/15, 7:24 AM


You can add workflow to res.partner model. Inorder to have only approved customers in quotations, opportunity etc, later you can domain filter the many2one field using state = approved.

For eg, am adding just two states "New" and "Approved". Please try the following code:

in your python file:

class res_partner(models.Model):

_inherit = 'res.partner'

('new', 'New'),
('approved', 'Approved'),

state = fields.Selection(STATE_SELECTION, 'Status', readonly=True,
help="New customer created. "
"New Customer approved. ",
def write(self, vals):

if self.state == 'approved':

return super(res_partner, self).write(vals)

def approve_customer(self):

in your workflow xml file:

<?xml version="1.0" encoding="utf-8"?><openerp>

<record id="customer_flow" model="workflow">
<field name="name">Custmer Workflow</field>
<field name="osv">res.partner</field>
<field name="on_create">True</field>

<record id="act_new" model="workflow.activity">
<field name="wkf_id" ref="customer_flow"/>
<field name="flow_start">True</field>
<field name="name">new</field>
<record id="act_approved" model="workflow.activity">
<field name="wkf_id" ref="customer_flow"/>
<field name="name">approved</field>
<field name="flow_stop">True</field>
<record id="trans_new_confirmed" model="workflow.transition">
<field name="act_from" ref="act_new"/>
<field name="act_to" ref="act_approved"/>
<field name="signal">customer_confirm</field>


in your xml view file:

	<record id="view_partner_form_with_states" model="ir.ui.view">
<field name="name">Add states to customer</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">

<sheet position="before">
<button name="approve_customer" states="new" type="object" string="Approve" class="oe_highlight" />
<field name="state" widget="statusbar" statusbar_visible="new,approved" statusbar_colors='{"new":"blue","approved":"blue"}' readonly="1" />

Hope this helps!

Hi Akhil P Sivan, that's great and thanks for your response. I already try your code, here my several question: 1. When I click approve button, there are no log for this action. For create or change, usually we saw log / note at the bottom side. 'Note by Administrator - 12:28 AM Partner created". How to add this function when click approved button. 2. When user change or edit the record, this record are back into New State or Draft state again. So, user need to approved those change, before continue. How to catch edit action or is there any mechanism to do that? 3. Is it possible when we have 2 workflow and 2 status bar. Let say for New record and approval process, 1 workflow. After new record approved, this become change request / modification, so there is 1 workflow again for Modification and Approval, also for status bar, will be shown modification and approval. Thanks and Regards, Andreas

on 10/17/15, 1:35 PM

1 more, do you have any idea to setup approval button for several group or user only. So for approval only appear when state New and user level Manager. Thanks.

on 10/17/15, 1:43 PM

Hi Andreas, you can catch the edit action either by the write() or a boolean field. So you can do the changes approval. Its possible modify the workflow like you said, this is just an example to show you how it can be possible. Just refer purchase_workflow.xml and try to modify this according to your needs. You can use security groups to make Approve button visible only for manager. If my answer helps you, please do upvote.

Akhil P Sivan
on 10/18/15, 6:01 PM

Andreas, I have updated the answer. So when you edit the state goes back to "draft", which you can approve later. To make it visible only to Manager, you can use groups attribute on the button.

Akhil P Sivan
on 10/19/15, 6:17 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/14/15, 11:19 AM
Seen: 541 times
Last updated: 10/20/15, 10:41 AM