Enterprise PR - odoo/enterprise#23980 Upgrade PR - odoo/enterprise#3206 - UI improvements/changes - Taxes Before this commit, in case taxes were defined on expense, the tax amount was added on top of a product price. For example, in case product price was 100$, and tax - 15%, then expense.total_amount would be 115$. Now, tax amount is included in expense.total_amount. To accommodate this change, we set following domain - ('price_include', '=', True) on tax_ids on expense. For the same example, expense.total_amount would be 100$, tax amount would be 13.04$ and untaxed amount - 86.96$. But, tax amount can be set for non-zero expenses (in case expense.product_id.standard_price !=0). For the above example, one could set tax amount to 15$. As a result untaxed amount will be 85$ and total amount - 1OO$. - Journal entry Previously, in case journal entry was reset to draft, canceled, reversed - it changed the state of the linked expense report. Now, actions done on accounting by accountant does not impact expense reports. task - 2687999 closes odoo/odoo#81904 Related: odoo/upgrade#3206 Signed-off-by: Kevin Baptiste <kba@odoo.com>
28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class AccountMoveLine(models.Model):
|
|
_inherit = "account.move.line"
|
|
|
|
expense_id = fields.Many2one('hr.expense', string='Expense', copy=False, help="Expense where the move line come from")
|
|
|
|
def reconcile(self):
|
|
# OVERRIDE
|
|
not_paid_expenses = self.expense_id.filtered(lambda expense: expense.state != 'done')
|
|
res = super().reconcile()
|
|
# Do not update expense or expense sheet states when reversing journal entries
|
|
not_paid_expense_sheets = not_paid_expenses.sheet_id.filtered(lambda sheet: sheet.account_move_id.payment_state != 'reversed')
|
|
paid_expenses = not_paid_expenses.filtered(lambda expense: expense.currency_id.is_zero(expense.amount_residual))
|
|
paid_expenses.write({'state': 'done'})
|
|
not_paid_expense_sheets.filtered(lambda sheet: all(expense.state == 'done' for expense in sheet.expense_line_ids)).set_to_paid()
|
|
return res
|
|
|
|
def _get_attachment_domains(self):
|
|
attachment_domains = super(AccountMoveLine, self)._get_attachment_domains()
|
|
if self.expense_id:
|
|
attachment_domains.append([('res_model', '=', 'hr.expense'), ('res_id', '=', self.expense_id.id)])
|
|
return attachment_domains
|