问题
I have installed module Sale Sourced by Line by Camptocamp, Eficent, SerpentCS, Odoo Community Association (OCA) for Odoo 9.0. The module creates a new many2one field as the code bellow:
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
warehouse_id = fields.Many2one(
'stock.warehouse',
'Source Warehouse',
readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
help="If a source warehouse is selected, "
"it will be used to define the route. "
"Otherwise, it will get the warehouse of "
"the sale order")
Now i would like to access the value warehouse_id on account_invoice_report qweb. Please tell me what are posible solutions for my purpose? Thank for your time,
回答1:
In account.invoice.line one field available sale_line_ids, based on that you can search warehouse_id from sale.order.line.
invoice.invoice_line_ids.mapped('sale_line_ids').mapped('warehouse_id')
This may help you.
来源:https://stackoverflow.com/questions/43050684/odoo-9-0c-how-can-i-access-the-value-of-a-many2one-field-that-has-been-created