I need help with bringing the job_title_2 field data from class sale.order to account.invoice based on the record from job_title.
class SaleOrderLine(models.Model):
_inherit = 'sale.order'
job_title = fields.Char('Job Title')
job_title_2 = fields.Char('Job Title 2')
class InvoiceLine(models.Model):
_inherit = 'account.invoice'
job_title = fields.Char('Job Title')
job_title_2 = fields.Char('Job Title 2')
I tried using but not working
@api.depends('sale_order_id')
def get_order(self):
if self.sale_order_id:
self.job_title_2= self.sale_order_id.job_title_2
The
get_ordermethod will not be triggered and the value ofjob_title_2will not change. To use a computed method, you need to set the compute parameter on thejob_title_2field.Example:
The
account.invoicemodel must have asale_order_idfieldIf you want to bring fields from the sale order to the account invoice, you can override the sale order _prepare_invoice method and add your field values
Example: