11from odoo import tools
2+ from odoo .exceptions import ValidationError
23from odoo .tests import Form , common , tagged
34
45
@@ -32,15 +33,21 @@ def test_15_liquido_producto_sales_patch(self):
3233
3334 # 60, 61, 27, 28, 45, 46
3435 # In this case manual numbering should be True and the latam document numer should be required
35- with self .assertRaisesRegex (AssertionError , "l10n_latam_document_number is a required field" ):
36- with Form (self .env ["account.move" ].with_context (default_move_type = "out_invoice" )) as invoice_form :
37- invoice_form .ref = "demo_liquido_producto_1: Vendor bill liquido producto (DOC 186)"
38- invoice_form .partner_id = self .res_partner_adhoc
39- invoice_form .invoice_payment_term_id = payment_term_id
40- invoice_form .journal_id = self .journal
41- invoice_form .l10n_latam_document_type_id = doc_27_lu_a
42- invoice = invoice_form .save ()
43- invoice .action_post () # Agregamos esta linea para que se dispare la validacion al momento de validar la factura y no antes
36+ with Form (self .env ["account.move" ].with_context (default_move_type = "out_invoice" )) as invoice_form :
37+ invoice_form .ref = "demo_liquido_producto_1: Vendor bill liquido producto (DOC 186)"
38+ invoice_form .partner_id = self .res_partner_adhoc
39+ invoice_form .invoice_payment_term_id = payment_term_id
40+ invoice_form .journal_id = self .journal
41+ invoice_form .l10n_latam_document_type_id = doc_27_lu_a
42+ with invoice_form .invoice_line_ids .new () as line_form :
43+ line_form .product_id = self .env .ref ("product.product_product_4" )
44+ line_form .quantity = 1
45+ line_form .price_unit = 100
46+ invoice = invoice_form .save ()
47+
48+ # Should fail when posting without document number
49+ with self .assertRaisesRegex (ValidationError , "Please set the document number" ):
50+ invoice .action_post ()
4451
4552 # Adding the document number will let us to save and validate the number without any problems
4653 with Form (self .env ["account.move" ].with_context (default_move_type = "out_invoice" )) as invoice_form :
@@ -50,6 +57,10 @@ def test_15_liquido_producto_sales_patch(self):
5057 invoice_form .journal_id = self .journal
5158 invoice_form .l10n_latam_document_type_id = doc_27_lu_a
5259 invoice_form .l10n_latam_document_number = "00077-00000077"
60+ with invoice_form .invoice_line_ids .new () as line_form :
61+ line_form .product_id = self .env .ref ("product.product_product_4" )
62+ line_form .quantity = 1
63+ line_form .price_unit = 100
5364 invoice = invoice_form .save ()
5465 invoice .action_post ()
5566
@@ -69,17 +80,23 @@ def test_16_liquido_producto_purchase_patch(self):
6980 doc_60_lp_a = self .env .ref ("l10n_ar.dc_a_cvl" )
7081 payment_term_id = self .env .ref ("account.account_payment_term_end_following_month" )
7182
72- with self .assertRaisesRegex (AssertionError , "l10n_latam_document_number is a required field" ):
73- with Form (self .env ["account.move" ].with_context (default_move_type = "in_invoice" )) as bill_form :
74- bill_form .ref = "demo_liquido_producto_1: Vendor bill liquido producto (DOC 186)"
75- bill_form .partner_id = self .res_partner_adhoc
76- bill_form .invoice_payment_term_id = payment_term_id
77- bill_form .invoice_date = "2023-02-09"
78- bill_form .l10n_latam_document_type_id = doc_60_lp_a
79- bill = bill_form .save ()
80- bill .action_post () # Agregamos esta linea para que se dispare la validacion al momento de validar la factura y no antes
83+ with Form (self .env ["account.move" ].with_context (default_move_type = "in_invoice" )) as bill_form :
84+ bill_form .ref = "demo_liquido_producto_1: Vendor bill liquido producto (DOC 186)"
85+ bill_form .partner_id = self .res_partner_adhoc
86+ bill_form .invoice_payment_term_id = payment_term_id
87+ bill_form .invoice_date = "2023-02-09"
88+ bill_form .l10n_latam_document_type_id = doc_60_lp_a
89+ with bill_form .invoice_line_ids .new () as line_form :
90+ line_form .product_id = self .env .ref ("product.product_product_4" )
91+ line_form .quantity = 1
92+ line_form .price_unit = 100
93+ bill = bill_form .save ()
94+
95+ self .assertEqual (bill .journal_id , purchase_not_pos_journal )
8196
82- self .assertEqual (bill .journal_id , purchase_not_pos_journal )
97+ # Should fail when posting without document number
98+ with self .assertRaisesRegex (ValidationError , "Please set the document number" ):
99+ bill .action_post ()
83100
84101 # Create a new journal that is an ARCA POS
85102 purchase_pos_journal = self ._create_journal ("preprinted" , data = {"type" : "purchase" , "l10n_ar_is_pos" : True })
@@ -92,6 +109,10 @@ def test_16_liquido_producto_purchase_patch(self):
92109 bill_form .journal_id = purchase_pos_journal
93110 bill_form .l10n_latam_document_type_id = doc_60_lp_a
94111 bill_form .l10n_latam_document_number = "00077-00000077"
112+ with bill_form .invoice_line_ids .new () as line_form :
113+ line_form .product_id = self .env .ref ("product.product_product_4" )
114+ line_form .quantity = 1
115+ line_form .price_unit = 100
95116 bill = bill_form .save ()
96117 bill .action_post ()
97118
0 commit comments