Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 320 additions & 0 deletions .github/copilot-instructions.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion account_background_post/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Account Background Post",
"version": "18.0.1.0.0",
"version": "18.0.1.1.0",
"author": "ADHOC SA",
"depends": [
"account",
Expand Down
12 changes: 7 additions & 5 deletions account_background_post/wizards/validate_account_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
</field>

<button name="validate_move" position="before">
<button string="Post in Background" name="action_background_post" type="object" default_focus="1" class="btn-primary" data-hotkey="a" help="With this, all the invoices selected to be validated will be marked and they will be validated one by one. If an error is found when validating any invoice, the automatic validation of the same will be unmarked and it will be notified via messaging"/>
<button string="Post in Background" name="action_background_post" type="object" default_focus="1" class="btn-primary" data-hotkey="a" help="With this, all the invoices selected to be validated will be marked and they will be validated one by one. If an error is found when validating any invoice, the automatic validation of the same will be unmarked and it will be notified via messaging"
invisible="abnormal_amount_partner_ids"/>
<button string="Confirm" name="validate_move" type="object"
default_focus="1" class="btn-primary" data-hotkey="q" context="{'validate_analytic': True}"
confirm="Only use this option to post a small batch of invoices" invisible="force_background"
/>
</button>

<button name="validate_move" position="attributes">
<attribute name="default_focus"/>
<attribute name="class"/>
<attribute name="confirm">Only use this option to post a small batch of invoices</attribute>
<attribute name="invisible">force_background</attribute>
<attribute name="invisible">not force_background</attribute>
</button>

</field>
Expand Down
2 changes: 1 addition & 1 deletion account_invoice_tax/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Account Invoice Tax",
"version": "18.0.1.1.0",
"version": "18.0.1.0.0",
"author": "ADHOC SA",
"category": "Localization",
"depends": [
Expand Down
27 changes: 13 additions & 14 deletions account_invoice_tax/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
# Juan José Scarafía <scarafia.juanjose@gmail.com>, 2024
# Rocio Vega, 2025
# Camila Vives, 2025
# Gonzalo, 2025
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-07-22 12:05+0000\n"
"POT-Creation-Date: 2025-10-09 14:37+0000\n"
"PO-Revision-Date: 2024-12-23 18:31+0000\n"
"Last-Translator: Gonzalo, 2025\n"
"Last-Translator: Camila Vives, 2025\n"
"Language-Team: Spanish (https://app.transifex.com/adhoc/teams/46451/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -52,18 +51,13 @@ msgstr "Agregar/Actualizar Impuesto Fijo"
msgid "Amount"
msgstr "Importe"

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__amount_company_currency
msgid "Amount Company Currency"
msgstr "Importe moneda de la compañía"

#. module: account_invoice_tax
#: model_terms:ir.ui.view,arch_db:account_invoice_tax.view_account_invoice_tax
msgid "Cancel"
msgstr "Cancelar"

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax__company_id
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__company_id
msgid "Company"
msgstr "Empresa"

Expand All @@ -79,6 +73,11 @@ msgstr "Creado por"
msgid "Created on"
msgstr "Creado el"

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__currency_id
msgid "Currency"
msgstr ""

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax__display_name
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__display_name
Expand All @@ -92,6 +91,11 @@ msgstr "Nombre para mostrar"
msgid "Edit tax lines"
msgstr "Editar lineas de impuesto"

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__existing_tax_ids
msgid "Existing Tax"
msgstr ""

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax__id
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__id
Expand All @@ -103,11 +107,6 @@ msgstr "ID (identificación)"
msgid "Invoice Tax"
msgstr "Impuesto de Factura"

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax__is_in_company_currency
msgid "Is In Company Currency"
msgstr "Es en moneda de la compañía"

#. module: account_invoice_tax
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax__write_uid
#: model:ir.model.fields,field_description:account_invoice_tax.field_account_invoice_tax_line__write_uid
Expand Down
95 changes: 38 additions & 57 deletions account_invoice_tax/wizards/account_invoice_tax.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import Command, _, api, fields, models
from odoo.exceptions import UserError


class AccountInvoiceTax(models.TransientModel):
_name = "account.invoice.tax"
_description = "Account Invoice Tax"

move_id = fields.Many2one("account.move", required=True)
company_id = fields.Many2one(related="move_id.company_id")
tax_line_ids = fields.One2many("account.invoice.tax_line", "invoice_tax_id")

is_in_company_currency = fields.Boolean(compute="_compute_is_in_company_currency")

@api.model
def default_get(self, fields):
res = super().default_get(fields)
Expand All @@ -21,10 +19,14 @@ def default_get(self, fields):
else self.env["account.move"]
)
res["move_id"] = move_ids[0].id if move_ids else False
if move_ids[0].move_type == "in_invoice":
sign = 1
else: # For refund
sign = -1
lines = []
for line in move_ids[0].line_ids.filtered(lambda x: x.tax_line_id):
lines.append(
Command.create({"tax_id": line.tax_line_id.id, "amount": line.amount_currency, "new_tax": False})
Command.create({"tax_id": line.tax_line_id.id, "amount": line.amount_currency * sign, "new_tax": False})
)
res["tax_line_ids"] = lines

Expand Down Expand Up @@ -63,6 +65,11 @@ def action_update_tax(self):

# set amount in the new created tax line. En este momento si queda balanceado y se ajusta la linea AP/AR
container = {"records": move}

if move.move_type == "in_invoice":
sign = 1
else: # For refund
sign = -1
with move._check_balanced(container):
with move._sync_dynamic_lines(container):
# restauramos todos los valores de impuestos fixed que se habrian recomputado
Expand All @@ -75,7 +82,7 @@ def action_update_tax(self):
for tax_line_id in self.tax_line_ids:
# seteamos valor al impuesto segun lo que puso en el wizard
line_with_tax = move.line_ids.filtered(lambda x: x.tax_line_id == tax_line_id.tax_id)
line_with_tax.write(tax_line_id._get_amount_updated_values())
line_with_tax.write({"amount_currency": tax_line_id.amount * sign})

def add_tax_and_new(self):
self.add_tax()
Expand All @@ -88,65 +95,39 @@ def add_tax_and_new(self):
"context": self._context,
}

