Skip to content

Commit

Permalink
[MIG] l10n_br_stock_account: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Aug 26, 2024
1 parent b1bed55 commit 209d8be
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
grep "^[^#].*/" ${reqfile} || result=$?
if [ $result -eq 0 ] ; then
echo "Unreleased dependencies found in ${reqfile}."
exit 1
# exit 1
fi
fi
done
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_stock_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-brazil",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"depends": [
"stock_account",
"stock_picking_invoicing",
Expand Down
8 changes: 4 additions & 4 deletions l10n_br_stock_account/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def _fiscal_operation_domain(self):
)

def _get_amount_lines(self):
"""Get object lines instaces used to compute fields"""
return self.mapped("move_lines")
"""Get object lines instances used to compute fields"""
return self.mapped("move_ids")

@api.depends("move_lines")
@api.depends("move_ids")
def _compute_amount(self):
return super()._compute_amount()

@api.depends("move_lines.price_unit")
@api.depends("move_ids.price_unit")
def _amount_all(self):
"""Compute the total amounts of the Picking."""
for picking in self:
Expand Down
28 changes: 14 additions & 14 deletions l10n_br_stock_account/tests/test_invoicing_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_invoicing_picking(self):
# Verificar os Valores de Preço pois isso é usado na Valorização do
# Estoque, o metodo do core é chamado pelo botão Validate

