修复bug
This commit is contained in:
@@ -81,6 +81,25 @@ class ReSaleOrder(models.Model):
|
||||
}
|
||||
return self.env['sale.order.line'].create(vals)
|
||||
|
||||
@api.constrains('order_line')
|
||||
def check_order_line(self):
|
||||
for item in self:
|
||||
if not item.order_line:
|
||||
raise UserError('请选择【订单行】中的【产品】')
|
||||
for line in item.order_line:
|
||||
if not line.product_template_id:
|
||||
raise UserError('请对【订单行】中的【产品】进行选择')
|
||||
if not line.name:
|
||||
raise UserError('请对【订单行】中的【说明】进行输入')
|
||||
if line.product_qty == 0:
|
||||
raise UserError('请对【订单行】中的【数量】进行输入')
|
||||
if not line.product_uom:
|
||||
raise UserError('请对【订单行】中的【计量单位】进行选择')
|
||||
if line.price_unit == 0:
|
||||
raise UserError('请对【订单行】中的【单价】进行输入')
|
||||
if not line.taxes_id:
|
||||
raise UserError('请对【订单行】中的【税】进行选择')
|
||||
|
||||
|
||||
class ResaleOrderLine(models.Model):
|
||||
_inherit = 'sale.order.line'
|
||||
@@ -95,6 +114,28 @@ class RePurchaseOrder(models.Model):
|
||||
check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态')
|
||||
remark = fields.Text('备注')
|
||||
|
||||
def button_confirming(self):
|
||||
self.write({'state': 'purchase', 'check_status': 'pending'})
|
||||
|
||||
@api.constrains('order_line')
|
||||
def check_order_line(self):
|
||||
for item in self:
|
||||
if not item.order_line:
|
||||
raise UserError('该询价单未添加【产品】,请进行添加')
|
||||
for line in item.order_line:
|
||||
if not line.product_id:
|
||||
raise UserError('【产品】未添加,请进行添加')
|
||||
if not line.name:
|
||||
raise UserError('请对【产品】中的【说明】进行输入')
|
||||
if line.product_qty == 0:
|
||||
raise UserError('请对【产品】中的【数量】进行输入')
|
||||
if not line.product_uom:
|
||||
raise UserError('请对【产品】中的【计量单位】进行选择')
|
||||
if line.price_unit == 0:
|
||||
raise UserError('请对【产品】中的【单价】进行输入')
|
||||
if not line.taxes_id:
|
||||
raise UserError('请对【产品】中的【税】进行选择')
|
||||
|
||||
def write(self, vals):
|
||||
if self.env.user.has_group('sf_base.group_purchase_director'):
|
||||
if vals.get('check_status'):
|
||||
@@ -103,9 +144,19 @@ class RePurchaseOrder(models.Model):
|
||||
return super().write(vals)
|
||||
|
||||
def button_confirm(self):
|
||||
self.check_status = 'pending'
|
||||
res = super().button_confirm()
|
||||
return res
|
||||
for order in self:
|
||||
if order.state not in ['draft', 'sent', 'purchase']:
|
||||
continue
|
||||
order.order_line._validate_analytic_distribution()
|
||||
order._add_supplier_to_product()
|
||||
# Deal with double validation process
|
||||
if order._approval_allowed():
|
||||
order.button_approve()
|
||||
else:
|
||||
order.write({'state': 'to approve'})
|
||||
if order.partner_id not in order.message_partner_ids:
|
||||
order.message_subscribe([order.partner_id.id])
|
||||
return True
|
||||
|
||||
|
||||
class ResPartnerToSale(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user