新增单件用量显示

This commit is contained in:
guanhuan
2025-07-14 15:39:37 +08:00
parent 0441f345ef
commit 5902d61f13
2 changed files with 8 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ class SfDemandPlan(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')
manual_quotation = fields.Boolean('人工编程',related='product_id.manual_quotation', default=False) 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(
@@ -224,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',
@@ -243,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

@@ -38,8 +38,8 @@
<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="unit_number" optional="hide"/>
<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"/>