Odoo Help


How to relate the customers of accounting with my new module?

Uppili Arivukkannu
on 6/22/16, 4:28 AM 647 views

I have created a new module


from openerp.osv import fields, osv

class carbuy(osv.osv):
_name = "car.buy"
_description = "car Customers"
_columns = {
'name' : fields.char('Car Model',required=True),
'cname' : fields.char('Customer Name', required=True),
'bprice' : fields.float('Bought Price', required=True),
'sprice' : fields.float('Sold Price' , required=True),




<record id="car_buy_form" model="ir.ui.view">

<field name="name">car.buy.form</field>

<field name="model">car.buy</field>

<field name="type">form</field>

<field name="arch" type="xml">

<form string="carbuy customer details">



<field name="name"/>

<field name="cname"/>

<field name="bprice"/>

<field name="sprice"/>






<record model="ir.ui.view" id="carbuy_tree_view">

<field name="name">carbuy.tree</field>

<field name="model">car.buy</field>

<field name="type">tree</field>

<field name="arch" type="xml">

<tree string="carbuy customer details">

<field name="name"/>

<field name="cname"/>

<field name="bprice"/>

<field name="sprice"/>




<record model="ir.actions.act_window" id="car_buy_form">

<field name="name">carbuy Customers</field>

<field name="res_model">car.buy</field>


<menuitem name="carBuy" id="carbuy_menu"/>

<menuitem name="carbuy" id="carBuy_group_menu" parent="carbuy_menu"/>

<menuitem name="carbuy Customers" parent="carBuy_group_menu" id="carbuy_menu_mainform" action="car_buy_form"/>



I have call the customer name as the many2one field.

so that it has to show the customer details or customer name which is in Accounting.

In simple when I click the customer name field in my new module it has to show the details or name of the customers in the Customers section of accounting.

For example:

In hr_attendance the field employee_id

'employee_id': fields.many2one('hr.employee', "Employee", required=True, select=True)

It calls the employees in the class hr_employee when the employee field is clicked in hr_attendance.

Likewise I want to call the customer name from accounting to my new module.

Give me some suggestions.


--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 6/22/16, 7:35 AM


If I got you right, then you need to make a many2one field with res.partner to your module as:

'customer_id': fields.many2one('res.partner', 'Customer', domain=[('customer', '=', True)])

hope this could help

Thank you it works

Uppili Arivukkannu
on 6/22/16, 8:26 AM

Thanks for your help. I need another help how to call the suppliers field in my new module field. The supplier is also in the accounting section.

Uppili Arivukkannu
on 6/22/16, 9:42 AM

I got the solution for the suppliers. Thanks for your help

Uppili Arivukkannu
on 6/22/16, 9:50 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: 6/22/16, 4:28 AM
Seen: 647 times
Last updated: 6/22/16, 8:26 AM