Skip to content

Commit

Permalink
[FIX] l10n_ar_ux: monkey patch fiscal_position post_load
Browse files Browse the repository at this point in the history
Task: 34656
  • Loading branch information
mem-adhoc committed Mar 6, 2024
1 parent 4309d8c commit 1010a33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
16 changes: 14 additions & 2 deletions l10n_ar_ux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
##############################################################################
from . import controllers
from . import models
from odoo import api
from . import reports
from . import wizards
from .hooks import post_init_hook

from odoo.addons.l10n_latam_invoice_document.models.account_move import AccountMove
from odoo.addons.l10n_ar.models.account_fiscal_position import AccountFiscalPosition
from odoo.exceptions import UserError


def monkey_patch_inverse_l10n_latam_document_number():
def monkey_patches():
# monkey patch
orginal_method = AccountMove._inverse_l10n_latam_document_number

Expand Down Expand Up @@ -41,3 +42,14 @@ def _inverse_l10n_latam_document_number(self):
' the POS number if there is not posted (or posted before) invoices'))

AccountMove._inverse_l10n_latam_document_number = _inverse_l10n_latam_document_number

# monkey patch
@api.model
def _get_fiscal_position(self, partner, delivery=None):
if self.env.company.country_id.code == "AR":
self = self.with_context(
company_code='AR',
l10n_ar_afip_responsibility_type_id=partner.l10n_ar_afip_responsibility_type_id.id)
return super(AccountFiscalPosition, self)._get_fiscal_position(partner, delivery=delivery)

AccountFiscalPosition._get_fiscal_position = _get_fiscal_position
2 changes: 1 addition & 1 deletion l10n_ar_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
'auto_install': True,
'application': False,
'post_init_hook': 'post_init_hook',
'post_load': 'monkey_patch_inverse_l10n_latam_document_number',
'post_load': 'monkey_patches',
}
15 changes: 0 additions & 15 deletions l10n_ar_ux/models/account_fiscal_position.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, api
from odoo.addons.l10n_ar.models.account_fiscal_position import AccountFiscalPosition


@api.model
def _get_fiscal_position(self, partner, delivery=None):
company = self.env.company
if company.country_id.code == "AR":
self = self.with_context(
company_code='AR',
l10n_ar_afip_responsibility_type_id=partner.l10n_ar_afip_responsibility_type_id.id)
return super(AccountFiscalPosition, self)._get_fiscal_position(partner, delivery=delivery)


AccountFiscalPosition._get_fiscal_position = _get_fiscal_position


class AccountFiscalPositionMp(models.Model):

Expand Down

0 comments on commit 1010a33

Please sign in to comment.