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

Inheritance does not change the field attributes, odoo 9.0c

By
Artem
on 10/4/16, 6:38 AM 165 views

What is 'states' used in the following definition in the class AccountInvoice?

partner_bank_id = fields.Many2one('res.partner.bank', string='Bank Account',
        help='Bank Account Number to which the invoice will be paid. A Company bank account if this is a Customer Invoice or Vendor Refund, otherwise a Partner bank account number.',
        readonly=True, states={'draft': [('readonly', False)]})

As I understand the field must be readonly except when the field 'states' is equal to 'draft' but this class has not got the field 'states'. Or am I wrong?


And I want to change partner_bank_id field of account.invoice to be writable but it does not work, the field stays the same.

# -*- coding: utf-8 -*-
from openerp import api, fields, models, _
class AccountInvoice(models.Model):
    _inherit = "account.invoice"
    partner_bank_id = fields.Many2one('res.partner.bank', string='Account',readonly=False)

partner_bank_id is invisible on the form.

Are you sure you don't want to modify the journal_id field?

Mai Ecarde
on 10/4/16, 10:52 AM

I added it to my form and want to edit.

Artem
on 10/4/16, 12:01 PM

Thanks a lot to for help.

Artem
on 10/4/16, 12:32 PM

Sorry I am not sure I am seeing the whole picture. What functionality are you trying to achieve? Is it the ability to add a bank account to a partner via the invoice form or is it the ability to select the bank account for a partner from multiple configured?

Mai Ecarde
on 10/4/16, 7:57 PM

Also, what does the view definition look like? Perhaps you have the partner_bank_id field twice?

Mai Ecarde
on 10/4/16, 8:00 PM

I want to choose the bank account to print it in an invoice.

Artem
on 10/5/16, 9:28 AM

Yeh, the partner_bank_id field is already in the invoice_supplier_form on 'other info' page.

Artem
on 10/5/16, 9:30 AM

Fields don't work correctly if they are visible more than once on a form. Have you tried to show the field only once?

Mai Ecarde
on 10/10/16, 6:55 AM

Everything works perfectly. Thanks.

Artem
on 10/11/16, 1:15 PM
0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 10/4/16, 8:49 AM

Hi,

States works with the special field state.  Try this

partner_bank_id = fields.Many2one('res.partner.bank', string='Account',readonly=False, states={})


and try to restart and upgrade your modules ...

Hope this could helps



FYI, You should only need to modify the parts of the field that you want to change.

i.e. partner_bank_id = fields.Many2one(readonly=False, states={})

should be enough.

Mai Ecarde
on 10/4/16, 10:51 AM

I'm confused. I added just the partner_bank_id field to the sale invoice form and any value was not stored in this field despite my invoice was 'draft'.

The partner_bank_id field is mentioned in the 'create' method so I think nothing works because of this.

Artem
on 10/4/16, 12:30 PM

Thanks a lot to for help.

Artem
on 10/4/16, 12:33 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

2 follower(s)

Stats

Asked: 10/4/16, 6:38 AM
Seen: 165 times
Last updated: 10/6/16, 10:10 AM