委外加工采购单与制造订单进行关联
This commit is contained in:
@@ -10,6 +10,39 @@ from odoo.tools import OrderedSet
|
||||
# _get_surface_technics_purchase_ids
|
||||
class PurchaseOrder(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
production_count = fields.Integer(
|
||||
"关联制造订单",
|
||||
compute='_compute_workorder_count',
|
||||
)
|
||||
|
||||
def action_view_production(self):
|
||||
origins = [order.name for order in self.picking_ids]
|
||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||
if not production_id:
|
||||
return
|
||||
action = {
|
||||
'res_model': 'mrp.production',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
if len(production_id) == 1:
|
||||
action.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': production_id.id,
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'name': _("制造订单列表"),
|
||||
'domain': [('id', 'in', production_id.ids)],
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
|
||||
|
||||
def _compute_workorder_count(self):
|
||||
for purchase in self:
|
||||
origins = [order.name for order in purchase.picking_ids]
|
||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||
purchase.production_count = len(production_id)
|
||||
def button_confirm(self):
|
||||
super().button_confirm()
|
||||
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id)])
|
||||
|
||||
Reference in New Issue
Block a user