Skip to content

Commit

Permalink
[IMP] l10n_br_sale_stock: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbcosta committed Sep 27, 2024
1 parent 53bb6c8 commit da1ff15
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions l10n_br_sale_stock/tests/test_sale_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,6 @@ def test_lucro_presumido_company(self):
sale_order = sale_order_form.save()
sale_order.incoterm = self.env.ref("account.incoterm_FOB")

if hasattr(self.env["sale.order"], "payment_mode_id"):
payment_mode = self.env["account.payment.mode"].search(
[
("payment_type", "=", "inbound"),
("company_id", "=", self.env.company.id),
],
limit=1,
)
sale_order.payment_mode_id = payment_mode
sale_order.action_confirm()
picking = sale_order_1.picking_ids
self.picking_move_state(picking)
Expand Down Expand Up @@ -479,3 +470,45 @@ def test_button_create_bill_in_view(self):
"Field to make invisible the Button Create Bill should be"
" False when the Sale Order has Service and Product.",
)

def test_compatible_with_international_case(self):
"""
Test compatibility with international cases or
without Fiscal Operation.
"""
so_international = self.env.ref("sale.sale_order_3")
so_international.fiscal_operation_id = False
so_international.action_confirm()
picking = so_international.picking_ids
self.picking_move_state(picking)
invoice = self.create_invoice_wizard(picking)
invoice.action_post()
# Caso Internacional não deve ter Documento Fiscal associado
self.assertFalse(
invoice.fiscal_document_id,
"International case should not has Fiscal Document.",
)
# Teste Retorno
picking_devolution = self.return_picking_wizard(picking)
invoice_devolution = self.create_invoice_wizard(picking_devolution)
self.assertFalse(
invoice_devolution.fiscal_document_id,
"International case should not has Fiscal Document.",
)

def test_form_stock_picking(self):
"""Test Stock Picking with Form"""

sale_order = self.env.ref("l10n_br_sale_stock.main_so_l10n_br_sale_stock_1")
sale_order.action_confirm()
picking = sale_order.picking_ids
self.picking_move_state(picking)
picking_form = Form(picking)

# Apesar do metodo onchange retornar uma OP Fiscal padrão,
# quando existe um Pedido de Venda associado deve usar retornar
# a mesma OP Fiscal do Pedido.
picking_form.invoice_state = "none"
picking_form.invoice_state = "2binvoiced"
self.assertEqual(sale_order.fiscal_operation_id, picking.fiscal_operation_id)
picking_form.save()

0 comments on commit da1ff15

Please sign in to comment.