Accept Merge Request #2198: (feature/齐套检查与下达生产 -> develop)
Merge Request: 人工线下加工最后一个工单完工后未记录时间完工时间 Created By: @管欢 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @管欢 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2198
This commit is contained in:
@@ -259,7 +259,9 @@ class SfProductionDemandPlan(models.Model):
|
||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
||||
lambda mo: mo.product_id == record.product_id)
|
||||
finished_orders = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
|
||||
if len(finished_orders) >= record.product_uom_qty:
|
||||
sum_product_qty = sum(finished_orders.mapped('product_qty'))
|
||||
if finished_orders and float_compare(sum_product_qty, record.product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||
end_dates = [
|
||||
workorder.date_finished for mo in finished_orders
|
||||
for workorder in mo.workorder_ids if workorder.date_finished
|
||||
@@ -361,7 +363,8 @@ class SfProductionDemandPlan(models.Model):
|
||||
)
|
||||
for order in purchase_orders
|
||||
)
|
||||
if total_purchase_quantity < record.product_uom_qty:
|
||||
if float_compare(total_purchase_quantity, record.product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
||||
pr_ids = self.env['purchase.request'].sudo().search(
|
||||
[('line_ids.product_id', 'in', raw_materials.ids), ('state', '!=', 'done')])
|
||||
outsourcing_purchase_request.extend(pr_ids.ids)
|
||||
@@ -378,7 +381,9 @@ class SfProductionDemandPlan(models.Model):
|
||||
)
|
||||
for order in purchase_orders
|
||||
)
|
||||
if total_purchase_quantity < record.product_uom_qty:
|
||||
|
||||
if float_compare(total_purchase_quantity, record.product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
||||
pr_ids = self.env['purchase.request'].sudo().search(
|
||||
[('origin', 'like', record.sale_order_id.name), ('state', '!=', 'done')])
|
||||
outsourcing_purchase_request.extend(pr_ids.ids)
|
||||
@@ -400,7 +405,9 @@ class SfProductionDemandPlan(models.Model):
|
||||
)
|
||||
for order in product_purchase_orders
|
||||
)
|
||||
if total_outsourcing_purchase_quantity / total_product_qty < record.product_uom_qty:
|
||||
quantity = total_outsourcing_purchase_quantity / total_product_qty
|
||||
if float_compare(quantity, record.product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
||||
purchase_request = self.env['purchase.request'].sudo().search(
|
||||
[('line_ids.product_id', 'in', bom_product_ids.ids),
|
||||
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])
|
||||
|
||||
@@ -23,7 +23,6 @@ class sf_technology_design(models.Model):
|
||||
# def _compute_group_uniq_id(self):
|
||||
# for record in self:
|
||||
|
||||
|
||||
def json_technology_design_str(self, k, route, i, process_parameter):
|
||||
workorders_values_str = [0, '', {
|
||||
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
||||
@@ -36,11 +35,19 @@ class sf_technology_design(models.Model):
|
||||
return workorders_values_str
|
||||
|
||||
def write(self, vals):
|
||||
return super(sf_technology_design, self).write(vals)
|
||||
res = super(sf_technology_design, self).write(vals)
|
||||
if 'group_uniq_id' in vals or 'process_parameters_id' in vals or 'active' in vals:
|
||||
if self.production_id:
|
||||
process_parameters_id = self.production_id.technology_design_ids.mapped('process_parameters_id')
|
||||
if process_parameters_id.ids:
|
||||
self.production_id.product_id.model_process_parameters_ids = process_parameters_id.ids
|
||||
else:
|
||||
self.production_id.product_id.model_process_parameters_ids = None
|
||||
return res
|
||||
|
||||
def unlink_technology_design(self):
|
||||
self.active = False
|
||||
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
@@ -48,9 +55,11 @@ class sf_technology_design(models.Model):
|
||||
raise ValidationError(_("工序不能为空"))
|
||||
result = super(sf_technology_design, self).create(vals_list)
|
||||
for res in result:
|
||||
record = self.search([('production_id', '=', res.production_id.id), ('active', 'in', [True, False])], order='group_uniq_id desc', limit=1)
|
||||
record = self.search([('production_id', '=', res.production_id.id), ('active', 'in', [True, False])],
|
||||
order='group_uniq_id desc', limit=1)
|
||||
res.group_uniq_id = record.group_uniq_id + 1
|
||||
return result
|
||||
|
||||
def get_duplicates_with_inactive(self, technology_designs):
|
||||
# 统计每个 'sequence' 出现的次数
|
||||
sequence_count = Counter(technology_design.sequence for technology_design in technology_designs)
|
||||
@@ -62,6 +71,7 @@ class sf_technology_design(models.Model):
|
||||
]
|
||||
|
||||
return result
|
||||
|
||||
# def rearrange_numbering(self,self_technology_designs):
|
||||
# inactive_designs = self.get_duplicates_with_inactive(self_technology_designs)
|
||||
# if inactive_designs:
|
||||
@@ -85,6 +95,7 @@ class sf_technology_design(models.Model):
|
||||
'active': self.active,
|
||||
'group_uniq_id': self.group_uniq_id,
|
||||
}
|
||||
|
||||
def sync_technology_designs(self, production_technology_designs, self_technology_designs):
|
||||
production_id = production_technology_designs[0].production_id.id
|
||||
self_technology_design_dict = {item.group_uniq_id: item for item in self_technology_designs}
|
||||
@@ -93,7 +104,8 @@ class sf_technology_design(models.Model):
|
||||
if not self_technology_design_dict.get(technology_design.group_uniq_id):
|
||||
technology_design.write({'production_id': False})
|
||||
else:
|
||||
technology_design.write(self_technology_design_dict.get(technology_design.group_uniq_id).get_technology_design())
|
||||
technology_design.write(
|
||||
self_technology_design_dict.get(technology_design.group_uniq_id).get_technology_design())
|
||||
for technology_design in self_technology_designs:
|
||||
if not production_technology_designs_dict.get(technology_design.group_uniq_id):
|
||||
technology_design = technology_design.get_technology_design()
|
||||
@@ -101,9 +113,8 @@ class sf_technology_design(models.Model):
|
||||
technology_design.pop('group_uniq_id')
|
||||
self.env['sf.technology.design'].create(technology_design)
|
||||
|
||||
|
||||
|
||||
def unified_procedure_multiple_work_orders(self, self_technology_designs, production_item):
|
||||
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||
[('production_id', '=', production_item.id), ('active', 'in', [True, False])])
|
||||
self.sync_technology_designs(self_technology_designs=self_technology_designs,production_technology_designs=technology_designs)
|
||||
self.sync_technology_designs(self_technology_designs=self_technology_designs,
|
||||
production_technology_designs=technology_designs)
|
||||
|
||||
Reference in New Issue
Block a user