32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
|
import logging
|
|
from itertools import groupby
|
|
from odoo import models, api, fields, _
|
|
|
|
|
|
class ProductionTechnologyWizard(models.TransientModel):
|
|
_name = 'sf.production.technology.wizard'
|
|
_description = '制造订单工艺确认向导'
|
|
|
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
|
origin = fields.Char(string='源单据')
|
|
is_technology_confirm = fields.Boolean(default=False)
|
|
|
|
def confirm(self):
|
|
if self.is_technology_confirm is True:
|
|
domain = [('origin', '=', self.origin)]
|
|
else:
|
|
domain = [('id', '=', self.production_id.id)]
|
|
productions = self.env['mrp.production'].search(domain)
|
|
for production in productions:
|
|
special = production.technology_design_ids.filtered(
|
|
lambda td: td.is_auto is False and td.process_parameters_id is not False)
|
|
if special:
|
|
production.get_subcontract_purchase()
|
|
productions._create_workorder(False)
|
|
for item in productions:
|
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
|
key=lambda a: a.sequence)
|
|
workorder[0].state = 'waiting'
|