Skip to content

Commit

Permalink
[ADD]销货订单上增加净重合计及添加测试
Browse files Browse the repository at this point in the history
  • Loading branch information
floraXiao committed Jul 26, 2018
1 parent 6fb48f4 commit a6acf9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sell/models/sell_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def _compute_delivery(self):
order.delivery_count = len([deli for deli in order.delivery_ids if not deli.is_return])
order.return_count = len([deli for deli in order.delivery_ids if deli.is_return])

@api.one
@api.depends('line_ids.goods_id', 'line_ids.quantity')
def _compute_net_weight(self):
'''计算净重合计'''
self.net_weight = sum(line.goods_id.net_weight * line.quantity for line in self.line_ids)

partner_id = fields.Many2one('partner', u'客户',
ondelete='restrict', states=READONLY_STATES,
help=u'签约合同的客户')
Expand Down Expand Up @@ -194,6 +200,8 @@ def _compute_delivery(self):
readonly=True,
copy=False,
help=u'输入预收款确认时产生的预收款单')
net_weight = fields.Float(
string=u'净重合计', compute='_compute_net_weight', store=True)

@api.onchange('address_id')
def onchange_partner_address(self):
Expand Down
6 changes: 6 additions & 0 deletions sell/tests/test_sell_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ def test_sell_order_done_no_attribute(self):
with self.assertRaises(UserError):
self.order.sell_order_done()

def test_compute_net_weight(self):
'''计算净重合计'''
self.env.ref('goods.mouse').net_weight = 50
self.order.line_ids[0].quantity = 10
self.assertEqual(self.order.net_weight, 50 * 10)


class TestSellOrderLine(TransactionCase):

Expand Down

0 comments on commit a6acf9e

Please sign in to comment.