This question has been flagged

I have created a new module

.py


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),
}


.xml

<openerp>

<data>

<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">

<sheet>

<group>

<field name="name"/>

<field name="cname"/>

<field name="bprice"/>

<field name="sprice"/>

</group>

</sheet>

</form>

</field>

</record>

<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"/>

</tree>

</field>

</record>

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

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

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

</record>

<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"/>

</data>

</openerp>


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.

Thanks.


Avatar
Discard
Best Answer

Hello,

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

Avatar
Discard
Author

Thank you it works

Author

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.

Author

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