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 Nov 13, 2023
1 parent 99facff commit 0d56b3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
16 changes: 16 additions & 0 deletions l10n_ar_ux/__init__.py
Expand Up @@ -4,13 +4,15 @@
##############################################################################
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():
# monkey patch
Expand Down Expand Up @@ -41,3 +43,17 @@ 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

def monkey_patch_inverse__get_fiscal_position():

@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
1 change: 1 addition & 0 deletions l10n_ar_ux/__manifest__.py
Expand Up @@ -47,4 +47,5 @@
'application': False,
'post_init_hook': 'post_init_hook',
'post_load': 'monkey_patch_inverse_l10n_latam_document_number',
'post_load': 'monkey_patch_inverse__get_fiscal_position',
}
16 changes: 0 additions & 16 deletions l10n_ar_ux/models/account_fiscal_position.py
@@ -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 0d56b3c

Please sign in to comment.