I have added a field in product.template named 'model' in my custom module and added this field in my view. But the problem is it is showing product list in the drop down when creating record.
Here is my
models.py
class Product(models.Model):
_name = "product.template"
_inherit = "product.template"
model = fields.Char(string="Product Model", required=False)
class GearManufacturing(models.Model):
_name = 'gear.manufacturing'
product_id = fields.Many2one("product.product", 'Product',required=True)
model = fields.Many2one('product.template', 'Model',required=True)
product_to_dispatch = fields.Integer('Products to Dispatch',required=True)
dispatch_date = fields.Date('Dispatch Date', copy=False, default=fields.Date.today(), index=True, required=True)
views.xml
<record id="gear_manufacturing_tree" model="ir.ui.view">
<field name="name">gear.manufacturing.tree</field>
<field name="model">gear.manufacturing</field>
<field name="arch" type="xml">
<tree>
<field name="product_id"/>
<field name="product_to_dispatch"/>
<field name="model"/>
<field name="dispatch_date"/>
</tree>
</field>
</record>
The field model is showing me Products in dropdown however, it should display nothing since there are no records of it. Where am I going wrong?
Update:
When I upgrade my module, I am getting this error too:
019-11-24 05:34:14,321 27436 ERROR db_test odoo.sql_db: bad query: b"\n INSERT INTO ir_model_data (module, name, model, res_id, noupdate, date_init, date_update)\n VALUES ('gear_manufacturing', 'access_gear_manufacturing_gear_manufacturing', 'ir.model.access', 616, false, now() at time zone 'UTC', now() at time zone 'UTC'), ('gear_manufacturing', 'access_gear_manufacturing_gear_manufacturing', 'ir.model.access', 617, false, now() at time zone 'UTC', now() at time zone 'UTC')\n ON CONFLICT (module, name)\n DO UPDATE SET date_update=(now() at time zone 'UTC') \n "
ERROR: ON CONFLICT DO UPDATE command cannot affect row a second time
HINT: Ensure that no rows proposed for insertion within the same command have duplicate constrained values.
2019-11-24 05:34:14,321 27436 ERROR db_test odoo.addons.base.models.ir_model: Failed to insert ir_model_data
('gear_manufacturing', 'access_gear_manufacturing_gear_manufacturing', 'ir.model.access', 616, False)
('gear_manufacturing', 'access_gear_manufacturing_gear_manufacturing', 'ir.model.access', 617, False)
it seems there is an issue with metadata (ir_model_data). I think it will solve when you create a new database (if feasible)