Compare commits

...

27 Commits

Author SHA1 Message Date
陈赓
9af458b11e 是否磁吸 2025-07-17 11:36:24 +08:00
陈赓
cdf6a36c30 Redis同步 2025-07-16 11:49:41 +08:00
陈赓
8e8f5eb8be feat: 新增 Redis 缓存同步相关模块与控制器 2025-07-15 11:29:18 +08:00
陈赓
cdbc277a94 feat: 新增 Redis 工具与控制器,更新同步逻辑相关文件 2025-07-15 11:28:12 +08:00
李晓斌
7fca59322e Accept Merge Request #2285: (feature/7253 -> develop)
Merge Request: BUG_7276_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2285
2025-07-15 09:42:48 +08:00
lixiaobin@jikimo.com
42694c1ac6 BUG_7276_lxb_commit 2025-07-15 09:39:50 +08:00
管欢
e88fc012ec Accept Merge Request #2284: (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/2284
2025-07-14 16:16:20 +08:00
guanhuan
ff7cd9c927 校验修改 2025-07-14 16:13:49 +08:00
guanhuan
588b7d340f Merge branch 'refs/heads/develop' into feature/物料需求计划管理 2025-07-14 15:52:10 +08:00
guanhuan
5902d61f13 新增单件用量显示 2025-07-14 15:39:37 +08:00
陈烨
8cfad007b9 Accept Merge Request #2283: (feature/7249 -> develop)
Merge Request: 合并 develop 分支到 feature/7249

Created By: @陈烨
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @陈烨
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2283
2025-07-14 14:29:24 +08:00
chenye
5008210176 合并 develop 分支到 feature/7249 2025-07-14 14:21:44 +08:00
chenye
f487ab4cce 提交7268,7271等bug修改 2025-07-14 14:15:28 +08:00
guanhuan
0441f345ef 新增单件用量显示 2025-07-14 14:11:28 +08:00
李晓斌
3527105e83 Accept Merge Request #2282: (feature/7253 -> develop)
Merge Request: Debug-7269_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2282?initial=true
2025-07-14 11:41:47 +08:00
lixiaobin@jikimo.com
88e4cfb541 Debug-7269_lxb_commit 2025-07-14 11:32:29 +08:00
管欢
5a175c078f Accept Merge Request #2281: (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/2281
2025-07-14 10:55:52 +08:00
guanhuan
20980bed9d 修复客供料产品下达计划,第二个计划下达报错 2025-07-14 10:54:17 +08:00
陈烨
9b94357439 Accept Merge Request #2280: (feature/7249 -> develop)
Merge Request: Merge branch 'develop' into feature/7249

Created By: @陈烨
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @陈烨
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2280
2025-07-14 08:50:26 +08:00
chenye
5ae3c5dd47 Merge branch 'develop' into feature/7249 2025-07-11 17:57:31 +08:00
chenye
60be14dda2 修改bug7264和7265 2025-07-11 17:49:05 +08:00
陈烨
f0ff7c4a74 Accept Merge Request #2279: (feature/7249 -> develop)
Merge Request: Merge branch 'develop' into feature/7249

Created By: @陈烨
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @陈烨
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2279
2025-07-11 17:01:05 +08:00
chenye
2b6e2fe31b Merge branch 'develop' into feature/7249 2025-07-11 16:48:24 +08:00
chenye
f1390e47c9 提交7252bug修改内容 2025-07-11 16:36:18 +08:00
李晓斌
c7cd0a6a69 Accept Merge Request #2278: (feature/7253 -> develop)
Merge Request: 7253_BUG修复

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2278
2025-07-11 11:40:18 +08:00
lixiaobin@jikimo.com
fa5307a2ea 7253_BUG修复 2025-07-11 11:13:08 +08:00
guanhuan
4706bfe85e 计划量字段被修改成了别的字段名 2025-07-10 17:36:37 +08:00
14 changed files with 335 additions and 173 deletions

View File

@@ -41,8 +41,10 @@ class StockPicking(models.Model):
if backorder_ids: if backorder_ids:
purchase_request_lines = self.move_ids.move_orig_ids.purchase_line_id.purchase_request_lines purchase_request_lines = self.move_ids.move_orig_ids.purchase_line_id.purchase_request_lines
if purchase_request_lines: if purchase_request_lines:
purchase_request_lines.move_dest_ids = [ purchase_request_lines.move_dest_ids = [
(4, x.id) for x in backorder_ids.move_ids if x.product_id.id in purchase_request_lines.mapped('product_id.id') (4, x.id) for x in backorder_ids.move_ids if
x.product_id.id in purchase_request_lines.mapped('product_id.id') and \
not x.created_purchase_request_line_id
] ]
return res return res

View File

