Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2479 มุมมอง

Hello, i need help. I added job_title_2 in sale.order and want to bring job_title_2 field to account.invoice also automated field based on job_title or partner_id record. How to resolve this ?


class SaleOrder(models.Model):
    _inherit = 'sale.order'
​​ ​job_title = fields.Char('Job Title') ​job_title_2 = fields.Char('Job Title 2')


class AccountInvoice(models.Model):
    _inherit = 'account.invoice'
​job_title_2 = fields.Char('Job Title 2')

I'm overriding function but seems still not working

@api.multi
def _prepare_invoice(self):
    res = super(SaleOrderLine, self)._prepare_invoice()
    res['job_title'] = self.job_title
    res['job_title_2'] = self.job_title_2
    return res

What's wrong with my code ? thanks







อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Did you add the _prepare_invoice function in sale.order model or sale.order.line model ? as per the class used inside the super method, it seems the function is added in the sale.order.line model,  can you move it to the sale.order model and update the class name in super method and see.

Thanks

อวตาร
ละทิ้ง
ผู้เขียน

hello, i added _prepare_invoice function on sale.order.line because take example from base sale.order and trying to overriding it.

as suggested in answer add it in sale.order model, so that you can pass value from sale to invoice.

in odoo module, there is no function _prepare_invoice in sol model

ผู้เขียน

I already tried change to sale.order but still not working, is there any still missing on it ?

Related Posts ตอบกลับ มุมมอง กิจกรรม
Odoo 11 Hide EDIT & DELETE แก้ไขแล้ว
1
มี.ค. 21
3593
0
ส.ค. 25
705
1
มี.ค. 24
1664
Hide menu for all except specific group แก้ไขแล้ว
1
พ.ย. 22
3712
Live tracking in odoo. แก้ไขแล้ว
2
ส.ค. 22
8109