Hi,
I need to pull through a boolean field from res.partner to account.invoice in order to filter invoices based on Partner data.
From what I've read this can be accomplished through a related field. I can see there's some documentation here -
https://www.odoo.com/documentation/8.0/reference/orm.html and a different example here -
https://odedrabhavesh.blogspot.co.uk/2015/02/how-related-field-work-in-odoo.html however I'm not to sure where this code would go. The second link seems to be suggesting that I need to create a module from the looks of it? It's also not very clear what each parameter does in the second example:
class sale_order_line(osv.Model):
_inherit = 'sale.order.line'
_columns = {
'product_categ_name': fields.related('product_id', 'categ_id', 'name', type='char', string='Product Category', store=True, readonly=True ),
}
_inherit - I assume this is the model that we want to modify
product_categ_name - name of the related field
product_id - id of the record we are linking to, in this case Product model
categ_id - ?
name - I assume this is name of the field from the other model that we want the value to be?
type - field type
string - field label
store - whether to store the computed value on the database
readonly - read only or not
In my case I would need to do something like this?
class bank_account_active(osv.Model):
_inherit = 'account.invoice'
_columns = {
'bank_account_active': fields.related('partner_id', '???', 'restrict_invoice', type='boolean', string='Bank Account Active', store=True, readonly=True ),
}
If anyone can push me into the right direction would great. I haven't done much python with Odoo just yet, outside from adding some python expressions through the interface, which is probably why I'm feeling a little lost here.
Thanks.