添加退回调整
This commit is contained in:
@@ -2,3 +2,4 @@ from . import workpiece_delivery_wizard
|
||||
from . import rework_wizard
|
||||
from . import production_wizard
|
||||
from . import production_technology_wizard
|
||||
from . import production_technology_re_adjust_wizard
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
||||
import logging
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from collections import defaultdict, namedtuple
|
||||
from odoo.addons.stock.models.stock_rule import ProcurementException
|
||||
from datetime import datetime
|
||||
from odoo import models, api, fields, _
|
||||
|
||||
|
||||
class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
_name = 'sf.production.technology.re_adjust.wizard'
|
||||
_description = '制造订单工艺调整'
|
||||
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||
origin = fields.Char(string='源单据')
|
||||
is_technology_re_adjust = fields.Boolean(default=False)
|
||||
|
||||
def confirm(self):
|
||||
if self.is_technology_re_adjust is True:
|
||||
domain = [('origin', '=', self.origin),('state', '=', 'confirmed')]
|
||||
else:
|
||||
domain = [('id', '=', self.production_id.id)]
|
||||
productions = self.env['mrp.production'].search(domain)
|
||||
for item in productions:
|
||||
special_design = item.technology_design_ids.filtered(
|
||||
lambda a: a.routing_tag == 'special' and a.is_auto is False and a.active in [True, False])
|
||||
workorders_values = []
|
||||
for item in special_design:
|
||||
if item.active is False:
|
||||
# 工单采购单外协出入库单皆需取消
|
||||
domain = [('production_id', '=', item.id)]
|
||||
if item.process_parameters_id:
|
||||
domain += [('surface_technics_parameters_id', '=', item.process_parameters_id)]
|
||||
else:
|
||||
domain += [('name', '=', item.route_id.name)]
|
||||
workorder = self.env['mrp.workorder'].search(domain)
|
||||
if workorder:
|
||||
workorder.write({'state': 'cancel'})
|
||||
workorder.picking_ids.write({'state': 'cancel'})
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('origin', '=', workorder.production_id.origin)])
|
||||
for line in purchase.order_line:
|
||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
||||
purchase_order.write({'state': 'cancel'})
|
||||
|
||||
else:
|
||||
workorder = self.env['mrp.workorder'].search([('name', '=', item.route_id.name)])
|
||||
if not workorder:
|
||||
if item.route_id.routing_type == '表面工艺':
|
||||
product_production_process = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.process_parameters_id.id)])
|
||||
workorders_values.append(
|
||||
self.env[
|
||||
'mrp.workorder']._json_workorder_surface_process_str(self, item,
|
||||
product_production_process.seller_ids[
|
||||
0].partner_id.id))
|
||||
if item.process_parameters_id.gain_way == '外协':
|
||||
product_id_to_production_names = {}
|
||||
# grouped_product_ids = {k: list(g) for k, g in
|
||||
# groupby(self, key=lambda x: x.product_id.id)}
|
||||
|
||||
product_id_to_production_names[self.product_id] = [production.name for production in self]
|
||||
self.env['purchase.order'].get_purchase_order(item.process_parameters_id,
|
||||
self,
|
||||
product_id_to_production_names)
|
||||
|
||||
else:
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str(self, item))
|
||||
|
||||
if workorders_values:
|
||||
self.write({'workorder_ids': workorders_values})
|
||||
self._reset_work_order_sequence()
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="sf_production_technology_re_adjust_wizard_form_view">
|
||||
<field name="name">sf.production.technology.re_adjust.wizard.form.view</field>
|
||||
<field name="model">sf.production.technology.re_adjust.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="origin" invisible="1"/>
|
||||
<div>
|
||||
<field name="is_technology_re_adjust" force_save="1"/>
|
||||
当前制造订单,同一销售订单相同产品所生成的制造订单是否统一进行退回调整操作
|
||||
</div>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认退回调整"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_sf_production_technology_re_adjust_wizard" model="ir.actions.act_window">
|
||||
<field name="name">工艺退回调整</field>
|
||||
<field name="res_model">sf.production.technology.re_adjust.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<!-- <field name="context">{-->
|
||||
<!-- 'default_production_id': active_id}-->
|
||||
<!-- </field>-->
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user