diff --git a/deltatech_expenses/__manifest__.py b/deltatech_expenses/__manifest__.py index 2cf4ed908..1e803bf7e 100644 --- a/deltatech_expenses/__manifest__.py +++ b/deltatech_expenses/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Expenses Deduction", "summary": "Expenses Deduction & Disposition of Cashing", - "version": "17.0.2.0.3", + "version": "17.0.2.0.4", "category": "Accounting & Finance", "author": "Terrabit, Dorin Hongu", "website": "https://www.terrabit.ro", diff --git a/deltatech_expenses/models/deltatech_expenses_deduction.py b/deltatech_expenses/models/deltatech_expenses_deduction.py index 07aa3a034..176f882e7 100644 --- a/deltatech_expenses/models/deltatech_expenses_deduction.py +++ b/deltatech_expenses/models/deltatech_expenses_deduction.py @@ -26,6 +26,14 @@ def _default_journal(self): domain = [("type", "=", "cash"), ("company_id", "=", self.env.company.id)] return self.env["account.journal"].search(domain, limit=1) + @api.model + def _default_journal_diem(self): + if self._context.get("default_journal_diem_id", False): + return self.env["account.journal"].browse(self._context.get("default_journal_diem_id")) + + domain = [("type", "=", "general"), ("company_id", "=", self.env.company.id)] + return self.env["account.journal"].search(domain, limit=1) + @api.model def _default_account_diem(self): account_pool = self.env["account.account"] @@ -139,6 +147,12 @@ def _default_account_diem(self): default=_default_journal, ) + journal_diem_id = fields.Many2one( + "account.journal", + string="Diem Journal", + default=_default_journal_diem, + ) + account_diem_id = fields.Many2one( "account.account", string="Account", @@ -451,7 +465,7 @@ def validate_expenses(self): "debit": expenses.total_diem, "credit": 0.0, "account_id": expenses.account_diem_id.id, - "journal_id": expenses.journal_id.id, + "journal_id": expenses.journal_diem_id.id, "partner_id": expenses.employee_id.id, "date": expenses.date_expense, "date_maturity": expenses.date_expense, @@ -461,7 +475,7 @@ def validate_expenses(self): "debit": 0.0, "credit": expenses.total_diem, "account_id": expenses.journal_id.account_cash_advances_id.id, # 542 - "journal_id": expenses.journal_id.id, + "journal_id": expenses.journal_diem_id.id, "partner_id": expenses.employee_id.id, "date": expenses.date_expense, "date_maturity": expenses.date_expense, @@ -470,8 +484,8 @@ def validate_expenses(self): line_ids.append([0, False, move_line_cr]) move = self.env["account.move"].create( { - "name": name or "/", - "journal_id": expenses.journal_id.id, + # "name": name or "/", + "journal_id": expenses.journal_diem_id.id, "date": expenses.date_expense, "ref": name or "", "line_ids": line_ids, diff --git a/deltatech_expenses/views/deltatech_expenses_deduction_view.xml b/deltatech_expenses/views/deltatech_expenses_deduction_view.xml index 4aacb31af..a7434c1ca 100644 --- a/deltatech_expenses/views/deltatech_expenses_deduction_view.xml +++ b/deltatech_expenses/views/deltatech_expenses_deduction_view.xml @@ -186,7 +186,7 @@ - +