Skip to content

Commit

Permalink
Add journal_diem field for diem-specific accounting
Browse files Browse the repository at this point in the history
Introduced a new "journal_diem_id" field and its defaulting mechanism to handle diem-related journal entries separately. Updated views and logic to ensure accurate management of accounting processes involving diem journals. Adjusted related code to replace existing journal references with the new field.
  • Loading branch information
dhongu committed Jan 6, 2025
1 parent 600d7ea commit 8bc1645
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deltatech_expenses/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 18 additions & 4 deletions deltatech_expenses/models/deltatech_expenses_deduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<page string="Other information">
<group>
<field name="journal_id" widget="selection" />
<!-- <field name="journal_payment_id" widget="selection" string="Payment" />-->
<field name="journal_diem_id" widget="selection" />
<field name="company_id" groups="base.group_multi_company" />
<field name="currency_id" invisible="1" />
</group>
Expand Down

0 comments on commit 8bc1645

Please sign in to comment.