Skip to content

Commit

Permalink
[FIX]CI FAIL,属性是否填充的约束放在审核时检查
Browse files Browse the repository at this point in the history
  • Loading branch information
floraXiao committed Jul 10, 2018
1 parent 12d284c commit bbfa942
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
9 changes: 3 additions & 6 deletions buy/models/buy_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ def buy_order_done(self):
if not self.line_ids:
raise UserError(u'请输入商品明细行')
for line in self.line_ids:
# 检查属性是否填充,防止无权限人员不填就可以保存
if line.using_attribute and not line.attribute_id:
raise UserError(u'请输入商品:%s 的属性' % line.goods_id.name)
if line.quantity <= 0 or line.price_taxed < 0:
raise UserError(u'商品 %s 的数量和含税单价不能小于0' % line.goods_id.name)
if line.tax_amount > 0 and self.currency_id:
Expand Down Expand Up @@ -682,12 +685,6 @@ def onchange_discount_rate(self):
self.price = self.price_taxed / (1 + self.tax_rate * 0.01)
self.discount_amount = (self.quantity * self.price *
self.discount_rate * 0.01)
@api.one
@api.constrains('attribute_id')
def check_attribute(self):
'''检查属性是否填充,防止无权限人员不填就可以保存'''
if self.using_attribute and not self.attribute_id:
raise UserError(u'请输入商品:%s 的属性' % self.goods_id.name)

class Payment(models.Model):
_name = "payment.plan"
Expand Down
1 change: 1 addition & 0 deletions scm/models/stock_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def stock_request_done(self):
request_line_ids = self.env['stock.request.line'].create({
'request_id': self.id,
'goods_id': line_out.goods_id.id,
'attribute_id': line_out.attribute_id and line_out.attribute_id.id or False,
'to_delivery_qty': line_out.goods_qty,
'request_qty': line_out.goods_qty,
'uom_id': line_out.goods_id.uom_id.id,
Expand Down
10 changes: 3 additions & 7 deletions sell/models/sell_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ def sell_order_done(self):
if not self.line_ids:
raise UserError(u'请输入商品明细行!')
for line in self.line_ids:
# 检查属性是否填充,防止无权限人员不填就可以保存
if line.using_attribute and not line.attribute_id:
raise UserError(u'请输入商品:%s 的属性' % line.goods_id.name)
if line.quantity <= 0 or line.price_taxed < 0:
raise UserError(u'商品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
if line.tax_amount > 0 and self.currency_id:
Expand Down Expand Up @@ -610,13 +613,6 @@ def onchange_discount_rate(self):
self.discount_amount = self.quantity * self.price \
* self.discount_rate * 0.01

@api.one
@api.constrains('attribute_id')
def check_attribute(self):
'''检查属性是否填充,防止无权限人员不填就可以保存'''
if self.using_attribute and not self.attribute_id:
raise UserError(u'请输入商品:%s 的属性' % self.goods_id.name)


class ApproveMultiSellOrder(models.TransientModel):
_name = "approve.multi.sell.order"
Expand Down
3 changes: 2 additions & 1 deletion sell/tests/test_sell_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,11 @@ def test_goods_inventory(self):

def test_sell_delivery_done_not_create_voucher(self):
'''发库单审核商品不足时不生成凭证'''
# 一个有批号管理的鼠标缺货
# 一个网线缺货
self.warehouse_obj.cancel_approved_order()
order_1 = self.env.ref('sell.sell_order_1')
for line in order_1.line_ids:
line.goods_id = self.env.ref('goods.cable')
line.quantity = 1
line.discount_amount = 0
order_1.sell_order_done()
Expand Down
36 changes: 18 additions & 18 deletions warehouse_wave/tests/test_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ def test_unlink(self):
''' 测试 wave unlink'''
self.wave[0].unlink()

order_1 = self.env.ref('sell.sell_order_1')
self.env.ref('sell.sell_order_line_1').tax_rate = 0
self.env.ref('sell.sell_order_line_1').quantity = 1
self.env.ref('sell.sell_order_line_1').discount_amount = 0
order_1.discount_amount = 0
order_1.warehouse_id = self.env.ref('warehouse.hd_stock').id
order_1.sell_order_done()
order_3 = self.env.ref('sell.sell_order_3')
self.env.ref('sell.sell_order_line_3').tax_rate = 0
self.env.ref('sell.sell_order_line_3').quantity = 1
self.env.ref('sell.sell_order_line_3').discount_amount = 0
order_3.discount_amount = 0
order_3.warehouse_id = self.env.ref('warehouse.hd_stock').id
order_3.sell_order_done()
delivery_1 = self.env['sell.delivery'].search(
[('order_id', '=', order_1.id)])
[('order_id', '=', order_3.id)])
delivery_1.date = '2016-01-02'
delivery_1.express_code = '123456'
delivery_1.express_type = 'SF'
Expand All @@ -265,7 +265,7 @@ def test_unlink(self):
pack.scan_barcode('123456', pack.id)

# 发货单已经打包发货,捡货单不允许删除
self.env.ref('goods.mouse').barcode = '000'
self.env.ref('goods.cable').barcode = '000'
pack.scan_barcode('000', pack.id)
with self.assertRaises(UserError):
wave_2.unlink()
Expand Down Expand Up @@ -385,15 +385,15 @@ def test_scan_barcode_needs_pack_qty(self):

def test_scan_barcode_is_pack_ok(self):
''' 测试 is_pack_ok, common.dialog.wizard '''
order_1 = self.env.ref('sell.sell_order_1')
order_1.warehouse_id = self.env.ref('warehouse.hd_stock').id
self.env.ref('sell.sell_order_line_1').quantity = 1
self.env.ref('sell.sell_order_line_1').discount_amount = 0
self.env.ref('sell.sell_order_line_1').tax_rate = 0
order_1.discount_amount = 0
order_1.sell_order_done()
order_3 = self.env.ref('sell.sell_order_3')
order_3.warehouse_id = self.env.ref('warehouse.hd_stock').id
self.env.ref('sell.sell_order_line_3').quantity = 1
self.env.ref('sell.sell_order_line_3').discount_amount = 0
self.env.ref('sell.sell_order_line_3').tax_rate = 0
order_3.discount_amount = 0
order_3.sell_order_done()
delivery_1 = self.env['sell.delivery'].search(
[('order_id', '=', order_1.id)])
[('order_id', '=', order_3.id)])
delivery_1.express_code = '8888'
delivery_1.express_type = 'SF'
delivery_1.date = '2016-01-02'
Expand All @@ -404,7 +404,7 @@ def test_scan_barcode_is_pack_ok(self):
self.env.ref('warehouse.wh_in_whin0').cancel_approved_order()
pack = self.env['do.pack'].create({})
pack.scan_barcode('8888', pack.id)
self.env.ref('goods.mouse').barcode = '222'
self.env.ref('goods.cable').barcode = '222'
pack.scan_barcode('222', pack.id)


Expand Down

0 comments on commit bbfa942

Please sign in to comment.