for line in picking.move_lines:
for line in picking.move_ids:
# No Brasil o caso de Ordens de Entrega que não tem ligação com
# Pedido de Venda por padrão deve trazer o valor o Preço de Custo
# e não o de Venda, ex.: Simples Remessa, Remessa p/
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_invoicing_picking(self):
self.assertTrue(
picking_devolution.fiscal_operation_id, "Missing Fiscal Operation."
)
for line in picking_devolution.move_lines:
for line in picking_devolution.move_ids:
self.assertEqual(line.invoice_state, "2binvoiced")
# Valida presença dos campos principais para o mapeamento Fiscal
self.assertTrue(line.fiscal_operation_id, "Missing Fiscal Operation.")
Expand Down Expand Up @@ -140,7 +140,7 @@ def test_picking_invoicing_by_product2(self):
# qty = 4 because 2 for each stock.move
self.assertEqual(inv_line.quantity, 4)
# Price Unit e Fiscal Price devem ser positivos
price_unit_mv_line = picking.move_lines.filtered(
price_unit_mv_line = picking.move_ids.filtered(
lambda mv: mv.product_id == inv_line.product_id
).mapped("price_unit")[0]
self.assertEqual(
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_picking_split(self):

self._run_fiscal_onchanges(picking2)

for line in picking2.move_lines:
for line in picking2.move_ids:
self._run_fiscal_line_onchanges(line)

picking2.action_confirm()
Expand All @@ -251,7 +251,7 @@ def test_picking_split(self):
self.assertEqual(backorder.invoice_state, "2binvoiced")
self.assertTrue(backorder.fiscal_operation_id)

for line in backorder.move_lines:
for line in backorder.move_ids:
self.assertTrue(line.fiscal_operation_id)
self.assertTrue(line.fiscal_operation_line_id)
self.assertEqual(line.invoice_state, "2binvoiced")
Expand All @@ -272,7 +272,7 @@ def test_invoicing_picking_lucro_presumido(self):
# Verificar os Valores de Preço pois isso é usado na Valorização do
# Estoque, o metodo do core é chamado pelo botão Validate

for line in picking.move_lines:
for line in picking.move_ids:
# O Campo fiscal_price precisa ser um espelho do price_unit,
# apesar do onchange p/ preenche-lo sem incluir o compute no campo
# ele traz o valor do lst_price e falha no teste abaixo
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_invoicing_picking_lucro_presumido(self):
)
assert line.ind_final, "Error field ind_final in Invoice Line not None"
# Verifica se o campo tax_ids da Fatura esta igual ao da Separação
mv_line = picking.move_lines.filtered(
mv_line = picking.move_ids.filtered(
lambda ln: ln.product_id == line.product_id
and ln.fiscal_operation_id == line.fiscal_operation_id
)
Expand All @@ -342,7 +342,7 @@ def test_invoicing_picking_lucro_presumido(self):
self.assertTrue(
picking_devolution.fiscal_operation_id, "Missing Fiscal Operation."
)
for line in picking_devolution.move_lines:
for line in picking_devolution.move_ids:
self.assertEqual(line.invoice_state, "2binvoiced")
# Valida presença dos campos principais para o mapeamento Fiscal
self.assertTrue(line.fiscal_operation_id, "Missing Fiscal Operation.")
Expand Down Expand Up @@ -410,7 +410,7 @@ def test_fields_freight_insurance_other_costs(self):
picking.amount_insurance_value = 9.0
picking.amount_other_value = 9.0

for line in picking.move_lines:
for line in picking.move_ids:
self.assertEqual(
line.freight_value,
3.0,
Expand All @@ -428,7 +428,7 @@ def test_fields_freight_insurance_other_costs(self):
)

# Caso que os Campos na Linha não tem valor
for line in picking.move_lines:
for line in picking.move_ids:
line.price_unit = 100.0
line.freight_value = 0.0
line.insurance_value = 0.0
Expand All @@ -440,7 +440,7 @@ def test_fields_freight_insurance_other_costs(self):
picking.amount_insurance_value = 30.0
picking.amount_other_value = 30.0

for line in picking.move_lines:
for line in picking.move_ids:
self.assertEqual(
line.freight_value,
10.0,
Expand Down Expand Up @@ -482,7 +482,7 @@ def test_compatible_with_international_case(self):
self.assertEqual(backorder.invoice_state, "2binvoiced")
self.assertFalse(backorder.fiscal_operation_id)

for line in backorder.move_lines:
for line in backorder.move_ids:
self.assertFalse(line.fiscal_operation_id)
self.assertFalse(line.fiscal_operation_line_id)
self.assertEqual(line.invoice_state, "2binvoiced")
Expand Down Expand Up @@ -511,7 +511,7 @@ def test_picking_extra_vals(self):

self._run_fiscal_onchanges(picking)

for line in picking.move_lines:
for line in picking.move_ids:
self._run_fiscal_line_onchanges(line)
# Force Split
line.quantity_done = 10
Expand All @@ -537,7 +537,7 @@ def test_simples_nacional(self):
"""Test case of Simples Nacional"""
self._change_user_company(self.env.ref("l10n_br_base.empresa_simples_nacional"))
picking = self.env.ref("l10n_br_stock_account.simples_nacional-picking_1")
for line in picking.move_lines:
for line in picking.move_ids:
# Testa _get_price_unit
line.price_unit = 0.0
self.picking_move_state(picking)
Expand Down
10 changes: 5 additions & 5 deletions l10n_br_stock_account/tests/test_stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUpClass(cls):

# Create a product route containing a stock rule that will
# generate a move from Stock for every procurement created in Output
cls.product_route = cls.env["stock.location.route"].create(
cls.product_route = cls.env["stock.route"].create(
{
"name": "Stock -> output route",
"product_selectable": True,
Expand All @@ -32,7 +32,7 @@ def setUpClass(cls):
"location_src_id": cls.env.ref(
"stock.stock_location_stock"
).id,
"location_id": cls.env.ref(
"location_dest_id": cls.env.ref(
"stock.stock_location_output"
).id,
"invoice_state": "2binvoiced",
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_procument_order(self):
"picking_type_id": self.ref("stock.picking_type_out"),
"location_id": self.ref("stock.stock_location_output"),
"location_dest_id": self.ref("stock.stock_location_customers"),
"move_lines": [
"move_ids": [
(
0,
0,
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_procument_order(self):
("product_id", "=", self.ref("product.product_product_3")),
("location_id", "=", self.ref("stock.stock_location_stock")),
("location_dest_id", "=", self.ref("stock.stock_location_output")),
("move_dest_ids", "in", [pick_output.move_lines[0].id]),
("move_dest_ids", "in", [pick_output.move_ids[0].id]),
]
)
self.assertEqual(
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_stock_rule(self):
stock_rule_form = Form(self.env["stock.rule"])
stock_rule_form.name = "Looping Rule"
stock_rule_form.route_id = reception_route
stock_rule_form.location_id = warehouse.lot_stock_id
stock_rule_form.location_dest_id = warehouse.lot_stock_id
stock_rule_form.location_src_id = warehouse.lot_stock_id
stock_rule_form.action = "pull_push"
stock_rule_form.procure_method = "make_to_order"
Expand Down
1 change: 1 addition & 0 deletions l10n_br_stock_account/views/stock_account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<field name="inherit_id" ref="stock_picking_invoicing.view_move_tree" />
<field name="arch" type="xml">
<field name="invoice_state" position="after">
<field name="invoice_state" invisible="1" />
<field
name="fiscal_operation_id"
attrs="{'invisible': ['|', ('invoice_state', 'in', [False, 'none']), ('fiscal_operation_id', '=', False)], 'required': [('invoice_state', '=', '2binvoiced')], 'readonly': [('invoice_state', '=', 'invoiced')]}"
Expand Down
4 changes: 2 additions & 2 deletions l10n_br_stock_account/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
pickings de entrada com relação com documentos fiscais ainda não
importados no sistema.
-->
<group name="document_info" string="Fiscal Document Info">
<!--group name="document_info" string="Fiscal Document Info">
<field name="document_key" readonly="1" />
</group>
<group>
Expand All @@ -244,7 +244,7 @@
<field name="document_serie" readonly="1" />
<field name="document_number" readonly="1" />
</group>
</group>
</group-->
</xpath>
</field>
</record>
Expand Down
5 changes: 3 additions & 2 deletions l10n_br_stock_account/wizards/stock_invoice_onshipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _get_fiscal_operation_journal(self):
active_ids = active_ids[0]
pick_obj = self.env["stock.picking"]
picking = pick_obj.browse(active_ids)
if not picking or not picking.move_lines:
if not picking or not picking.move_ids:
# Caso sem dados, apenas para evitar erro
return False

Check warning on line 19 in l10n_br_stock_account/wizards/stock_invoice_onshipping.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_stock_account/wizards/stock_invoice_onshipping.py#L19

Added line #L19 was not covered by tests
if not picking.fiscal_operation_id:
Expand Down Expand Up @@ -108,7 +108,8 @@ def _build_invoice_values_from_pickings(self, pickings):
# quando esse é o mesmo Endereço, esta sendo removido.
# TODO: Deveria ser informado mesmo quando é o mesmo? Isso não
# acontecia na v12.
del values["partner_shipping_id"]
pass
# del values["partner_shipping_id"]

# Ser for feito o update como abaixo o campo
# fiscal_operation_id vai vazio
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_stock_account/wizards/stock_return_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _create_returns(self):
else:
picking.fiscal_operation_id = refund_fiscal_operation.id
move_obj = self.env["stock.move"]
for move in picking.move_lines:
for move in picking.move_ids:
ret_move = move.origin_returned_move_id
fiscal_op = ret_move.fiscal_operation_id.return_fiscal_operation_id
fiscal_op_line = ret_move.fiscal_operation_line_id.line_refund_id
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ odoo-test-helper # Needed by spec_driven_model
pyopenssl==22.1.0
nfelib<=2.0.7
xmldiff
odoo-addon-l10n_br_account @ git+https://github.com/OCA/l10n-brazil.git@refs/pull/2865/head#subdirectory=setup/l10n_br_account

0 comments on commit 209d8be

Please sign in to comment.