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

I have a combobox defined in res.partner:


payment_method = fields.Selection(
selection=[
('bank_transfer', 'Transferencia Bancaria'),
('check', 'Cheque'),  
('direct_debit', 'Domiciliación')
],
string='Método de pago')

I have the same combobox defined in account.invoice.

Then I have a method redefined in account.invoice to set the combobox to the value set in res.partner when partner is selected:

        @api.multi
def onchange_partner_id(self, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
payment_method = ***RETRIEVE payment_method FROM partner_id and assign to payment_method in account.invoice****
return super(account_invoice, self).onchange_partner_id(type, partner_id, date_invoice=date_invoice, payment_term=payment_term, partner_bank_id=partner_bank_id, company_id=company_id)


How can I retrieve the value payment_method from res.partner and assign to account.invoice form payment_method?

Both combos appears fine in both forms (res.partner and account.invoice) and value at res.partner can be stored correctly, I just want to programatically assign the value from res.partner to account.invoice form.

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

You could do it like this:

    @api.multi
def onchange_partner_id(self, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
result = super(account_invoice, self).onchange_partner_id(type, partner_id, date_invoice=date_invoice, payment_term=payment_term, partner_bank_id=partner_bank_id, company_id=company_id)
if partner_id:
partner = self.env['res.partner'].browse(partner_id)
result['value']['payment_method'] = partner.payment_method
return result
อวตาร
ละทิ้ง
ผู้เขียน

Thanks a lot Axel. Not only works but also helped me to further understand how to customize Odoo.

Happy to help

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 21
4137
4
ต.ค. 19
9934
How to multiply sequence by non-int แก้ไขแล้ว
1
ม.ค. 18
9300
1
ก.พ. 17
5198
0
ม.ค. 17
4450