[IMP] mrp: add indexes in mrp.workcenter.productivity model

We add a index on the workcenter_id and workorder_id, both
have a One2many related to  (`time_ids` of workcenter and workorder)
and both is in the some search domain in python (also in search view).
(Also change the `readonly='True'` into correct form `readonly=True`
of `production_id`, and remove duplicate fields `workcenter_id` in view)

task-2389380

closes odoo/odoo#63500

Related: odoo/upgrade#2042
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Rémy Voet (ryv)
2020-12-22 12:43:00 +00:00
parent d346cd1ec2
commit e8be3acb83
2 changed files with 3 additions and 4 deletions
+3 -3
View File
@@ -308,12 +308,12 @@ class MrpWorkcenterProductivity(models.Model):
company_id = self.env.company
return company_id
production_id = fields.Many2one('mrp.production', string='Manufacturing Order', related='workorder_id.production_id', readonly='True')
workcenter_id = fields.Many2one('mrp.workcenter', "Work Center", required=True, check_company=True)
production_id = fields.Many2one('mrp.production', string='Manufacturing Order', related='workorder_id.production_id', readonly=True)
workcenter_id = fields.Many2one('mrp.workcenter', "Work Center", required=True, check_company=True, index=True)
company_id = fields.Many2one(
'res.company', required=True, index=True,
default=lambda self: self._get_default_company_id())
workorder_id = fields.Many2one('mrp.workorder', 'Work Order', check_company=True)
workorder_id = fields.Many2one('mrp.workorder', 'Work Order', check_company=True, index=True)
user_id = fields.Many2one(
'res.users', "User",
default=lambda self: self.env.uid)
@@ -499,7 +499,6 @@
<field name="model">mrp.workcenter.productivity</field>
<field name="arch" type="xml">
<search string="Operations">
<field name="workcenter_id"/>
<field name="workcenter_id"/>
<field name="loss_id"/>
<separator/>