Debian Codegraph @

addons/pos_sale_margin/tests/test_pos_sale_margin_report.py

raw
1 # -*- coding: utf-8 -*-
2 # Part of Odoo. See LICENSE file for full copyright and licensing details.
3 import odoo
4
5 from odoo.addons.point_of_sale.tests.common import TestPoSCommon
6
7
8 @odoo.tests.tagged('post_install', '-at_install')
9 class TestPoSSaleMarginReport(TestPoSCommon):
10
11 def setUp(self):
12 super(TestPoSSaleMarginReport, self).setUp()
13 self.config = self.basic_config
14
15 def test_pos_sale_margin_report(self):
16
17 product1 = self.create_product('Product 1', self.categ_basic, 150, standard_price=50)
18
19 self.open_new_session()
20 session = self.pos_session
21
22 self.env['pos.order'].create({
23 'session_id': session.id,
24 'lines': [(0, 0, {
25 'name': "OL/0001",
26 'product_id': product1.id,
27 'price_unit': 450,
28 'discount': 5.0,
29 'qty': 1.0,
30 'price_subtotal': 150,
31 'price_subtotal_incl': 150,
32 'total_cost': 50,
33 }),],
34 'amount_total': 150.0,
35 'amount_tax': 0.0,
36 'amount_paid': 0.0,
37 'amount_return': 0.0,
38 })
39
40 # PoS Orders have negative IDs to avoid conflict, so reports[0] will correspond to the newest order
41 reports = self.env['sale.report'].sudo().search([('product_id', '=', product1.id)], order='id')
42
43 self.assertEqual(reports[0].margin, 100)