Odoo Help

Welcome!

This community 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.

0

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

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

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.


1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

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

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

Your Answer

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!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/22/16, 4:28 AM
Seen: 226 times
Last updated: 6/22/16, 8:26 AM