Skip to content

Commit

Permalink
Merge 1052fdd into 43a840d
Browse files Browse the repository at this point in the history
  • Loading branch information
floraXiao committed Jul 10, 2018
2 parents 43a840d + 1052fdd commit 5729ba4
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 21 deletions.
7 changes: 7 additions & 0 deletions buy/models/buy_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,10 @@ 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)
4 changes: 3 additions & 1 deletion 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 @@ -683,7 +686,6 @@ def onchange_discount_rate(self):
self.discount_amount = (self.quantity * self.price *
self.discount_rate * 0.01)


class Payment(models.Model):
_name = "payment.plan"
_description = u'付款计划'
Expand Down
1 change: 1 addition & 0 deletions buy/tests/test_buy_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_buy_adjust_done(self):
}),
(0, 0, {'goods_id': self.mouse.id,
'quantity': 1,
'lot': 'mouse001',
}),
(0, 0, {'goods_id': self.cable.id,
'quantity': 1,
Expand Down
1 change: 1 addition & 0 deletions buy/tests/test_buy_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def test_buy_generate_receipt(self):
new_order = self.order.copy()
for line in new_order.line_ids:
line.goods_id = self.env.ref('goods.mouse').id
line.lot = 'mouse001'
new_order.buy_generate_receipt()
receipt = self.env['buy.receipt'].search(
[('order_id', '=', new_order.id)])
Expand Down
1 change: 1 addition & 0 deletions buy/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def setUp(self):
order_2.quantity = 1
for line in order_2.line_ids:
line.goods_id = self.env.ref('goods.mouse').id
line.lot = 'mouse001'
order_2.bank_account_id = False
order_2.buy_order_done()
receipt_2 = self.env['buy.receipt'].search(
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
7 changes: 7 additions & 0 deletions sell/models/sell_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,10 @@ 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)
3 changes: 3 additions & 0 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
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
3 changes: 2 additions & 1 deletion sell_to_buy/models/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ class buy_order_line(models.Model):
def unlink(self):
'''删除购货订单行时,如果对应销货订单行已采购,则去掉打勾'''
for line in self:
line.sell_line_id.is_bought = False
if line.sell_line_id:
line.sell_line_id.is_bought = False
return super(buy_order_line, self).unlink()
10 changes: 10 additions & 0 deletions warehouse/models/warehouse_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ def check_availability(self):
# 如果是 商品库位转移生成的内部移库,则不用约束调入仓和调出仓是否相同;否则需要约束
if not (self.move_id.origin == 'wh.internal' and not self.location_id == False):
raise UserError(u'调出仓库不可以和调入仓库一样')
# 检查属性或批号是否填充,防止无权限人员不填就可以保存
if self.using_attribute and not self.attribute_id:
raise UserError(u'请输入商品:%s 的属性' % self.goods_id.name)
if self.using_batch:
if self.type == 'in' and not self.lot:
raise UserError(u'请输入商品:%s 的批号' % self.goods_id.name)
if self.type in ['out', 'internal'] and not self.lot_id:
raise UserError(u'请选择商品:%s 的批号' % self.goods_id.name)

def prev_action_done(self):
pass
Expand Down Expand Up @@ -345,6 +353,8 @@ def action_done(self):
'warehouse_id': line.warehouse_dest_id.id,
'warehouse_dest_id': self.env.user.company_id.wh_scrap_id.id
}
if line.lot:
dic.update({'lot_id': line.id})
wh_internal = self.env['wh.internal'].search([('ref', '=', line.move_id.name)])
if not wh_internal:
value = {
Expand Down
4 changes: 4 additions & 0 deletions warehouse/tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ def test_generate_inventory(self):

def test_check_done_state_done(self):
''' Test: check_done state == 'done' '''
mouse_line = self.browse_ref('warehouse.wh_move_line_12')
mouse_line.action_done()
for line in self.inventory.line_ids:
if line.goods_id.name == u'鼠标':
mouse = line
Expand All @@ -211,6 +213,8 @@ def test_check_done_state_done(self):
# 此时鼠标数量-1,生成一个鼠标的出库单
self.inventory.generate_inventory()

# 鼠标进行批号管理,出库行必须选择一个批号
self.inventory.out_id.line_out_ids[0].lot_id = mouse_line.id
self.inventory.out_id.approve_order()
self.inventory.out_id.cancel_approved_order()

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 5729ba4

Please sign in to comment.