Skip to content

Commit

Permalink
[MIG] l10n_br_purchase: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Sep 6, 2024
1 parent 914e538 commit 4cfff3b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
2 changes: 1 addition & 1 deletion l10n_br_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Akretion, Odoo Community Association (OCA)",
"maintainers": ["renatonlima", "rvalyi"],
"website": "https://github.com/OCA/l10n-brazil",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"depends": ["purchase", "l10n_br_account"],
"data": [
# Security
Expand Down
28 changes: 4 additions & 24 deletions l10n_br_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,10 @@ def _fiscal_operation_domain(self):
)

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
order_view = super().fields_view_get(view_id, view_type, toolbar, submenu)

if view_type == "form":
view = self.env["ir.ui.view"]

sub_form_view = order_view["fields"]["order_line"]["views"]["form"]["arch"]

sub_form_node = self.env["purchase.order.line"].inject_fiscal_fields(
sub_form_view
)

sub_arch, sub_fields = view.postprocess_and_fields(
sub_form_node, "purchase.order.line"
)

order_view["fields"]["order_line"]["views"]["form"] = {
"fields": sub_fields,
"arch": sub_arch,
}

return order_view
def _get_view(self, view_id=None, view_type="form", **options):
arch, view = super()._get_view(view_id, view_type, **options)
arch = self.env["purchase.order.line"].inject_fiscal_fields(arch)
return arch, view

@api.onchange("fiscal_operation_id")
def _onchange_fiscal_operation_id(self):
Expand Down
4 changes: 1 addition & 3 deletions l10n_br_purchase/models/purchase_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ def _compute_amount(self):
def _onchange_quantity(self):
"""To call the method in the mixin to update
the price and fiscal quantity."""
result = super()._onchange_quantity()
self._onchange_commercial_quantity()
return result
return self._onchange_commercial_quantity()

def _compute_tax_id(self):
for line in self:
Expand Down
11 changes: 3 additions & 8 deletions l10n_br_purchase/tests/test_l10n_br_purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Magno Costa <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from lxml import etree

from odoo.tests import Form, TransactionCase

from odoo.addons.l10n_br_fiscal.constants.fiscal import (
Expand Down Expand Up @@ -276,7 +274,6 @@ def _invoice_purchase_order(self, order):
)

for line in invoice.invoice_line_ids:
line._onchange_price_subtotal()
self.assertTrue(
line.fiscal_operation_line_id,
"Error to included Operation " "Line from Purchase Order Line.",
Expand Down Expand Up @@ -451,12 +448,10 @@ def test_form_purchase(self):

purchase_form.save()

def test_fields_view_get(self):
"""Test Purchase Order fields_view_get."""
view_arch = etree.fromstring(self.po_products.fields_view_get()["arch"])

def test_get_view(self):
arch, models = self.po_products._get_view()
self.assertTrue(
view_arch.findall(".//field[@name='fiscal_operation_id']"),
arch.findall(".//field[@name='fiscal_operation_id']"),
"Error to included Operation " "Line from Purchase Order Line.",
)

Expand Down
7 changes: 4 additions & 3 deletions l10n_br_purchase/views/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<field name="fiscal_genre_code" invisible="1" />
<field name="tax_framework" invisible="1" />
<field name="tax_icms_or_issqn" invisible="1" />
<field name="product_uom" invisible="1" />
</group>
</xpath>
<xpath
Expand All @@ -81,7 +82,7 @@
'required': [('display_type', '=', False)],
}</attribute>
<attribute name="context">{
'partner_id':parent.partner_id, 'quantity':product_qty,'uom':product_uom, 'company_id': parent.company_id
'partner_id':parent.partner_id, 'quantity':product_qty, 'uom':product_uom, 'company_id': parent.company_id
}</attribute>
</xpath>
<xpath
Expand Down Expand Up @@ -210,7 +211,7 @@
options="{'currency_field': 'currency_id'}"
/>
</xpath>
<xpath expr="//field[@name='tax_totals_json']" position="before">
<xpath expr="//field[@name='tax_totals']" position="before">
<field
name="amount_price_gross"
widget="monetary"
Expand All @@ -222,7 +223,7 @@
options="{'currency_field': 'currency_id'}"
/>
</xpath>
<xpath expr="//field[@name='tax_totals_json']" position="after">
<xpath expr="//field[@name='tax_totals']" position="after">
<field name="delivery_costs" invisible="1" />
<field
name="amount_freight_value"
Expand Down

0 comments on commit 4cfff3b

Please sign in to comment.