تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5412 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

@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)]" />

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

@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) ??

 

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مارس 15
3627
2
فبراير 23
4004
1
يناير 22
4075
5
أبريل 17
7623
1
مارس 15
5587