@@ -42,6 +42,7 @@ class MrsMaterialModel(models.Model):
materials_num = fields.Char("编码号") materials_num = fields.Char("编码号")
name = fields.Char('型号名') name = fields.Char('型号名')
need_h = fields.Boolean("热处理", default="false") need_h = fields.Boolean("热处理", default="false")
need_m = fields.Boolean("是否磁吸", default="false")
mf_materia_post = fields.Char("热处理后密度") mf_materia_post = fields.Char("热处理后密度")
density = fields.Float("密度(kg/m³)") density = fields.Float("密度(kg/m³)")
materials_id = fields.Many2one('sf.production.materials', "材料名") materials_id = fields.Many2one('sf.production.materials', "材料名")

View File

@@ -263,6 +263,7 @@
<field name="materials_no" readonly="1" force_save="1"/> <field name="materials_no" readonly="1" force_save="1"/>
<field name="gain_way" required="0"/> <field name="gain_way" required="0"/>
<field name="density" readonly="1" required="1" class="custom_required"/> <field name="density" readonly="1" required="1" class="custom_required"/>
<field name="need_m" default="false" readonly="1"/>
</group> </group>
<group> <group>
<field name="rough_machining" required="1"/> <field name="rough_machining" required="1"/>
@@ -306,6 +307,7 @@
<field name="tensile_strength"/> <field name="tensile_strength"/>
<field name="hardness" optional="show"/> <field name="hardness" optional="show"/>
<field name="need_h"/> <field name="need_h"/>
<field name="need_m"/>
<field name="apply" widget="many2many_tags" optional="show"/> <field name="apply" widget="many2many_tags" optional="show"/>
<field name="density" optional="show"/> <field name="density" optional="show"/>
<field name="rough_machining" optional="hide"/> <field name="rough_machining" optional="hide"/>
@@ -352,6 +354,7 @@
<field name="materials_no"/> <field name="materials_no"/>
<field name="name"/> <field name="name"/>
<field name="need_h"/> <field name="need_h"/>
<field name="need_m"/>
<field name="mf_materia_post"/> <field name="mf_materia_post"/>
<field name="density"/> <field name="density"/>
<field name='materials_id' default="default" invisible="1"/> <field name='materials_id' default="default" invisible="1"/>

View File

@@ -18,3 +18,12 @@ class MrpBom(models.Model):
subcontract = self.get_supplier(product.materials_type_id) subcontract = self.get_supplier(product.materials_type_id)
bom_id.subcontractor_id = subcontract.partner_id.id bom_id.subcontractor_id = subcontract.partner_id.id
return bom_id return bom_id
def name_get(self):
"""重写name_get方法只显示BOM编码"""
result = []
for record in self:
# 只显示BOM编码如果编码为空则显示产品名称
display_name = record.code or record.product_tmpl_id.name or f'BOM-{record.id}'
result.append((record.id, display_name))
return result

View File

