Skip to content

Commit

Permalink
[IMP] 添加 buy_receipt 测试数据;代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
USI-SHRD committed Jun 19, 2018
1 parent 581cb1a commit 8ec0941
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion auto_exchange/models/auto_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_web_exchange(self, line_date):
url, 'POST', headers=headers, body=urllib.urlencode(body))
result = etree.HTML(content.decode('utf8')).xpath(
'//table[@cellpadding="0"]/tr[4]/td/text()')
except httplib2.HttpLib2Error:
except httplib2.HttpLib2Error: # pragma: no cover
raise UserError(u'网页设置有误(%s)请联系作者:(qq:2201864)' % url)
return result[5]

Expand Down
3 changes: 0 additions & 3 deletions buy/models/buy_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ def _wrong_receipt_done(self):
if line.goods_qty <= 0 or line.price_taxed < 0:
raise UserError(u'商品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
if line.goods_id.force_batch_one:
if line.goods_qty > 1:
raise UserError(u'商品 %s 进行了序列号管理,数量必须为1' %
line.goods_id.name)
batch_one_list.append((line.goods_id.id, line.lot))

if len(batch_one_list) > len(set(batch_one_list)):
Expand Down
23 changes: 23 additions & 0 deletions buy/tests/test_buy_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,29 @@ def test_buy_to_return(self):
with self.assertRaises(UserError):
self.receipt.buy_to_return()

def test_buy_to_return_using_batch(self):
''' 采购入库单转化为采购退货单:订单行产品进行了批次管理 '''
self.receipt.line_in_ids[0].goods_id.using_batch = True
self.receipt.line_in_ids[0].lot = '1'
self.receipt.line_in_ids[0].copy()
self.receipt.buy_receipt_done()
self.receipt.buy_to_return()

def test_buy_receipt_done_return_order_has_payment(self):
''' 有付款的采购退货单 系统认为是纯退货,不再生成草稿状态的发货单 '''
self.receipt.line_in_ids[0].copy()
self.receipt.buy_receipt_done()
self.receipt.buy_to_return()

return_order = self.env['buy.receipt'].search([
('is_return', '=', True),
('origin_id', '=', self.receipt.id),
])
return_order.payment = 2
return_order.bank_account_id = self.bank_account.id
return_order.buy_receipt_done()



class TestWhMoveLine(TransactionCase):

Expand Down

0 comments on commit 8ec0941

Please sign in to comment.