外协工单采购申请查询问题
This commit is contained in:
@@ -69,7 +69,18 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效',
|
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效',
|
||||||
tracking=True)
|
tracking=True)
|
||||||
back_button_display = fields.Boolean(default=False, compute='_compute_back_button_display', store=True)
|
back_button_display = fields.Boolean(default=False, compute='_compute_back_button_display', store=True)
|
||||||
|
pr_mp_count = fields.Integer('采购申请单数量', compute='_compute_pr_mp_count', store=True)
|
||||||
|
@api.depends('state')
|
||||||
|
def _compute_pr_mp_count(self):
|
||||||
|
for item in self:
|
||||||
|
if not item.is_subcontract:
|
||||||
|
pr_mp_count = 0
|
||||||
|
continue
|
||||||
|
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', item.name),('is_subcontract','=','True')])
|
||||||
|
if pr_ids:
|
||||||
|
item.pr_mp_count = len(pr_ids)
|
||||||
|
else:
|
||||||
|
item.pr_mp_count = 0
|
||||||
@api.depends('state')
|
@api.depends('state')
|
||||||
def _compute_back_button_display(self):
|
def _compute_back_button_display(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -445,6 +456,28 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
|
|
||||||
|
def action_view_pr_mrp_workorder(self):
|
||||||
|
"""
|
||||||
|
采购请求
|
||||||
|
"""
|
||||||
|
self.ensure_one()
|
||||||
|
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', self.name),('is_subcontract', '=', True)])
|
||||||
|
action = {
|
||||||
|
'res_model': 'purchase.request',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
}
|
||||||
|
if len(pr_ids) == 1:
|
||||||
|
action.update({
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_id': pr_ids[0].id,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
action.update({
|
||||||
|
'name': _("从 %s生成采购请求单", self.name),
|
||||||
|
'domain': [('id', 'in', pr_ids)],
|
||||||
|
'view_mode': 'tree,form',
|
||||||
|
})
|
||||||
|
return action
|
||||||
def action_view_surface_technics_purchase(self):
|
def action_view_surface_technics_purchase(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
# if self.routing_type == '表面工艺':
|
# if self.routing_type == '表面工艺':
|
||||||
|
|||||||
@@ -144,6 +144,17 @@
|
|||||||
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//div[@name='button_box']" position="inside">
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
|
<button type="object" name="action_view_pr_mrp_workorder" class="oe_stat_button"
|
||||||
|
icon="fa-credit-card"
|
||||||
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
|
attrs="{'invisible': [('pr_mp_count', '=', 0)]}">
|
||||||
|
<div class="o_field_widget o_stat_info">
|
||||||
|
<span class="o_stat_value">
|
||||||
|
<field name="pr_mp_count"/>
|
||||||
|
</span>
|
||||||
|
<span class="o_stat_text">采购</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
||||||
icon="fa-credit-card"
|
icon="fa-credit-card"
|
||||||
groups="base.group_user,sf_base.group_sf_order_user"
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
|
|||||||
Reference in New Issue
Block a user