询价单行项目价格判断

This commit is contained in:
胡尧
2025-03-25 16:20:54 +08:00
parent 4d38a11c3c
commit 03539c7ed3

View File

@@ -58,6 +58,15 @@ class PurchaseOrder(models.Model):
origins = [order.name for order in purchase.picking_ids]
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
purchase.production_count = len(production_id)
def write(self, vals):
for record in self:
for line in record.order_line:
if line.product_qty <= 0:
raise UserError('请对【产品】中的【数量】进行输入')
if line.price_unit <= 0:
raise UserError('请对【产品】中的【单价】进行输入')
return super(PurchaseOrder, self).write(vals)
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')
@@ -134,11 +143,4 @@ class PurchaseOrderLine(models.Model):
# 如果手动设置了 part_name使用手动设置的值
record.part_name = record.manual_part_name
if record.manual_part_number:
record.part_number = record.manual_part_number
def write(self, vals):
if 'product_qty' in vals and vals.get('product_qty') <= 0:
raise UserError('请对【产品】中的【数量】进行输入')
if 'price_unit' in vals and vals.get('price_unit') <= 0:
raise UserError('请对【产品】中的【单价】进行输入')
return super(PurchaseOrderLine, self).write(vals)
record.part_number = record.manual_part_number