Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/销售订单行新增模型展示
This commit is contained in:
@@ -327,9 +327,9 @@ class MrpProduction(models.Model):
|
||||
# workorder.duration_expected = workorder._get_duration_expected()
|
||||
|
||||
def _create_workorder2(self, k):
|
||||
res = self._create_workorder1(k)
|
||||
self._create_workorder1(k)
|
||||
self._reset_work_order_sequence1(k)
|
||||
return res
|
||||
return True
|
||||
|
||||
def _reset_work_order_sequence(self):
|
||||
for rec in self:
|
||||
@@ -339,11 +339,10 @@ class MrpProduction(models.Model):
|
||||
current_sequence += 1
|
||||
if work.name == '获取CNC加工程序':
|
||||
work.button_start()
|
||||
work.button_finish()
|
||||
work.fetchCNC()
|
||||
|
||||
# 创建工单并进行排序
|
||||
def _create_workorder(self):
|
||||
res = self._create_workorder3()
|
||||
self._create_workorder3()
|
||||
self._reset_work_order_sequence()
|
||||
return res
|
||||
return True
|
||||
|
||||
@@ -479,53 +479,38 @@ class ResMrpWorkOrder(models.Model):
|
||||
if self.date_planned_finished and self.date_planned_finished < start_date:
|
||||
vals['date_planned_finished'] = start_date
|
||||
return self.write(vals)
|
||||
# 外协出库单,从“正在等待”变为“就绪”状态
|
||||
if self.is_subcontract is True:
|
||||
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
|
||||
if picking_out:
|
||||
picking_out.write({'state': 'assigned'})
|
||||
else:
|
||||
raise UserError(_('请先完成上一步工单'))
|
||||
|
||||
def button_finish(self):
|
||||
end_date = datetime.now()
|
||||
for workorder in self:
|
||||
if workorder.state in ('done', 'cancel'):
|
||||
continue
|
||||
workorder.end_all()
|
||||
vals = {
|
||||
'qty_produced': workorder.qty_produced or workorder.qty_producing or workorder.qty_production,
|
||||
'state': 'done',
|
||||
'date_finished': end_date,
|
||||
'date_planned_finished': end_date,
|
||||
'costs_hour': workorder.workcenter_id.costs_hour
|
||||
}
|
||||
if not workorder.date_start:
|
||||
vals['date_start'] = end_date
|
||||
if not workorder.date_planned_start or end_date < workorder.date_planned_start:
|
||||
vals['date_planned_start'] = end_date
|
||||
workorder.with_context(bypass_duration_calculation=True).write(vals)
|
||||
self.env.cr.commit()
|
||||
finish_workorder_count = self.env['mrp.workorder'].search_count(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('is_subcontract', '=', True)])
|
||||
subcontract_workorder_count = self.env['mrp.workorder'].search_count(
|
||||
[('production_id', '=', workorder.production_id.id), ('is_subcontract', '=', True),
|
||||
('state', '=', 'done')])
|
||||
if finish_workorder_count > 0 and subcontract_workorder_count > 0:
|
||||
subcontract_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', workorder.production_id.id), ('is_subcontract', '=', True),
|
||||
('state', '=', 'done')])
|
||||
for item in subcontract_workorder:
|
||||
order_line_ids = []
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('categ_type', '=', '服务'), ('detailed_type', '=', 'service')])
|
||||
if self.picking_out_id:
|
||||
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
|
||||
if picking_out.workorder_out_id:
|
||||
order_line_ids = []
|
||||
for item in picking_out.workorder_out_id:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if server_product:
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
self.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
else:
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
self.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
super().button_finish()
|
||||
|
||||
|
||||
class CNCprocessing(models.Model):
|
||||
@@ -705,4 +690,4 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
pass
|
||||
|
||||
else:
|
||||
self.pro_code_ok = workorder.pro_code_is_ok(barcode)
|
||||
self.pro_code_ok = workorder.pro_code_is_ok(barcode)
|
||||
|
||||
@@ -5,6 +5,7 @@ from re import findall as regex_findall
|
||||
from re import split as regex_split
|
||||
from odoo import SUPERUSER_ID, _, api, fields, models
|
||||
from odoo.tools import float_compare
|
||||
import logging
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
@@ -238,7 +239,8 @@ class StockPicking(models.Model):
|
||||
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
count = self.env['ir.sequence'].search_count([('prefix', 'like', rescode)])
|
||||
count = self.env['stock.picking'].search_count([('name', 'like', rescode)])
|
||||
logging.info('count:' + str(count))
|
||||
if not count:
|
||||
num = "%04d" % 1
|
||||
else:
|
||||
@@ -246,6 +248,21 @@ class StockPicking(models.Model):
|
||||
num = "%04d" % m
|
||||
return '%s%s' % (rescode, num)
|
||||
|
||||
def button_validate(self):
|
||||
if self.workorder_out_id:
|
||||
workorder_in = self.workorder_out_id.filtered(lambda p: p.state == 'progress' and p.is_subcontract is True)
|
||||
if workorder_in:
|
||||
picking_in = self.env['stock.picking'].search([('id', '=', workorder_in.picking_in_id.id)])
|
||||
if picking_in:
|
||||
picking_in.write({'state': 'assigned'})
|
||||
else:
|
||||
workorder_subcontract = self.workorder_out_id.filtered(
|
||||
lambda p: p.state == 'pending' and p.is_subcontract is True)
|
||||
if workorder_subcontract:
|
||||
raise UserError(_('该出库单对应的工单还未开始,不能进行验证操作!'))
|
||||
res = super().button_validate()
|
||||
return res
|
||||
|
||||
# 创建 外协出库入单
|
||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
||||
m = 0
|
||||
@@ -270,7 +287,7 @@ class StockPicking(models.Model):
|
||||
outcontract_picking_type_out))
|
||||
new_picking = True
|
||||
picking_in = self.env['stock.picking'].create(
|
||||
moves_in._get_new_picking_values_Res(item, sorted_workorders,'WH/OCIN/'))
|
||||
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
|
||||
picking_out = self.env['stock.picking'].create(
|
||||
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
|
||||
moves_in.write({'picking_id': picking_in.id})
|
||||
@@ -285,6 +302,7 @@ class ReStockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
def _get_new_picking_values_Res(self, item, sorted_workorders, rescode):
|
||||
logging.info('new_picking-rescode: %s' % rescode)
|
||||
return {
|
||||
'name': self.env['stock.picking']._get_name_Res(rescode),
|
||||
'origin': item.name,
|
||||
@@ -295,5 +313,6 @@ class ReStockMove(models.Model):
|
||||
'picking_type_id': self.mapped('picking_type_id').id,
|
||||
'location_id': self.mapped('location_id').id,
|
||||
'location_dest_id': self.mapped('location_dest_id').id,
|
||||
'state': 'draft',
|
||||
'state': 'confirmed',
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user