Odoo 9.0C: How can i access the value of a many2on

2019-06-10 18:53发布

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条回答
爷、活的狠高调
2楼-- · 2019-06-10 19:43

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.

查看更多
登录 后发表回答