diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index d05e6b63..3cc0d877 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -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) \ No newline at end of file + record.part_number = record.manual_part_number \ No newline at end of file