Skip to content

Commit

Permalink
[FIX] account_withholding: compute tax_repartition_line_id when accou…
Browse files Browse the repository at this point in the history
…nt payment group is posted

Ticket: 62171
  • Loading branch information
pablohmontenegro committed Jun 5, 2023
1 parent 45b6f78 commit 8d0e6da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion account_withholding/__manifest__.py
Expand Up @@ -34,5 +34,5 @@
'installable': True,
'name': 'Withholdings on Payments',
'test': [],
'version': "16.0.1.1.0",
'version': "16.0.1.2.0",
}
15 changes: 15 additions & 0 deletions account_withholding/migrations/16.0.1.2.0/post-migration.py
@@ -0,0 +1,15 @@
from openupgradelib import openupgrade
import logging
logger = logging.getLogger(__name__)


@openupgrade.migrate()
def migrate(env, version):
withholdings = env['account.payment'].search([]).filtered(lambda x: x.tax_withholding_id and x.state == 'posted')
for withholding in withholdings:
liquidity_lines, counterpart_lines, writeoff_lines = withholding._seek_for_lines()
if not liquidity_lines.tax_repartition_line_id or not liquidity_lines.tax_line_id:
rep_line = withholding._get_withholding_repartition_line()
liquidity_lines.tax_repartition_line_id = rep_line
liquidity_lines.tax_line_id = rep_line.tax_id
logger.info('Se computaron campos tax_repartition_line_id y tax_line_id en líneas de retenciones ya publicadas')
6 changes: 2 additions & 4 deletions account_withholding/models/account_payment.py
Expand Up @@ -64,10 +64,8 @@ def action_post(self):
for withholding in withholdings:
liquidity_lines, counterpart_lines, writeoff_lines = withholding._seek_for_lines()
rep_line = withholding._get_withholding_repartition_line()
liquidity_lines._write({
'tax_repartition_line_id': rep_line.id,
'tax_line_id': rep_line.tax_id.id,
})
liquidity_lines.tax_repartition_line_id = rep_line
liquidity_lines.tax_line_id = rep_line.tax_id
return res

def action_draft(self):
Expand Down

0 comments on commit 8d0e6da

Please sign in to comment.