Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5671 Ansichten

Hii,

I have a custom field added in the header of the account.invoice. I have added the same custom filed to account.invoice.line.
When I create an Invoice directly or from PO I assign a value to this field.
How to pass custom field value to from invoice header to all lines?

I have done it  overriding write() and onchage() methods but no luck on create() method. 

How to pass it by overriding create() method.

I am doing it the following way but not working...

@api.model
def create(self, values):
result = super(FFTAccountInvoice, self).create(values)
     values.update({'invoice_line_ids': [(0, 0, {'shipment_id': result['shipment_id'].id})]})
     return result



Avatar
Verwerfen
Autor Beste Antwort

The requirement can be achieved by overriding create() and write() methods, or even field onchage() method.
But I have done it by Related field as following and it is working fine with me..

class TTAccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
    shipment_id = fields.Many2one('purchase.shipment', string='Shipment', related='invoice_id.shipment_id', store=True)

 in account.invoice i have custom filed shipment_id. So related='invoice_id.shipment_id'.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Sept. 24
11217
1
Juni 23
2319
1
Apr. 23
11392
1
Juni 22
2652
0
März 22
2