Accept Merge Request #1854: (feature/tool_standard_library_process -> 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/1854
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
@@ -109,15 +109,37 @@ class PurchaseOrder(models.Model):
|
|||||||
class PurchaseOrderLine(models.Model):
|
class PurchaseOrderLine(models.Model):
|
||||||
_inherit = 'purchase.order.line'
|
_inherit = 'purchase.order.line'
|
||||||
|
|
||||||
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
part_number = fields.Char('零件图号', store=True, compute='_compute_origin_sale_id')
|
||||||
|
part_name = fields.Char('零件图号', store=True,
|
||||||
|
compute='_compute_origin_sale_id')
|
||||||
related_product = fields.Many2one('product.product', string='关联产品',
|
related_product = fields.Many2one('product.product', string='关联产品',
|
||||||
help='经此产品工艺加工成的成品')
|
help='经此产品工艺加工成的成品')
|
||||||
|
@api.depends('product_id')
|
||||||
# @api.depends('order_id.origin')
|
def _compute_related_product(self):
|
||||||
# def _compute_related_product(self):
|
for record in self:
|
||||||
# for record in self:
|
if record.product_id.categ_id.name == '坯料':
|
||||||
# if record.product_id.detailed_type:
|
product_name = ''
|
||||||
# production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
match = re.search(r'(S\d{5}-\d)', record.product_id.name)
|
||||||
# record.related_product = production_id.product_id if production_id else False
|
# 如果匹配成功,提取结果
|
||||||
# else:
|
if match:
|
||||||
# record.related_product = False
|
product_name = match.group(0)
|
||||||
|
sale_order_name = ''
|
||||||
|
match_sale = re.search(r'(S\d+)', record.product_id.name)
|
||||||
|
if match_sale:
|
||||||
|
sale_order_name = match_sale.group(0)
|
||||||
|
sale_order = self.env['sale.order'].sudo().search(
|
||||||
|
[('name', '=', sale_order_name)])
|
||||||
|
if sale_order:
|
||||||
|
filtered_order_line = sale_order.order_line.filtered(
|
||||||
|
lambda order_line: product_name in order_line.product_id.name
|
||||||
|
)
|
||||||
|
record.part_number = filtered_order_line.product_id.part_number if filtered_order_line else None
|
||||||
|
record.part_name = filtered_order_line.product_id.part_name if filtered_order_line else None
|
||||||
|
else:
|
||||||
|
record.part_number = record.product_id.part_number
|
||||||
|
record.part_name = record.product_id.part_name
|
||||||
|
# if record.product_id.detailed_type:
|
||||||
|
# production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
||||||
|
# record.related_product = production_id.product_id if production_id else False
|
||||||
|
# else:
|
||||||
|
# record.related_product = False
|
||||||
|
|||||||
@@ -2305,6 +2305,8 @@ class Cutting_tool_standard_library(models.Model):
|
|||||||
result = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
for item in result['cutting_tool_standard_library_all_list']:
|
for item in result['cutting_tool_standard_library_all_list']:
|
||||||
|
if item['code'] == 'JKM-T-DJWL-ZTDJ-20250225001':
|
||||||
|
print('qwfhuiuiohfqwuio')
|
||||||
cutting_tool_standard_library = self.search(
|
cutting_tool_standard_library = self.search(
|
||||||
[("code", '=', item['code']),
|
[("code", '=', item['code']),
|
||||||
("active", 'in', [True, False])])
|
("active", 'in', [True, False])])
|
||||||
@@ -2385,8 +2387,8 @@ class Cutting_tool_standard_library(models.Model):
|
|||||||
"handle_id": False if not item['handle_code'] else self.search(
|
"handle_id": False if not item['handle_code'] else self.search(
|
||||||
[('code', '=', item['handle_code'])]).id,
|
[('code', '=', item['handle_code'])]).id,
|
||||||
"suitable_machining_method_ids": [(6, 0, [])] if not item.get(
|
"suitable_machining_method_ids": [(6, 0, [])] if not item.get(
|
||||||
'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids(
|
'suitable_machining_method') else self.env['maintenance.equipment.image']._get_ids(
|
||||||
item['suitable_machining_methods']),
|
item['suitable_machining_method']),
|
||||||
"blade_tip_characteristics_id": self.env['maintenance.equipment.image'].search(
|
"blade_tip_characteristics_id": self.env['maintenance.equipment.image'].search(
|
||||||
[('name', '=', item['blade_tip_characteristics'])]).id,
|
[('name', '=', item['blade_tip_characteristics'])]).id,
|
||||||
"handle_type_id": self.env['maintenance.equipment.image'].search(
|
"handle_type_id": self.env['maintenance.equipment.image'].search(
|
||||||
|
|||||||
Reference in New Issue
Block a user