diff --git a/l10n_br_account/models/account_move.py b/l10n_br_account/models/account_move.py index 157c4e34be95..68849ee00a6d 100644 --- a/l10n_br_account/models/account_move.py +++ b/l10n_br_account/models/account_move.py @@ -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?", @@ -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 diff --git a/l10n_br_account/views/account_move_view.xml b/l10n_br_account/views/account_move_view.xml index 6da04419936f..e841921e69de 100644 --- a/l10n_br_account/views/account_move_view.xml +++ b/l10n_br_account/views/account_move_view.xml @@ -154,10 +154,7 @@ - - + /> - - -// License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). - -/* eslint-disable sort-imports */ - -import {onWillStart} from "@odoo/owl"; -import {patch} from "@web/core/utils/patch"; -import {ListRenderer} from "@web/views/list/list_renderer"; -import {ViewButton} from "@web/views/view_button/view_button"; - -patch(ViewButton.prototype, "l10n_br_fiscal.ViewButton", { - onClick() { - if (this.props.className && this.props.className.includes("edit-line-popup")) { - if (this.props.record) { - this.env.bus.trigger("OPEN_LINE_IN_POPUP", { - record: this.props.record, - }); - } - return; - } - this._super.apply(this, arguments); - }, -}); - -patch(ListRenderer.prototype, "l10n_br_fiscal.ListRenderer", { - setup() { - this._super.apply(this, arguments); - - onWillStart(() => { - this.env.bus.on("OPEN_LINE_IN_POPUP", this, ({record}) => { - if (this.props.list.records.includes(record)) { - this.props.openRecord(record); - } - }); - }); - }, -}); diff --git a/l10n_br_purchase/__manifest__.py b/l10n_br_purchase/__manifest__.py index de16690a3066..45d9dc3e2d58 100644 --- a/l10n_br_purchase/__manifest__.py +++ b/l10n_br_purchase/__manifest__.py @@ -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", diff --git a/l10n_br_purchase/models/purchase_order.py b/l10n_br_purchase/models/purchase_order.py index a6c54de2db0d..f6348eadbdd8 100644 --- a/l10n_br_purchase/models/purchase_order.py +++ b/l10n_br_purchase/models/purchase_order.py @@ -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 @@ -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") diff --git a/l10n_br_sale/__manifest__.py b/l10n_br_sale/__manifest__.py index 81cf76c16f16..f5ca100000ff 100644 --- a/l10n_br_sale/__manifest__.py +++ b/l10n_br_sale/__manifest__.py @@ -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", diff --git a/l10n_br_sale/models/sale_order.py b/l10n_br_sale/models/sale_order.py index 6c014ebf14fd..a2266b02bb26 100644 --- a/l10n_br_sale/models/sale_order.py +++ b/l10n_br_sale/models/sale_order.py @@ -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 @@ -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") @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index fece29375730..47d1327afc18 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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