Debian Codegraph @

addons/sale_loyalty/tests/test_sale_auto_invoice.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo.fields import Command
4 from odoo.tests import tagged
5
6 from odoo.addons.sale_loyalty.tests.common import TestSaleCouponCommon
7
8
9 @tagged('post_install', '-at_install')
10 class TestSaleAutoInvoice(TestSaleCouponCommon):
11
12 def test_automatic_invoice_on_zero_amount_order(self):
13 self.env['ir.config_parameter'].sudo().set_param('sale.automatic_invoice', 'True')
14 # Create a loyalty program with 100% discount
15 self.env['loyalty.program'].sudo().create({
16 'name': '100discount',
17 'program_type': 'promo_code',
18 'rule_ids': [
19 Command.create({
20 'code': "100dis",
21 'minimum_amount': 0,
22 })
23 ],
24 'reward_ids': [
25 Command.create({
26 'discount': 100,
27 }),
28 ],
29 })
30 # Add order line to order
31 self.env["sale.order.line"].create({
32 'order_id': self.empty_order.id,
33 'product_id': self.product_A.id,
34 'product_uom_qty': 1,
35 'price_unit': 200,
36 })
37 # Apply discount
38 self._apply_promo_code(self.empty_order, '100dis')
39 self.empty_order._validate_order()
40 self.assertTrue(
41 self.empty_order.invoice_ids,
42 "Invoices should be generated for orders with zero total amount",
43 )