Merge branch 'release/release_2.8' into feature/验证合并的逻辑

This commit is contained in:
胡尧
2025-01-17 16:12:27 +08:00
5 changed files with 36 additions and 8 deletions

View File

@@ -27,7 +27,17 @@ class jikimo_purchase_tier_validation(models.Model):
raise ValidationError(_('请先完成审批。'))
# if record.state == 'approved':
# record.state = 'purchase'
return super().button_confirm()
res = super(jikimo_purchase_tier_validation, self).button_confirm()
for record in self:
if record.state == 'approved':
record.order_line._validate_analytic_distribution()
record._add_supplier_to_product()
# Deal with double validation process
if record._approval_allowed():
record.button_approve()
if record.partner_id not in record.message_partner_ids:
record.message_subscribe([record.partner_id.id])
return res
# def button_confirm(self):
# self = self.with_context(skip_validation=True)
@@ -87,15 +97,14 @@ class jikimo_purchase_tier_validation(models.Model):
def _validate_tier(self, tiers=False):
res = super(jikimo_purchase_tier_validation, self)._validate_tier(tiers)
tier_reviews = tiers or self.review_ids
# 检查是否所有审批都已通过
all_approved = all(
tier_review.status == 'approved'
for tier_review in tier_reviews
for tier_review in self.review_ids
)
if all_approved and tier_reviews: # 确保有审批记录
if self.review_ids and all_approved: # 确保有审批记录
self.state = 'approved'
return res

View File

@@ -7,6 +7,7 @@
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[last()]" position="after">
<field name="routing_type" invisible="1"/>
<page string="异常记录" name="workorder_exception" attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}">
<field name="exception_ids" nolabel="1" readonly="1">
<tree create="false" delete="false" edit="false">

View File

@@ -350,7 +350,7 @@ class MrpProduction(models.Model):
if any((wo.test_results == '返工' and wo.state == 'done' and
(production.programming_state in ['已编程'] or wo.individuation_page_PTD is True))
or (wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中', '已编程'])
for wo in production.workorder_ids):
for wo in production.workorder_ids) or production.is_rework is True:
production.state = 'rework'
if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids):
production.state = 'scrap'

View File

@@ -126,9 +126,9 @@
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="inside">
<xpath expr="//form" position="inside">
<!-- 其他可见字段 -->
<field name="_barcode_scanned" widget="barcode_handler" invisible="1"/>
<field name="_barcode_scanned" widget="barcode_handler"/>
</xpath>
<!-- <xpath expr="//form" position="inside"> -->
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
@@ -312,6 +312,7 @@
<xpath expr="//page[1]" position="before">
<page string="工件装夹" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
<group>
<!-- <field name="_barcode_scanned" widget="barcode_handler"/> -->
<group string="托盘">
<field name="tray_serial_number" readonly="1" string="序列号"/>
</group>

View File

@@ -130,7 +130,10 @@ class ReSaleOrder(models.Model):
'order_id': self.id,
'product_id': product.id,
'name': '%s/%s/%s/%s/%s/%s' % (
product.model_long, product.model_width, product.model_height, product.model_volume,
self.format_float(product.model_long),
self.format_float(product.model_width),
self.format_float(product.model_height),
self.format_float(product.model_volume),
machining_accuracy_name,
product.materials_id.name),
'price_unit': product.list_price,
@@ -143,6 +146,20 @@ class ReSaleOrder(models.Model):
}
return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)
def format_float(self, value):
# 将浮点数转换为字符串
value_str = str(value)
# 检查小数点的位置
if '.' in value_str:
# 获取小数部分
decimal_part = value_str.split('.')[1]
# 判断小数位数是否超过2位
if len(decimal_part) > 2:
# 超过2位则保留2位小数
return "{:.2f}".format(value)
# 否则保持原来的位数
return float(value_str)
@api.constrains('order_line')
def check_order_line(self):
for item in self: