Skip to content

Commit

Permalink
[IMP] account_ux: ADD Improvements and corrections on account_ux
Browse files Browse the repository at this point in the history
  • Loading branch information
rov-adhoc authored and jjscarafia committed Oct 22, 2024
1 parent 871c89a commit d902584
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion account_ux/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AccountAccount(models.Model):

@api.constrains('currency_id')
def check_currency(self):
if len(self.company_ids) == 1:
if len(self.mapped('company_ids.currency_id')) == 1:
for rec in self.filtered(lambda x: x.currency_id == x.company_ids.currency_id):
raise ValidationError(_(
'Solo puede utilizar una moneda secundaria distinta a la '
Expand Down
24 changes: 12 additions & 12 deletions account_ux/reports/invoice_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields

from odoo.tools import SQL

class AccountInvoiceReport(models.Model):

Expand All @@ -27,17 +27,17 @@ class AccountInvoiceReport(models.Model):
_depends = {'account.move.line': ['price_unit', 'discount']}

def _select(self):
return super()._select() + """,
line.price_unit,
line.id as line_id,
move.currency_id as invoice_currency_id,
line.discount,
line.price_unit * line.quantity * line.discount/100 *
(CASE WHEN move
.move_type IN ('in_refund','out_refund','in_receipt') THEN -1 ELSE 1 END) as discount_amount,
-line.balance * (line.price_total / NULLIF(line.price_subtotal, 0.0)) AS total_cc,
line.price_subtotal * (CASE WHEN move.move_type IN ('in_refund', 'out_invoice') THEN 1 ELSE -1 END) as price_subtotal_ic
"""
query = SQL("""
, line.price_unit
, line.id as line_id
, move.currency_id as invoice_currency_id
, line.discount
, line.price_unit * line.quantity * line.discount / 100 *
(CASE WHEN move.move_type IN ('in_refund', 'out_refund', 'in_receipt') THEN -1 ELSE 1 END) as discount_amount
, -line.balance * (line.price_total / NULLIF(line.price_subtotal, 0.0)) AS total_cc
, line.price_subtotal * (CASE WHEN move.move_type IN ('in_refund', 'out_invoice') THEN 1 ELSE -1 END) as price_subtotal_ic
""")
return SQL("%s %s", super()._select(), query)

def _group_by(self):
return super()._group_by() + ", move.invoice_currency_id"

0 comments on commit d902584

Please sign in to comment.