diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 3d71b6c7..5ee7d8f2 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -59,18 +59,16 @@ class PurchaseOrder(models.Model): production_id = self.env['mrp.production'].search([('origin', 'in', origins)]) purchase.production_count = len(production_id) - # def button_confirm(self): - # super().button_confirm() - # workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id), ('state', '!=', 'cancel')]) - # for workorder in workorders: - # if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True: - # move_out = workorder.move_subcontract_workorder_ids[1] - # for mo in move_out: - # if mo.state != 'done': - # mo.write({'state': 'assigned', 'production_id': False}) - # if not mo.move_line_ids: - # self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder)) - # return True + def write(self, vals): + res = super(PurchaseOrder, self).write(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 res + origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id') origin_sale_ids = fields.Many2many('sale.order', string='销售订单号(多个)', store=True,