İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
5114 Görünümler

Hi,


 I have added a custom field like "custom_field" in my purchse.order.line and then i have added the same field in "account.move.line" which is used at Bill line. 


Now i want when i client the "Create Bill" button on my purchase order it should copy this field as well from purchase.order.line to account.move.line. Below is the core code on 'purchase.order. model. 


Please guide me how i can do this. thank you


def action_view_invoice(self):

        '''

        This function returns an action that display existing vendor bills of given purchase order ids.

        When only one found, show the vendor bill immediately.

        '''

        action = self.env.ref('account.action_move_in_invoice_type')

        result = action.read()[0]

        create_bill = self.env.context.get('create_bill', False)

        # override the context to get rid of the default filtering

        result['context'] = {

            'default_type': 'in_invoice',

            'default_company_id': self.company_id.id,

            'default_purchase_id': self.id,

        }

        # Invoice_ids may be filtered depending on the user. To ensure we get all

        # invoices related to the purchase order, we read them in sudo to fill the

        # cache.

        self.sudo () ._ read (['invoice_ids'])

        # choose the view_mode accordingly

        if len (self.invoice_ids)> 1 and not create_bill:

            result ['domain'] = "[('id', 'in'," + str (self.invoice_ids.ids) + ")]"

        else:

            res = self.env.ref ('account.view_move_form', False)

            form_view = [(res and res.id or False, 'form')]

            if 'views' in result:

                result ['views'] = form_view + [(state, view) for state, view in action ['views'] if view! = 'form']

            else:

                result ['views'] = form_view

            # Do not set an invoice_id if we want to create a new bill.

            if not create_bill:

                result ['res_id'] = self.invoice_ids.id or False

        result ['context'] ['default_invoice_origin'] = self.name

        result ['context'] ['default_ref'] = self.partner_ref

        return result




Avatar
Vazgeç
Üretici

thank you @Abdullah. 

En İyi Yanıt

You have a function name def _prepare_account_move_line in purchase.order.line,, inherit it and pass your valiue in it like

return{

'your_custom_field_in_invoice_line' : self.your_custom_field_in_purchase_order_line

}

Hope it helps. Thanks

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Haz 23
2398
0
Kas 20
3851
1
Kas 21
3744
3
Eyl 21
4943
4
May 21
28847