Skip to Content
Menu
This question has been flagged
1 Reply
4322 Views

Hello i have a question how to set automatically value field nomor_faktur_po on purchase.order when i set value field nomor_faktur_sp on stock.picking with onchange?

class stock_nomor_faktur(models.Model):

    _inherit = 'stock.picking'

nomor_faktur_sp = fields.Char(string='Nomor Faktur')


class stock_nomor_faktur(models.Model):

    _inherit = 'purchase.order'

    nomor_faktur_po = fields.Char(string='Nomor Faktur')


      My stock.picking view

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

        <field name="name">nomor_faktur_stock_picking</field>

        <field name="model">stock.picking</field>

        <field name="inherit_id" ref="stock.view_picking_form"/>

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

            <xpath expr="//field[@name='origin']" position="after">

                <field name="nomor_faktur_sp"/>

            </xpath>

        </field>

    </record>

My purchase.order View

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

        <field name="name">nomor_faktur_purchase_order</field>

        <field name="model">purchase.order</field>

        <field name="inherit_id" ref="purchase.purchase_order_form"/>

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

            <xpath expr="//field[@name='location_dest_id']" position="after">

                <field name="nomor_faktur_po"/>

            </xpath>

        </field>

    </record>



Avatar
Discard
Best Answer

Stock.picking having stock.move relation

stock.move having purchase.order.line relation

Try this one

@api.onchange('nomor_faktur_sp')
def ochange_nomor_faktur_sp(self):
    if self.move_lines:

        if self.move_lines[0].purchase_line_id:
            self.move_lines[0].purchase_line_id.order_id.nomor_faktur_po = self.nomor_faktur_sp

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 15
4389
0
Dec 24
59
1
Oct 23
364
2
Oct 23
679
2
Aug 23
1967