Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to set value for a combobox in a method

By
E.M.
on 9/21/15, 6:20 PM 605 views

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.

2

Axel Mendoza

--Axel Mendoza--
10263
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 9/21/15, 11:54 PM

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.

E.M.
on 9/22/15, 5:25 PM

Happy to help

Axel Mendoza
on 9/22/15, 5:48 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/21/15, 6:20 PM
Seen: 605 times
Last updated: 9/22/15, 5:21 PM