Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Indian - Accounting

Entity: account.move

Compute Method: _compute_l10n_in_warning

Inputs Method Outputs
indian_invoice = self.filtered(lambda m: m.country_code == 'IN' and m.move_type != 'entry')
line_filter_func = lambda line: line.display_type == 'product' and line.tax_ids and line._origin
_xmlid_to_res_id = self.env['ir.model.data']._xmlid_to_res_id
for move in indian_invoice:
            warnings = {}
            company = move.company_id
            action_name = _("Journal Item(s)")
            action_text = _("View Journal Item(s)")
            invalid_tax_lines = move.invoice_line_ids.filtered(
                lambda line: line.display_type == 'product'
                and any(tax.l10n_in_tax_type == 'tcs' for tax in line.tax_ids)
            )
            if company.l10n_in_tcs_feature and not move.commercial_partner_id.l10n_in_pan_entity_id and invalid_tax_lines:
                warnings['lower_tcs_tax'] = {
                    'message': _("As the Partner's PAN missing/invalid apply TCS at the higher rate."),
                    'action': invalid_tax_lines.with_context(tax_validation=True)._get_records_action(
                        name=action_name,
                        views=[(_xmlid_to_res_id("l10n_in.view_move_line_tree_hsn_l10n_in"), "list")],
                        domain=[('id', 'in', invalid_tax_lines.ids)],
                    ),
                    'action_text': action_text,
                }

            if move.l10n_in_is_self_invoice and any(
                line.l10n_in_gstr_section != 'purchase_b2c_rcm'
                for line in move.invoice_line_ids
                if line._origin
            ):
                warnings['invalid_self_invoice'] = {
                    'message': _(
                        "This invoice does not meet the Self Invoice conditions. "
                        "Please verify before printing.",
                    ),
                }

            if (
                company.l10n_in_gst_registration_type == 'regular'
                and company.l10n_in_hsn_code_digit
                and (filtered_lines := move.invoice_line_ids.filtered(line_filter_func))
                and (not company.l10n_in_disable_b2c_hsn_reporting
                     or move.l10n_in_gst_treatment in self._l10n_in_get_b2b_gst_treatments())
            ):
                lines = self.env['account.move.line']
                for line in filtered_lines:
                    hsn_code = line.l10n_in_hsn_code
                    if (
                        not hsn_code
                        or (
                            not re.match(r'^\d{4}$|^\d{6}$|^\d{8}$', hsn_code)
                            or len(hsn_code) < int(company.l10n_in_hsn_code_digit)
                        )
                    ):
                        lines |= line._origin

                if lines:
                    digit_suffixes = {
                        '4': _("4 digits, 6 digits or 8 digits"),
                        '6': _("6 digits or 8 digits"),
                        '8': _("8 digits")
                    }
                    msg = _(
                        "Ensure that the HSN/SAC Code consists either %s in invoice lines",
                        digit_suffixes.get(company.l10n_in_hsn_code_digit, _("Invalid HSN/SAC Code digit"))
                    )
                    warnings['invalid_hsn_code_length'] = {
                        'message': msg,
                        'action': lines._get_records_action(
                            name=action_name,
                            views=[(_xmlid_to_res_id("l10n_in.view_move_line_tree_hsn_l10n_in"), "list")],
                            domain=[('id', 'in', lines.ids)]
                        ),
                        'action_text': action_text,
                    }

            move.l10n_in_warning = warnings
(self - indian_invoice).l10n_in_warning = {}

Back to entity