Skip to content

Commit

Permalink
Rename currency_amount to origin_currency_amount and currency_code to…
Browse files Browse the repository at this point in the history
… origin_currency_code. Always write data in column, not just when it is different from company currency.

Add start_date and end_date when OCA module account_invoice_start_end_dates is installed.
  • Loading branch information
alexis-via committed May 7, 2024
1 parent 22eaa1a commit 3bf4b66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
12 changes: 10 additions & 2 deletions account_move_export/models/account_move_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,17 @@ def _prepare_columns(self):
"entry_ref": {"width": 20, "style": "char", "sequence": 100},
"reconcile_ref": {"width": 10, "style": "char", "sequence": 110},
"due_date": {"width": 10, "style": "date", "sequence": 120},
"currency_amount": {"width": 12, "style": "float", "sequence": 130},
"currency_code": {"width": 12, "style": "char", "sequence": 140},
"origin_currency_amount": {"width": 12, "style": "float", "sequence": 130},
"origin_currency_code": {"width": 12, "style": "char", "sequence": 140},
}
line_obj = self.env["account.move.line"]
if hasattr(line_obj, "start_date") and hasattr(line_obj, "end_date"):
cols.update(
{
"start_date": {"width": 10, "style": "date", "sequence": 150},
"end_date": {"width": 10, "style": "date", "sequence": 160},
}
)
return cols

def _csv_format_amount(self, amount, export_options):
Expand Down
17 changes: 10 additions & 7 deletions account_move_export/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AccountMoveLine(models.Model):

def _prepare_account_move_export_line(self, export_options):
self.ensure_one()
assert self.display_type not in ("line_section", "line_note")
move = self.move_id
partner_code = None
if self.partner_id and (
Expand All @@ -22,9 +23,6 @@ def _prepare_account_move_export_line(self, export_options):
partner_code = self.partner_id._prepare_account_move_export_partner_code(
export_options
)
secondary_currency = (
self.currency_id.id != export_options["company_currency_id"]
)
res = {
"type": "G",
"entry_number": move.name,
Expand All @@ -38,9 +36,14 @@ def _prepare_account_move_export_line(self, export_options):
"entry_ref": move.ref or None,
"reconcile_ref": self.full_reconcile_id.name or None,
"due_date": self.date_maturity or None,
"currency_amount": secondary_currency
and self.currency_id.round(self.amount_currency)
or None,
"currency_code": secondary_currency and self.currency_id.name or None,
"origin_currency_amount": self.currency_id.round(self.amount_currency),
"origin_currency_code": self.currency_id.name,
}
if hasattr(self, "start_date") and hasattr(self, "end_date"):
res.update(
{
"start_date": self.start_date or None,
"end_date": self.end_date or None,
}
)
return res

0 comments on commit 3bf4b66

Please sign in to comment.