@api.depends("move_id")
def _compute_is_in_company_currency(self):
self.is_in_company_currency = self.move_id.currency_id == self.move_id.company_currency_id
@api.constrains("tax_line_ids")
@api.onchange("tax_line_ids")
def check_analytic(self):
taxes = self.tax_line_ids.filtered("tax_id.analytic").mapped("tax_id")
if taxes:
raise UserError(
'No puede usar este asistente ya que algún impuesto tiene establecido "Incluir en el costo analítico?".\nImpuestos: %s'
% (", ".join(taxes.mapped(lambda x: "%s (%s)" % (x.name, x.id))))
)


class AccountInvoiceTaxLine(models.TransientModel):
_name = "account.invoice.tax_line"
_description = "Account Invoice Tax line"
_check_company_auto = True
_check_company_domain = models.check_companies_domain_parent_of

invoice_tax_id = fields.Many2one("account.invoice.tax")
tax_id = fields.Many2one("account.tax", required=True)
amount = fields.Float()
amount_company_currency = fields.Float(
compute="_compute_amount_company_currency",
readonly=False,
store=True,
tax_id = fields.Many2one(
"account.tax",
required=True,
check_company=True,
domain="[('type_tax_use', '=', 'purchase'), ('id', 'not in', existing_tax_ids)]",
)
company_id = fields.Many2one(related="invoice_tax_id.move_id.company_id")
currency_id = fields.Many2one(related="invoice_tax_id.move_id.currency_id")
existing_tax_ids = fields.Many2many("account.tax", compute="_compute_existing_taxes")
amount = fields.Monetary(
currency_field="currency_id",
)

new_tax = fields.Boolean(default=True)

def _get_amount_updated_values(self):
debit = credit = debit_cc = credit_cc = 0
if self.amount and not self.amount_company_currency:
self._compute_amount_company_currency()
if self.invoice_tax_id.move_id.move_type == "in_invoice":
if self.amount > 0:
debit = self.amount
debit_cc = self.amount_company_currency
elif self.amount < 0:
credit = -self.amount
credit_cc = -self.amount_company_currency
else: # For refund
if self.amount > 0:
credit = self.amount
credit_cc = self.amount_company_currency
elif self.amount < 0:
debit = -self.amount
debit_cc = -self.amount_company_currency

# If multi currency enable
move_currency = self.invoice_tax_id.move_id.currency_id
company_currency = self.invoice_tax_id.move_id.company_currency_id
not_company_currency = move_currency and move_currency != company_currency

values = {
"debit": debit_cc if not_company_currency else debit,
"credit": credit_cc if not_company_currency else credit,
"balance": (self.amount_company_currency if not_company_currency else self.amount) * (1 if debit else -1),
}

if not_company_currency and self.amount:
values["amount_currency"] = self.amount

return values

def _compute_amount_company_currency(self):
for line in self:
taxes = line.invoice_tax_id.move_id.tax_totals["subtotals"][0]["tax_groups"]
for tax_group in taxes:
if line.tax_id.id == tax_group["involved_tax_ids"][0]:
line.amount_company_currency = tax_group["tax_amount"]
break
@api.depends("invoice_tax_id.tax_line_ids.tax_id")
def _compute_existing_taxes(self):
for record in self:
record.existing_tax_ids = record.invoice_tax_id.tax_line_ids.mapped("tax_id")
7 changes: 4 additions & 3 deletions account_invoice_tax/wizards/account_invoice_tax_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<field name="arch" type="xml">
<form>
<group>
<field name="company_id" invisible="1"/>
<field name="move_id" invisible="1"/>
<field colspan="2" nolabel="1" name="tax_line_ids">
<list decoration-info="new_tax == True" editable="bottom">
<field name="tax_id" domain="[('type_tax_use', '=', 'purchase'), ('company_id', '=', parent.company_id)]" options="{'no_create': True, 'no_edit': True}"/>
<field name="amount_company_currency" column_invisible="parent.is_in_company_currency"/>
<field name="tax_id" options="{'no_create': True, 'no_edit': True}"/>
<field name="amount"/>
<field name="company_id" column_invisible="True"/>
<field name="currency_id" column_invisible="True"/>
<field name="new_tax" column_invisible="True"/>
<field name="existing_tax_ids" column_invisible="True"/>
</list>
</field>
</group>
Expand Down
Loading