@@ -36,6 +36,9 @@ class SfDemandPlan(models.Model):
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类', blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
related='product_id.blank_type') related='product_id.blank_type')
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
related='product_id.blank_precision')
manual_quotation = fields.Boolean('人工编程', related='product_id.manual_quotation', default=False)
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long', store=True) embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long', store=True)
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True) is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
pending_qty = fields.Float( pending_qty = fields.Float(
@@ -112,7 +115,10 @@ class SfDemandPlan(models.Model):
def _compute_embryo_long(self): def _compute_embryo_long(self):
for line in self: for line in self:
if line.product_id: if line.product_id:
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}" if line.product_id.blank_type == '圆料':
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
else:
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
else: else:
line.embryo_long = None line.embryo_long = None
@@ -209,7 +215,7 @@ class SfDemandPlan(models.Model):
def name_get(self): def name_get(self):
result = [] result = []
for plan in self: for plan in self:
result.append((plan.id, plan.product_id.name)) result.append((plan.id, plan.demand_plan_number))
return result return result
def button_production_release_plan(self): def button_production_release_plan(self):
@@ -218,10 +224,10 @@ class SfDemandPlan(models.Model):
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers') customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
if not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.id == customer_location_id): if not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.id == customer_location_id):
if float_compare(sum_product_uom_qty, self.product_uom_qty, if float_compare(sum_product_uom_qty, self.product_uom_qty,
precision_rounding=self.product_id.uom_id.rounding) == 1: precision_rounding=self.product_id.uom_id.rounding) == 1:
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。") raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
elif float_compare(sum_product_uom_qty, self.product_uom_qty, elif float_compare(sum_product_uom_qty, self.product_uom_qty,
precision_rounding=self.product_id.uom_id.rounding) == 1: precision_rounding=self.product_id.uom_id.rounding) == 1:
return { return {
'name': _('需求计划'), 'name': _('需求计划'),
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
@@ -237,7 +243,8 @@ class SfDemandPlan(models.Model):
else: else:
for demand_plan_line_id in line_ids: for demand_plan_line_id in line_ids:
demand_plan_line_id.action_confirm() demand_plan_line_id.action_confirm()
#需求要求取值格式是来源+来源明细行ID,但是来源明细行ID取得就是product_id.name得最后一位所以这里也直接截取product_id.name
# 需求要求取值格式是来源+来源明细行ID,但是来源明细行ID取得就是product_id.name得最后一位所以这里也直接截取product_id.name
@api.depends('product_id.name') @api.depends('product_id.name')
def _compute_demand_plan_number(self): def _compute_demand_plan_number(self):
for line in self: for line in self:

View File

@@ -21,7 +21,7 @@ class SfProductionDemandPlan(models.Model):
status = fields.Selection([ status = fields.Selection([
('10', '草稿'), ('10', '草稿'),
('20', '待确认'), ('20', '待确认'),
('30', '需求确认'), ('30', '待工艺设计'),
('50', '待下达生产'), ('50', '待下达生产'),
('60', '已下达'), ('60', '已下达'),
('100', '取消'), ('100', '取消'),
@@ -81,6 +81,7 @@ class SfProductionDemandPlan(models.Model):
related='product_id.blank_type') related='product_id.blank_type')
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型', blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
related='product_id.blank_precision') related='product_id.blank_precision')
unit_number = fields.Float('单件用量', digits=(16, 3), related='product_id.unit_number')
embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long') embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long')
materials_id = fields.Char('材料', related='demand_plan_id.materials_id') materials_id = fields.Char('材料', related='demand_plan_id.materials_id')
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度') model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
@@ -169,6 +170,7 @@ class SfProductionDemandPlan(models.Model):
finished_product_arrival_date = fields.Date('采购计划到货(成品)') finished_product_arrival_date = fields.Date('采购计划到货(成品)')
bom_id = fields.Many2one('mrp.bom', string="BOM", readonly=True) bom_id = fields.Many2one('mrp.bom', string="BOM", readonly=True)
location_id = fields.Many2one('stock.location', string='需求位置', default=get_location_id, readonly=True) location_id = fields.Many2one('stock.location', string='需求位置', default=get_location_id, readonly=True)
manual_quotation = fields.Boolean('人工编程', related='product_id.manual_quotation', default=False)
@api.constrains('plan_uom_qty') @api.constrains('plan_uom_qty')
def _check_plan_uom_qty(self): def _check_plan_uom_qty(self):
@@ -176,15 +178,22 @@ class SfProductionDemandPlan(models.Model):
if line_ids: if line_ids:
raise ValidationError(_("计划量不能小于等于0")) raise ValidationError(_("计划量不能小于等于0"))
@api.constrains('new_supply_method') @api.constrains('supply_method')
def _check_new_supply_method(self): def _check_supply_method(self):
product_name = [] product_name = []
product = []
for line in self: for line in self:
if line.new_supply_method == 'purchase' and line.is_incoming_material: if line.supply_method == 'purchase' and line.is_incoming_material:
product_name.append(line.product_id.display_name) product_name.append(line.product_id.display_name)
if line.supply_method == 'automation' and line.manual_quotation:
product.append(line.product_id.display_name)
if product_name: if product_name:
unique_product_names = list(set(product_name)) unique_product_names = list(set(product_name))
raise UserError('当前(%s)产品为客供料,不能选择外购' % ','.join(unique_product_names)) raise UserError('当前(%s)产品为客供料,不能选择外购' % ','.join(unique_product_names))
if product:
unique_product = list(set(product))
raise UserError('当前(%s)产品为人工编程,不能选择自动化产线加工' % ','.join(unique_product))
@api.depends('new_supply_method') @api.depends('new_supply_method')
def _compute_custom_made_type(self): def _compute_custom_made_type(self):
@@ -344,9 +353,12 @@ class SfProductionDemandPlan(models.Model):
pro_plan.do_production_schedule() pro_plan.do_production_schedule()
def update_sale_order_state(self): def update_sale_order_state(self):
demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)]) # demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
demand_plan_state = demand_plan.filtered(lambda line: line.state != '40') # demand_plan_state = demand_plan.filtered(lambda line: line.state != '40')
if not demand_plan_state: production_demand_plan = self.env['sf.production.demand.plan'].sudo().search(
[('sale_order_id', '=', self.sale_order_id.id)])
production_demand_plan_state = production_demand_plan.filtered(lambda line: line.status in ('10', '20', '30'))
if not production_demand_plan_state:
# 修改销售订单为加工中 # 修改销售订单为加工中
self.sale_order_id.state = 'processing' self.sale_order_id.state = 'processing'
@@ -587,7 +599,7 @@ class SfProductionDemandPlan(models.Model):
def unlink(self): def unlink(self):
for item in self: for item in self:
if item.status not in ('10', '20', '30'): if item.status not in ('10', '20', '30'):
raise ValidationError(u'只能删除状态为【草稿,待确认,需求确认】的需求计划。') raise ValidationError(u'只能删除状态为【草稿,待确认,待工艺设计】的需求计划。')
else: else:
super(SfProductionDemandPlan, item).unlink() super(SfProductionDemandPlan, item).unlink()
@@ -603,6 +615,11 @@ class SfProductionDemandPlan(models.Model):
# 按产品分组并计算总数 # 按产品分组并计算总数
product_data = {} product_data = {}
for plan in filtered_plan: for plan in filtered_plan:
check_overdelivery_allowed = False
if not plan.demand_plan_id.overdelivery_allowed:
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
if plan.location_id.id == customer_location_id:
check_overdelivery_allowed = True
if plan.product_id not in product_data: if plan.product_id not in product_data:
# 初始化产品数据,从产品上获取需求量 # 初始化产品数据,从产品上获取需求量
product_data[plan.product_id] = { product_data[plan.product_id] = {
@@ -612,17 +629,22 @@ class SfProductionDemandPlan(models.Model):
# 累加计划数量 # 累加计划数量
product_data[plan.product_id]['plan_uom_qty'] += plan.plan_uom_qty product_data[plan.product_id]['plan_uom_qty'] += plan.plan_uom_qty
product_data[plan.product_id]['overdelivery_allowed'] = check_overdelivery_allowed
# 检查需求超过计划数量的产品 # 检查需求超过计划数量的产品
warning_messages = [] warning_messages = []
error_messages = []
for product, data in product_data.items(): for product, data in product_data.items():
if float_compare(data['plan_uom_qty'], data['product_uom_qty'], if data['overdelivery_allowed'] and float_compare(data['plan_uom_qty'], data['product_uom_qty'],precision_rounding=product.uom_id.rounding) == 1:
precision_rounding=product.uom_id.rounding) == 1: error_messages.append(f"您正在下达的产品 {product.display_name},已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
elif float_compare(data['plan_uom_qty'], data['product_uom_qty'],
precision_rounding=product.uom_id.rounding) == 1:
warning_messages.append( warning_messages.append(
_("您正在下达的产品 %s,计划量%s,需求数量为%s,已超过需求数量") % _("您正在下达的产品 %s,计划量%s,需求数量为%s,已超过需求数量") %
(product.display_name, data['plan_uom_qty'], data['product_uom_qty']) (product.display_name, data['plan_uom_qty'], data['product_uom_qty'])
) )
if warning_messages and check_overdelivery_allowed: if error_messages:
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。") error_message = "\n".join(error_messages)
raise ValidationError(error_message)
elif warning_messages: elif warning_messages:
warning_message = "\n".join(warning_messages) warning_message = "\n".join(warning_messages)
return { return {
@@ -640,17 +662,17 @@ class SfProductionDemandPlan(models.Model):
def button_release_plan(self): def button_release_plan(self):
self.ensure_one() self.ensure_one()
if not self.new_supply_method:
raise ValidationError(f"供货方式不能为空!")
check_overdelivery_allowed = False check_overdelivery_allowed = False
if not self.demand_plan_id.overdelivery_allowed: if not self.demand_plan_id.overdelivery_allowed:
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers') customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
if self.location_id.id == customer_location_id: if self.location_id.id == customer_location_id:
check_overdelivery_allowed = True check_overdelivery_allowed = True
if check_overdelivery_allowed: if check_overdelivery_allowed:
if float_compare(self.plan_uom_qty, self.product_uom_qty,precision_rounding=self.product_id.uom_id.rounding) == 1: if float_compare(self.plan_uom_qty, self.product_uom_qty,
precision_rounding=self.product_id.uom_id.rounding) == 1:
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。") raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
elif float_compare(self.plan_uom_qty, self.product_uom_qty,precision_rounding=self.product_id.uom_id.rounding) == 1: elif float_compare(self.plan_uom_qty, self.product_uom_qty,
precision_rounding=self.product_id.uom_id.rounding) == 1:
return { return {
'name': _('需求计划'), 'name': _('需求计划'),
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
@@ -673,6 +695,7 @@ class SfProductionDemandPlan(models.Model):
self._action_launch_stock_rule() self._action_launch_stock_rule()
if self.supply_method in ('automation', 'manual'): if self.supply_method in ('automation', 'manual'):
self.write({'status': '50'}) self.write({'status': '50'})
self.update_sale_order_state()
else: else:
self.write({'status': '60'}) self.write({'status': '60'})
self.update_sale_order_state() self.update_sale_order_state()

View File

@@ -83,7 +83,7 @@
} }
} }
th[data-name=processing_time] + th::before{ /*.demand_plan_tree th[data-name=planned_start_date] + th::before{*/
content: '待执行单据'; /* content: '待执行单据';*/
line-height: 38px; /* line-height: 38px;*/
} /*}*/

View File

@@ -22,6 +22,7 @@
<field name="model_id" optional="hide"/> <field name="model_id" optional="hide"/>
<field name="part_name"/> <field name="part_name"/>
<field name="part_number"/> <field name="part_number"/>
<field name="manual_quotation" optional="hide"/>
<field name="is_incoming_material"/> <field name="is_incoming_material"/>
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/> <field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
<field name="readonly_custom_made_type" invisible="1"/> <field name="readonly_custom_made_type" invisible="1"/>
@@ -31,13 +32,14 @@
<field name="product_uom_qty"/> <field name="product_uom_qty"/>
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/> <field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
<field name="deadline_of_delivery"/> <field name="deadline_of_delivery"/>
<field name="inventory_quantity_auto_apply"/> <field name="inventory_quantity_auto_apply" optional="hide"/>
<field name="qty_delivered"/> <field name="qty_delivered" optional="hide"/>
<field name="qty_to_deliver"/> <field name="qty_to_deliver" optional="hide"/>
<field name="model_long"/> <field name="model_long"/>
<field name="blank_type" optional="hide"/> <field name="blank_type" optional="hide"/>
<field name="blank_precision"/> <field name="blank_precision"/>
<field name="embryo_long"/> <field name="embryo_long"/>
<field name="unit_number" optional="hide"/>
<field name="materials_id"/> <field name="materials_id"/>
<field name="model_machining_precision"/> <field name="model_machining_precision"/>
<field name="model_process_parameters_ids" widget="many2many_tags"/> <field name="model_process_parameters_ids" widget="many2many_tags"/>

View File

@@ -20,7 +20,9 @@
<field name="part_number"/> <field name="part_number"/>
<field name="materials_id"/> <field name="materials_id"/>
<field name="blank_type"/> <field name="blank_type"/>
<field name="blank_precision"/>
<field name="embryo_long"/> <field name="embryo_long"/>
<field name="manual_quotation"/>
<field name="is_incoming_material"/> <field name="is_incoming_material"/>
<field name="pending_qty"/> <field name="pending_qty"/>
<field name="planned_qty"/> <field name="planned_qty"/>
@@ -86,7 +88,7 @@
'required': [('new_supply_method', '=', 'custom_made')]}"/> 'required': [('new_supply_method', '=', 'custom_made')]}"/>
<field name="route_ids" widget="many2many_tags" optional="hide"/> <field name="route_ids" widget="many2many_tags" optional="hide"/>
<field name="location_id" optional="hide"/> <field name="location_id" optional="hide"/>
<field name="bom_id" optional="hide"/> <field name="bom_id" optional="hide" readonly="1" options="{'no_create': True}"/>
<field name="processing_time" optional="hide"/> <field name="processing_time" optional="hide"/>
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/> <field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
<field name="blank_arrival_date"/> <field name="blank_arrival_date"/>

View File

@@ -217,7 +217,8 @@ class StockRule(models.Model):
''' '''
创建制造订单时生成序列号 创建制造订单时生成序列号
''' '''
production.action_generate_serial() if production.product_id.tracking != "none":
production.action_generate_serial()
origin_production = production.move_dest_ids and production.move_dest_ids[ origin_production = production.move_dest_ids and production.move_dest_ids[
0].raw_material_production_id or False 0].raw_material_production_id or False
orderpoint = production.orderpoint_id orderpoint = production.orderpoint_id
@@ -442,7 +443,7 @@ class ProductionLot(models.Model):
@api.model @api.model
def _get_next_serial(self, company, product): def _get_next_serial(self, company, product):
"""Return the next serial number to be attributed to the product.""" """Return the next serial number to be attributed to the product."""
if product.tracking == "serial": if product.tracking != "none":
last_serial = self.env['stock.lot'].search( last_serial = self.env['stock.lot'].search(
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)], [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)],
limit=1, order='name desc') limit=1, order='name desc')
@@ -453,7 +454,9 @@ class ProductionLot(models.Model):
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if ( return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if (
not move_line_id or not move_line_id or
(last_serial and last_serial.name > move_line_id.lot_name)) else move_line_id.lot_name, 2)[1] (last_serial and last_serial.name > move_line_id.lot_name)) else move_line_id.lot_name, 2)[1]
return "%s-%03d" % (product.name, 1) else:
return "%s-%03d" % (product.name, 1)
return False
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code') qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')

