-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by rvalyi
- Loading branch information
Showing
6 changed files
with
152 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
from . import stock_rule | ||
from . import res_config_settings | ||
from . import stock_move | ||
from . import stock_picking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2024-Today - Akretion (<http://www.akretion.com>). | ||
# @author Magno Costa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = "stock.picking" | ||
|
||
def _get_default_fiscal_operation(self): | ||
fiscal_operation = super()._get_default_fiscal_operation() | ||
if self.purchase_id: | ||
if self.purchase_id.fiscal_operation_id: | ||
# Evita a inconsistência de ter o Pedido de Compras com uma | ||
# OP Fiscal e a Ordem de Seleção outra, quando o campo | ||
# invoice_state é alterado, o usuário pode alterar o campo | ||
# mas dessa forma forçamos a decisão de não usar a mesma | ||
# do Pedido. | ||
if fiscal_operation != self.purchase_id.fiscal_operation_id: | ||
fiscal_operation = self.purchase_id.fiscal_operation_id | ||
|
||
return fiscal_operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
# Renato Lima <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.tests import Form | ||
|
||
from odoo.addons.l10n_br_stock_account.tests.common import TestBrPickingInvoicingCommon | ||
|
||
|
||
|
@@ -446,3 +448,22 @@ def test_purchase_with_partner_to_shipping(self): | |
invoice.partner_id, | ||
"The Invoice Partner and Partner to Shipping should be the same.", | ||
) | ||
|
||
def test_form_stock_picking(self): | ||
"""Test Stock Picking with Form""" | ||
purchase = self.env.ref("l10n_br_purchase_stock.main_po_only_products_1") | ||
purchase.button_confirm() | ||
picking = purchase.picking_ids | ||
self.picking_move_state(picking) | ||
picking_form = Form(picking) | ||
|
||
# Alterando a OP Fiscal apenas para forçar a diferença | ||
picking.company_id.stock_in_fiscal_operation_id = False | ||
|
||
# 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(purchase.fiscal_operation_id, picking.fiscal_operation_id) | ||
picking_form.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters