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 Dec 4, 2023
1 parent 4309d8c commit c81eb11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
20 changes: 19 additions & 1 deletion l10n_ar_ux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
##############################################################################
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.exceptions import UserError

from odoo.addons.l10n_ar.models.account_fiscal_position import AccountFiscalPosition

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 +43,19 @@ 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

orginal_method_fiscal_position = AccountFiscalPosition._get_fiscal_position

#monkey patch
@api.model
def _get_fiscal_position(self, partner, delivery=None):
orginal_method_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
3 changes: 2 additions & 1 deletion l10n_ar_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
'auto_install': True,
'application': False,
'post_init_hook': 'post_init_hook',
'post_load': 'monkey_patch_inverse_l10n_latam_document_number',
'post_load': 'monkey_patches',
# 'post_load': 'monkey_patch_inverse__get_fiscal_position',
}
16 changes: 0 additions & 16 deletions l10n_ar_ux/models/account_fiscal_position.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
# 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):

_inherit = 'account.fiscal.position'

@api.model
Expand Down

0 comments on commit c81eb11

Please sign in to comment.