Reputation: 69
I'm trying to show custom product field on stock.inventory.line but keep getting error "Field stock.inventory.line.outdated cannot find dependency 'stock_move_ids' on model 'product.template'."
This is in my module manifest file under dependencies:
'depends': ['base', 'product', 'stock', 'sale', 'account', 'stock_account']
This is inside python file:
from odoo import models, fields
class StockInventoryLine(models.Model):
_inherit = 'stock.inventory.line'
product_id = fields.Many2one('product.template', string='Product')
instrument_field = fields.Many2one(related='product_id.instrument', string='Instrument')
This is in my XML file:
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record id="view_stock_inventory_line_tree" model="ir.ui.view">
<field name="name">stock.inventory.line.tree</field>
<field name="model">stock.inventory.line</field>
<field name="inherit_id" ref="stock.view_stock_inventory_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="instrument_field"/>
</xpath>
</field>
</record>
</data>
</odoo>
I get that probably the error is with the model stock.inventory.line but I don't know what to use here.
Upvotes: 0
Views: 344
Reputation: 1055
The model stock.inventory.line
doesn't exists any more in Odoo 15. it's replaced with stock.quant
model.
If you are using Odoo 14 or previous versions, the product_id
field in stock.inventory.line
defined as Many2one
from product.product
and you redefined it to link it with product.template
.
The product.product
inheriting all fields from product.template
so you can get instrument_field
directly from product.product
Another thing, stock_move_ids
defined in product.product
and because of your overriding, Odoo couldn't find it in product.template
Please remove the product_id
from your code as below.
from odoo import models, fields
class StockInventoryLine(models.Model):
_inherit = 'stock.inventory.line'
instrument_field = fields.Many2one(related='product_id.instrument',
string='Instrument')
Upvotes: 1