I've created a custom boolean field that appears in Sale Order lines and Invoice lines, and now I'm trying to transfer the values of the field to the Invoice when created from the Sale Order (wether the checkbox is marked or not...TRUE or FALSE), but for some reason my code is not working as expected, I'm not getting any error, but the values aren't being transfered from one module to the other either.
This is my code:
ti_print_report_lines_choice.py:
from openerp.osv import fields, osv, orm
from tools.translate import _#Create fields in different models
class ti_print_choice_sale_order_line(osv.osv):
_inherit = 'sale.order.line'
_columns = {
'x_printable_choice': fields.boolean(
"Don't print",
help='Mark if this product will NOT be printed in reports'
),
}
ti_print_choice_sale_order_line()class ti_print_choice_account_invoice_line(osv.osv):
_inherit = "account.invoice.line"
_columns = {
'x_printable_choice': fields.boolean(
"Don't print",
help='Mark if this product will NOT be printed in reports'
),
}
ti_print_choice_account_invoice_line()
#Copy fields between modules: From Sale Order to Invoice
class sale_order(orm.Model):
_inherit = 'sale.order'def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
res = super(sale_order, self)._prepare_invoice(
cr, uid, line, account_id=False, context=context
)
res.update({
'x_printable_choice': line.x_printable_choice,
})
return res
sale_order()
I will be doing the same for Purchase Orders and Stock Moves...but for the sake of simplicity I've excluded it from this question
Any help or insight is appreciated