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.

1

How to define onchange method ? odooV8

By
Ajeng Shilvie
on 12/11/14, 11:37 PM 912 views

How can i make it ?

i make a custome module , the fields are :

many2one invoice_id(refer to customer invoice number), 

many2one order_line (refer to account.invoice.line, the invoice number same as selected invoice_id)

many2one customer_id(refer to partner_id in customer invoice that has the same number as selected item in invoice_id field),and

address field(refer to customer's address in selected invoice_id too)

here's the code :

class faktur(osv.osv):
    _name = 'permohonan.faktur'
    _columns = {

        ''invoice_id': fields.many2one('account.invoice',string='Invoice',domain=[('state','=','paid'),('type','=','out_invoice')],required=True),

        'order_line': fields.many2one('account.invoice.line', string='Order Line', required=True),
        'customer_id': fields.many2one('res.partner', string='Customer',required=True),
        'address': fields.char('Address',23),
    }

here is xml code :

record model="ir.ui.view" id="permohonan_faktur_form_view">
    <field name="name">permohonan.faktur.form</field>
    <field name="model">permohonan.faktur</field>
    <field name="arch" type="xml">
        <form string="Form Permohonan Faktur STNK" version="7.0">
        <group col="2" string="Permohonan Faktur STNK">
            <group >
                <field name="invoice_id" context="{'form_view_ref':'account.invoice_form'}"/>
                <field name="order_line" />
                <field name="customer_id"/>
                <field name="address"/>
              </group>
           </group>
        </form>
    </field>
</record>

i want address and customer_id field onchange when i select invoice_id , i want order_line value defend on selected invoice number..

1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 12/12/14, 12:15 AM

@Ajeng

You can try the following for onchange method in odoov8

To use the following way.. you need import the following and inherit it

from openerp import models,fields,api

class faktur (models.Model)

@api.onchange('invoice_id')
def onchange_invoice_id(self):
    if self.invoice_id:
    """Your code goes here"""
    """finally"""
    self.customer_id = <some partner id based on your code>
    self.address= <some address id based on your code>

Note: I don't understand why are you using "many2one" for "order_line", because there could be more than one invoice line against an invoice.

But in case you want to load only those invoice line based on the selected invoice_id than you can apply the following domain in your view:

<field name="order_line" domain="[('invoice_id','=',invoice_id)]" />

0
Ajeng Shilvie
On 12/12/14, 1:08 AM

@Emipro

the domain for "order_line" it worked, thank you.

but i am sorry, i am new in odoo.. i don't understand using @api, do i have to use class faktur (models.Model) instead class faktur(osv.osv) ??

 

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: 12/11/14, 11:37 PM
Seen: 912 times
Last updated: 3/16/15, 8:10 AM