Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions l10n_br_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class AccountMove(models.Model):

_order = "date DESC, name DESC"

_popup_button_xpaths = [
("//field[@name='invoice_line_ids']/list/field[@name='product_id']", "before"),
]

document_electronic = fields.Boolean(
related="document_type_id.electronic",
string="Electronic?",
Expand Down Expand Up @@ -214,20 +218,20 @@ def _get_view(self, view_id=None, view_type="form", **options):
arch, view = super()._get_view(view_id, view_type, **options)
if self.env.company.country_id.code != "BR" or view_type != "form":
return arch, view
if view_type == "form" and self.env.company.country_id.code == "BR":
if view_type == "form":
arch = self.env["l10n_br_fiscal.document.line"].inject_fiscal_fields(arch)

for tax_totals_node in arch.xpath(
"//field[@name='tax_totals'][@widget='account-tax-totals-field']"
):
tax_totals_node.set("attrs", "{'invisible': True}")

if view_type == "form" and (
self.env.user.has_group("l10n_br_account.group_line_fiscal_detail")
or self.env.context.get("force_line_fiscal_detail")
):
for sub_tree_node in arch.xpath("//field[@name='invoice_line_ids']/list"):
sub_tree_node.attrib["editable"] = ""
if self.env.user.has_group(
"l10n_br_account.group_line_fiscal_detail"
) or self.env.context.get("force_line_fiscal_detail"):
for sub_tree_node in arch.xpath(
"//field[@name='invoice_line_ids']/list"
):
sub_tree_node.attrib["editable"] = ""
elif "web_list_record_popup.mixin" in self.env:
arch = self.env["web_list_record_popup.mixin"]._inject_popup_buttons(
arch,
self._popup_button_xpaths,
)

return arch, view

Expand Down
18 changes: 1 addition & 17 deletions l10n_br_account/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@
<xpath
expr="//field[@name='invoice_line_ids']/list/field[@name='product_id']"
position="before"
>
<!--widget name="line_view_popup_button" TODO make it work in l10n_br_fiscal
/-->
</xpath>
/>
<xpath
expr="//field[@name='invoice_line_ids']/list/field[@name='tax_ids']"
position="replace"
Expand Down Expand Up @@ -237,19 +234,6 @@
}
</attribute>
</xpath>
<!--xpath
TODO MIGRATE see https://github.com/OCA/l10n-brazil/pull/3037
expr="//field[@name='line_ids']/tree/field[@name='price_total']"
position="attributes"
>
<attribute name="force_save">1</attribute>
</xpath-->
<!--xpath
expr="//field[@name='line_ids']/tree/field[@name='price_subtotal']"
position="attributes"
>
<attribute name="force_save">1</attribute>
</xpath-->
<xpath
expr="//field[@name='line_ids']/list/field[@name='tax_ids']"
position="replace"
Expand Down
5 changes: 0 additions & 5 deletions l10n_br_fiscal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@
# Menus
"views/l10n_br_fiscal_menu.xml",
],
"assets": {
"web.assets_backend": [
# "l10n_br_fiscal/static/src/js/list_renderer_with_button.esm.js",
],
},
"demo": [
"demo/city_taxation_code_demo.xml",
"demo/company_demo.xml",
Expand Down
38 changes: 0 additions & 38 deletions l10n_br_fiscal/static/src/js/list_renderer_with_button.esm.js

This file was deleted.

2 changes: 1 addition & 1 deletion l10n_br_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"maintainers": ["renatonlima", "rvalyi"],
"website": "https://github.com/OCA/l10n-brazil",
"version": "18.0.1.0.0",
"depends": ["purchase", "l10n_br_account"],
"depends": ["purchase", "l10n_br_account", "web_list_record_popup"],
"data": [
# Security
"security/ir.model.access.csv",
Expand Down
24 changes: 15 additions & 9 deletions l10n_br_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class PurchaseOrder(models.Model):
_name = "purchase.order"
_inherit = [_name, "l10n_br_fiscal.document.mixin"]

_popup_button_xpaths = [
("//field[@name='order_line']/list/field[@name='product_id']", "before"),
]

@api.model
def _default_fiscal_operation(self):
return self.env.company.purchase_fiscal_operation_id
Expand Down Expand Up @@ -53,16 +57,18 @@ def _get_view(self, view_id=None, view_type="form", **options):
arch, view = super()._get_view(view_id, view_type, **options)
if self.env.company.country_id.code != "BR":
return arch, view
if view_type == "form" and self.env.company.country_id.code == "BR":
if view_type == "form":
arch = self.env["purchase.order.line"].inject_fiscal_fields(arch)

if view_type == "form" and (
self.env.user.has_group("l10n_br_purchase.group_line_fiscal_detail")
or self.env.context.get("force_line_fiscal_detail")
):
for sub_tree_node in arch.xpath("//field[@name='order_line']/list"):
sub_tree_node.attrib["editable"] = ""

if self.env.user.has_group(
"l10n_br_purchase.group_line_fiscal_detail"
) or self.env.context.get("force_line_fiscal_detail"):
for sub_tree_node in arch.xpath("//field[@name='order_line']/list"):
sub_tree_node.attrib["editable"] = ""
elif "web_list_record_popup.mixin" in self.env:
arch = self.env["web_list_record_popup.mixin"]._inject_popup_buttons(
arch,
self._popup_button_xpaths,
)
return arch, view

@api.onchange("fiscal_operation_id")
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-brazil",
"version": "18.0.1.0.1",
"depends": ["sale_management", "l10n_br_account"],
"depends": ["sale_management", "l10n_br_account", "web_list_record_popup"],
"data": [
# Data
"data/company.xml",
Expand Down
34 changes: 19 additions & 15 deletions l10n_br_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class SaleOrder(models.Model):
_name = "sale.order"
_inherit = [_name, "l10n_br_fiscal.document.mixin"]

_popup_button_xpaths = [
("//field[@name='order_line']/list/field[@name='product_id']", "before"),
]

@api.model
def _default_fiscal_operation(self):
return self.env.company.sale_fiscal_operation_id
Expand Down Expand Up @@ -68,20 +72,18 @@ def _get_view(self, view_id=None, view_type="form", **options):
arch, view = super()._get_view(view_id, view_type, **options)
if self.env.company.country_id.code != "BR":
return arch, view
if view_type == "form" and self.env.company.country_id.code == "BR":
if view_type == "form":
arch = self.env["sale.order.line"].inject_fiscal_fields(arch)
for tax_totals_node in arch.xpath(
"//field[@name='tax_totals'][@widget='account-tax-totals-field']"
):
tax_totals_node.set("invisible", "1")

if view_type == "form" and (
self.env.user.has_group("l10n_br_sale.group_line_fiscal_detail")
or self.env.context.get("force_line_fiscal_detail_edition")
):
for sub_tree_node in arch.xpath("//field[@name='order_line']/tree"):
sub_tree_node.attrib["editable"] = ""

if self.env.user.has_group(
"l10n_br_sale.group_line_fiscal_detail"
) or self.env.context.get("force_line_fiscal_detail_edition"):
for sub_tree_node in arch.xpath("//field[@name='order_line']/tree"):
sub_tree_node.attrib["editable"] = ""
elif "web_list_record_popup.mixin" in self.env:
arch = self.env["web_list_record_popup.mixin"]._inject_popup_buttons(
arch,
self._popup_button_xpaths,
)
return arch, view

@api.onchange("fiscal_operation_id")
Expand All @@ -108,8 +110,10 @@ def _get_invoiceable_lines(self, final=False):
document_type_id = self._context.get("document_type_id")
lines_with_fo_line = lines.filtered(lambda ln: ln.fiscal_operation_line_id)
lines_doc_type = lines_with_fo_line.filtered(
lambda ln: ln.fiscal_operation_line_id.get_document_type(ln.company_id).id
== document_type_id
lambda ln: (
ln.fiscal_operation_line_id.get_document_type(ln.company_id).id
== document_type_id
)
)
other_lines = lines.filtered(lambda ln: ln.is_downpayment or ln.display_type)
lines_doc_type |= other_lines
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nfelib
Setuptools<81
signxml==3.2.2
xmldiff
odoo-addon-web_list_record_popup @ git+https://github.com/OCA/web.git@refs/pull/3522/head#subdirectory=web_list_record_popup
Loading