View File

@@ -1506,149 +1506,149 @@ class SyncMulti_Mounting_Type(models.Model):
raise ValidationError("联装类型认证未通过") raise ValidationError("联装类型认证未通过")
class SyncFixtureModel(models.Model): # class SyncFixtureModel(models.Model):
_inherit = 'sf.fixture.model' # _inherit = 'sf.fixture.model'
_description = '同步夹具型号列表' # _description = '同步夹具型号列表'
url = '/api/fixture_model/list' # url = '/api/fixture_model/list'
# 定时同步夹具型号列表 # # 定时同步夹具型号列表
def sync_fixture_model_yesterday(self): # def sync_fixture_model_yesterday(self):
config = self.env['res.config.settings'].get_values() # config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key']) # headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url # strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers) # r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json() # r = r.json()
result = json.loads(r['result']) # result = json.loads(r['result'])
if result['status'] == 1: # if result['status'] == 1:
if result.get('fixture_model_yesterday_list'): # if result.get('fixture_model_yesterday_list'):
for item in result['fixture_model_yesterday_list']: # for item in result['fixture_model_yesterday_list']:
if item: # if item:
fixture_model = self.search([("code", '=', item['code']), ('active', 'in', [True, False])]) # fixture_model = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
val = { # val = {
"name": item['name'], # "name": item['name'],
"code": item['code'], # "code": item['code'],
"fixture_material_id": self.env['sf.fixture.material'].search( # "fixture_material_id": self.env['sf.fixture.material'].search(
[('code', '=', item['fixture_material_code'])]).id, # [('code', '=', item['fixture_material_code'])]).id,
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search( # "multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
[('code', '=', item['multi_mounting_type_code'])]).id, # [('code', '=', item['multi_mounting_type_code'])]).id,
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id, # "brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']), # "model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
"status": item['status'], # "status": item['status'],
"active": item['active'], # "active": item['active'],
} # }
if not fixture_model: # if not fixture_model:
self.create(val) # self.create(val)
else: # else:
fixture_model.write(val) # fixture_model.write(val)
else: # else:
raise ValidationError("夹具型号认证未通过") # raise ValidationError("夹具型号认证未通过")
# 定时同步所有夹具型号列表 # # 定时同步所有夹具型号列表
def sync_all_fixture_model(self): # def sync_all_fixture_model(self):
config = self.env['res.config.settings'].get_values() # config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key']) # headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url # strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers) # r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json() # r = r.json()
result = json.loads(r['result']) # result = json.loads(r['result'])
# print('result:%s' % result) # # print('result:%s' % result)
if result['status'] == 1: # if result['status'] == 1:
if result.get('fixture_model_all_list'): # if result.get('fixture_model_all_list'):
for item in result['fixture_model_all_list']: # for item in result['fixture_model_all_list']:
if item: # if item:
fixture_model = self.search([('code', '=', item['code']), ('active', 'in', [True, False])]) # fixture_model = self.search([('code', '=', item['code']), ('active', 'in', [True, False])])
val = { # val = {
"name": item['name'], # "name": item['name'],
"code": item['code'], # "code": item['code'],
"fixture_material_id": self.env['sf.fixture.material'].search( # "fixture_material_id": self.env['sf.fixture.material'].search(
[('code', '=', item['fixture_material_code'])]).id, # [('code', '=', item['fixture_material_code'])]).id,
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search( # "multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
[('code', '=', item['multi_mounting_type_code'])]).id, # [('code', '=', item['multi_mounting_type_code'])]).id,
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id, # "brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']), # "model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
"status": item['status'], # "status": item['status'],
"active": item['active'], # "active": item['active'],
} # }
if not fixture_model: # if not fixture_model:
self.create(val) # self.create(val)
else: # else:
fixture_model.write(val) # fixture_model.write(val)
else: # else:
raise ValidationError("夹具型号认证未通过") # raise ValidationError("夹具型号认证未通过")
class SyncfixtureMaterialsBasicParameters(models.Model): # class SyncfixtureMaterialsBasicParameters(models.Model):
_inherit = 'sf.fixture.materials.basic.parameters' # _inherit = 'sf.fixture.materials.basic.parameters'
_description = '同步夹具型号基本参数列表' # _description = '同步夹具型号基本参数列表'
url = '/api/fixture_parameters/list' # url = '/api/fixture_parameters/list'
# 定时同步夹具型号基本信息 # # 定时同步夹具型号基本信息
def sync_fixture_materials_basic_parameters_yesterday(self): # def sync_fixture_materials_basic_parameters_yesterday(self):
config = self.env['res.config.settings'].get_values() # config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key']) # headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url # strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers) # r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json() # r = r.json()
result = json.loads(r['result']) # result = json.loads(r['result'])
if result['status'] == 1: # if result['status'] == 1:
if result.get('fixture_parameters_yesterday_list'): # if result.get('fixture_parameters_yesterday_list'):
all_list = result.get('fixture_parameters_yesterday_list') # all_list = result.get('fixture_parameters_yesterday_list')
if all_list.get('zero_chuck_all_list'): # if all_list.get('zero_chuck_all_list'):
self._write_or_create(all_list.get('zero_chuck_yesterday_list'), '零点卡盘') # self._write_or_create(all_list.get('zero_chuck_yesterday_list'), '零点卡盘')
if all_list.get('zero_tray_all_list'): # if all_list.get('zero_tray_all_list'):
self._write_or_create(all_list.get('zero_tray_yesterday_list'), '零点托盘') # self._write_or_create(all_list.get('zero_tray_yesterday_list'), '零点托盘')
if all_list.get('pneumatic_fixture_all_list'): # if all_list.get('pneumatic_fixture_all_list'):
self._write_or_create(all_list.get('pneumatic_fixture_yesterday_list'), '气动夹具') # self._write_or_create(all_list.get('pneumatic_fixture_yesterday_list'), '气动夹具')
if all_list.get('jaw_vice_all_list'): # if all_list.get('jaw_vice_all_list'):
self._write_or_create(all_list.get('jaw_vice_yesterday_list'), '虎钳夹具') # self._write_or_create(all_list.get('jaw_vice_yesterday_list'), '虎钳夹具')
if all_list.get('magnet_fixture_all_list'): # if all_list.get('magnet_fixture_all_list'):
self._write_or_create(all_list.get('magnet_fixture_yesterday_list'), '磁吸夹具') # self._write_or_create(all_list.get('magnet_fixture_yesterday_list'), '磁吸夹具')
if all_list.get('adapter_board_all_list'): # if all_list.get('adapter_board_all_list'):
self._write_or_create(all_list.get('adapter_board_yesterday_list'), '转接板(锁板)夹具') # self._write_or_create(all_list.get('adapter_board_yesterday_list'), '转接板(锁板)夹具')
if all_list.get('scroll_chuck_all_list'): # if all_list.get('scroll_chuck_all_list'):
self._write_or_create(all_list.get('scroll_chuck_yesterday_list'), '三爪卡盘') # self._write_or_create(all_list.get('scroll_chuck_yesterday_list'), '三爪卡盘')
else: # else:
raise ValidationError("夹具型号基本参数认证未通过") # raise ValidationError("夹具型号基本参数认证未通过")
# 定时同步所有夹具型号基本信息 # # 定时同步所有夹具型号基本信息
def sync_all_fixture_materials_basic_parameters(self): # def sync_all_fixture_materials_basic_parameters(self):
config = self.env['res.config.settings'].get_values() # config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key']) # headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url # strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers) # r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json() # r = r.json()
result = json.loads(r['result']) # result = json.loads(r['result'])
if result['status'] == 1: # if result['status'] == 1:
if result.get('fixture_parameters_all_list'): # if result.get('fixture_parameters_all_list'):
all_list = result.get('fixture_parameters_all_list') # all_list = result.get('fixture_parameters_all_list')
if all_list.get('zero_chuck_all_list'): # if all_list.get('zero_chuck_all_list'):
self._write_or_create(all_list.get('zero_chuck_all_list'), '零点卡盘') # self._write_or_create(all_list.get('zero_chuck_all_list'), '零点卡盘')
if all_list.get('zero_tray_all_list'): # if all_list.get('zero_tray_all_list'):
self._write_or_create(all_list.get('zero_tray_all_list'), '零点托盘') # self._write_or_create(all_list.get('zero_tray_all_list'), '零点托盘')
if all_list.get('pneumatic_fixture_all_list'): # if all_list.get('pneumatic_fixture_all_list'):
self._write_or_create(all_list.get('pneumatic_fixture_all_list'), '气动夹具') # self._write_or_create(all_list.get('pneumatic_fixture_all_list'), '气动夹具')
if all_list.get('jaw_vice_all_list'): # if all_list.get('jaw_vice_all_list'):
self._write_or_create(all_list.get('jaw_vice_all_list'), '虎钳夹具') # self._write_or_create(all_list.get('jaw_vice_all_list'), '虎钳夹具')
if all_list.get('magnet_fixture_all_list'): # if all_list.get('magnet_fixture_all_list'):
self._write_or_create(all_list.get('magnet_fixture_all_list'), '磁吸夹具') # self._write_or_create(all_list.get('magnet_fixture_all_list'), '磁吸夹具')
if all_list.get('adapter_board_all_list'): # if all_list.get('adapter_board_all_list'):
self._write_or_create(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具') # self._write_or_create(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具')
if all_list.get('scroll_chuck_all_list'): # if all_list.get('scroll_chuck_all_list'):
self._write_or_create(all_list.get('scroll_chuck_all_list'), '三爪卡盘') # self._write_or_create(all_list.get('scroll_chuck_all_list'), '三爪卡盘')
else: # else:
raise ValidationError("夹具型号基本参数认证未通过") # raise ValidationError("夹具型号基本参数认证未通过")
def _write_or_create(self, fixture_parameters_list, material_name): # def _write_or_create(self, fixture_parameters_list, material_name):
for item in fixture_parameters_list: # for item in fixture_parameters_list:
if item: # if item:
basic_parameters = self.search([('code', '=', item.get('code')), ('active', 'in', [True, False])]) # basic_parameters = self.search([('code', '=', item.get('code')), ('active', 'in', [True, False])])
if not basic_parameters: # if not basic_parameters:
self.create(self._get_basic_parameters_list(item, material_name)) # self.create(self._get_basic_parameters_list(item, material_name))
else: # else:
basic_parameters.write(self._get_basic_parameters_list(item, material_name)) # basic_parameters.write(self._get_basic_parameters_list(item, material_name))
class SyncFunctionalFixtureType(models.Model): class SyncFunctionalFixtureType(models.Model):
@@ -3231,3 +3231,108 @@ class EmbryoRedundancySync(models.Model):
"active": item['active'], "active": item['active'],
"remark": item['remark'], "remark": item['remark'],
}) })
class SyncfixtureMaterialsBasicParameters(models.Model):
_inherit = 'sf.fixture.materials.basic.parameters'
_description = 'Redis 优先同步夹具基本参数'
def sync_all_fixture_materials_basic_parameters(self):
rc = RedisClient()
key = 'mrs:fixture_param_all_list'
all_list = rc.get_json(key)
# ✅ Redis 无数据时,请求 MRS 端刷新 Redis 缓存
if not all_list:
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(config['token'], config['sf_secret_key'])
refresh_url = config['mrs_url'] + '/api/refresh_redis/fixture_param'
try:
res = requests.post(refresh_url, headers=headers, json={}, timeout=10)
res.raise_for_status()
except Exception as e:
raise ValidationError(f"Redis 无数据MRS 缓存刷新失败: {str(e)}")
# 再次尝试从 Redis 获取
all_list = rc.get_json(key)
if not all_list:
raise ValidationError("Redis 刷新后仍无数据,无法同步夹具基本参数")
# ✅ 同步函数作为局部函数定义在方法体内部
def _sync_list(param_list, material_name):
for item in param_list or []:
if not item or not item.get('code'):
continue
record = self.search([('code', '=', item['code'])], limit=1)
vals = self._get_basic_parameters_list(item, material_name)
if record:
record.write(vals)
else:
self.create(vals)
# ✅ 各类夹具参数同步调用
_sync_list(all_list.get('zero_chuck_all_list'), '零点卡盘')
_sync_list(all_list.get('zero_tray_all_list'), '零点托盘')
_sync_list(all_list.get('pneumatic_fixture_all_list'), '气动夹具')
_sync_list(all_list.get('jaw_vice_all_list'), '虎钳夹具')
_sync_list(all_list.get('magnet_fixture_all_list'), '磁吸夹具')
_sync_list(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具')
_sync_list(all_list.get('scroll_chuck_all_list'), '三爪卡盘')
_sync_list(all_list.get('air_tray_all_list'), '气吹托盘')
_sync_list(all_list.get('magnet_tray_all_list'), '磁吸托盘')
class SyncFixtureModel(models.Model):
_inherit = 'sf.fixture.model'
_description = 'Redis 优先同步夹具型号'
def sync_all_fixture_model(self):
rc = RedisClient()
key = 'mrs:fixture_model_all_list'
all_list = rc.get_json(key)
# ✅ Redis 没数据时,请求 MRS 接口刷新
if not all_list:
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(config['token'], config['sf_secret_key'])
refresh_url = config['mrs_url'] + '/api/refresh_redis/fixture_model'
try:
res = requests.post(refresh_url, headers=headers, json={}, timeout=10)
res.raise_for_status()
except Exception as e:
raise ValidationError(f"Redis 无数据MRS 刷新失败: {str(e)}")
# 再次尝试获取 Redis
all_list = rc.get_json(key)
if not all_list:
raise ValidationError("刷新后仍无 Redis 数据,无法同步夹具型号")
# ✅ 开始同步夹具型号
for item in all_list:
if not item or not item.get('code'):
continue
record = self.search([('code', '=', item['code'])], limit=1)
vals = {
'name': item['name'],
'code': item['code'],
'fixture_material_id': self.env['sf.fixture.material']
.search([('code', '=', item['fixture_material_code'])], limit=1).id,
'multi_mounting_type_id': self.env['sf.multi_mounting.type']
.search([('code', '=', item['multi_mounting_type_code'])], limit=1).id,
'brand_id': self.env['sf.machine.brand']
.search([('code', '=', item['brand_code'])], limit=1).id,
'model_file': base64.b64decode(item['model_file']) if item.get('model_file') else False,
'status': item['status'],
'active': item['active'],
}
if record:
record.write(vals)
else:
self.create(vals)

View File

@@ -45759,6 +45759,11 @@ msgstr ""
msgid "热处理" msgid "热处理"
msgstr "" msgstr ""
#. module: sf_base
#: model:ir.model.fields,field_description:sf_base.field_sf_materials_model__need_m
msgid "是否磁吸"
msgstr ""
#. module: sf_base #. module: sf_base
#: model:ir.model.fields,field_description:sf_base.field_sf_materials_model__mf_materia_post #: model:ir.model.fields,field_description:sf_base.field_sf_materials_model__mf_materia_post
msgid "热处理后密度" msgid "热处理后密度"