odoo-addon-account-financial-report 17.0.1.6.12.2__py3-none-any.whl → 17.0.1.7.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of odoo-addon-account-financial-report might be problematic. Click here for more details.

Files changed (33) hide show
  1. odoo/addons/account_financial_report/README.rst +1 -1
  2. odoo/addons/account_financial_report/__manifest__.py +1 -1
  3. odoo/addons/account_financial_report/i18n/account_financial_report.pot +16 -0
  4. odoo/addons/account_financial_report/i18n/ar.po +15 -0
  5. odoo/addons/account_financial_report/i18n/ca.po +15 -0
  6. odoo/addons/account_financial_report/i18n/de.po +15 -0
  7. odoo/addons/account_financial_report/i18n/es.po +16 -1
  8. odoo/addons/account_financial_report/i18n/es_AR.po +15 -0
  9. odoo/addons/account_financial_report/i18n/es_MX.po +15 -0
  10. odoo/addons/account_financial_report/i18n/fr.po +15 -0
  11. odoo/addons/account_financial_report/i18n/fr_CH.po +15 -0
  12. odoo/addons/account_financial_report/i18n/hr.po +15 -0
  13. odoo/addons/account_financial_report/i18n/hr_HR.po +15 -0
  14. odoo/addons/account_financial_report/i18n/it.po +15 -0
  15. odoo/addons/account_financial_report/i18n/ja.po +15 -0
  16. odoo/addons/account_financial_report/i18n/nl.po +15 -0
  17. odoo/addons/account_financial_report/i18n/nl_NL.po +15 -0
  18. odoo/addons/account_financial_report/i18n/pt.po +15 -0
  19. odoo/addons/account_financial_report/i18n/pt_BR.po +15 -0
  20. odoo/addons/account_financial_report/i18n/ro.po +15 -0
  21. odoo/addons/account_financial_report/i18n/sv.po +15 -0
  22. odoo/addons/account_financial_report/i18n/tr.po +15 -0
  23. odoo/addons/account_financial_report/report/open_items.py +29 -25
  24. odoo/addons/account_financial_report/report/open_items_xlsx.py +150 -17
  25. odoo/addons/account_financial_report/report/templates/open_items.xml +183 -56
  26. odoo/addons/account_financial_report/static/description/index.html +1 -1
  27. odoo/addons/account_financial_report/tests/test_open_items.py +30 -0
  28. odoo/addons/account_financial_report/wizard/open_items_wizard.py +18 -0
  29. odoo/addons/account_financial_report/wizard/open_items_wizard_view.xml +1 -0
  30. {odoo_addon_account_financial_report-17.0.1.6.12.2.dist-info → odoo_addon_account_financial_report-17.0.1.7.0.1.dist-info}/METADATA +2 -2
  31. {odoo_addon_account_financial_report-17.0.1.6.12.2.dist-info → odoo_addon_account_financial_report-17.0.1.7.0.1.dist-info}/RECORD +33 -33
  32. {odoo_addon_account_financial_report-17.0.1.6.12.2.dist-info → odoo_addon_account_financial_report-17.0.1.7.0.1.dist-info}/WHEEL +0 -0
  33. {odoo_addon_account_financial_report-17.0.1.6.12.2.dist-info → odoo_addon_account_financial_report-17.0.1.7.0.1.dist-info}/top_level.txt +0 -0
@@ -962,6 +962,7 @@ msgstr "Groepeer boekingen per"
962
962
 
963
963
  #. module: account_financial_report
964
964
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
965
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
965
966
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
966
967
  msgid "Grouped By"
967
968
  msgstr "Gegroepeerd op"
@@ -1189,11 +1190,19 @@ msgstr "Regel"
1189
1190
  #. odoo-python
1190
1191
  #: code:addons/account_financial_report/report/general_ledger.py:0
1191
1192
  #: code:addons/account_financial_report/report/open_items.py:0
1193
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1192
1194
  #: code:addons/account_financial_report/report/trial_balance.py:0
1193
1195
  #, python-format
1194
1196
  msgid "Missing Partner"
1195
1197
  msgstr ""
1196
1198
 
1199
+ #. module: account_financial_report
1200
+ #. odoo-python
1201
+ #: code:addons/account_financial_report/report/open_items.py:0
1202
+ #, python-format
1203
+ msgid "Missing Salesperson"
1204
+ msgstr ""
1205
+
1197
1206
  #. module: account_financial_report
1198
1207
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1199
1208
  msgid "Model to set interval lines for Age partner balance report"
@@ -1403,6 +1412,11 @@ msgstr ""
1403
1412
  msgid "Partner Initial balance"
1404
1413
  msgstr "Relatiebeginsaldo"
1405
1414
 
1415
+ #. module: account_financial_report
1416
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1417
+ msgid "Partner Salesperson"
1418
+ msgstr ""
1419
+
1406
1420
  #. module: account_financial_report
1407
1421
  #. odoo-python
1408
1422
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1427,6 +1441,7 @@ msgstr "Beginbalans partner"
1427
1441
 
1428
1442
  #. module: account_financial_report
1429
1443
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1444
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1430
1445
  msgid "Partners"
1431
1446
  msgstr "Partners"
1432
1447
 
@@ -956,6 +956,7 @@ msgstr ""
956
956
 
957
957
  #. module: account_financial_report
958
958
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
959
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
959
960
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
960
961
  msgid "Grouped By"
961
962
  msgstr ""
@@ -1177,11 +1178,19 @@ msgstr ""
1177
1178
  #. odoo-python
1178
1179
  #: code:addons/account_financial_report/report/general_ledger.py:0
1179
1180
  #: code:addons/account_financial_report/report/open_items.py:0
1181
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1180
1182
  #: code:addons/account_financial_report/report/trial_balance.py:0
1181
1183
  #, python-format
1182
1184
  msgid "Missing Partner"
1183
1185
  msgstr ""
1184
1186
 
1187
+ #. module: account_financial_report
1188
+ #. odoo-python
1189
+ #: code:addons/account_financial_report/report/open_items.py:0
1190
+ #, python-format
1191
+ msgid "Missing Salesperson"
1192
+ msgstr ""
1193
+
1185
1194
  #. module: account_financial_report
1186
1195
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1187
1196
  msgid "Model to set interval lines for Age partner balance report"
@@ -1389,6 +1398,11 @@ msgstr ""
1389
1398
  msgid "Partner Initial balance"
1390
1399
  msgstr ""
1391
1400
 
1401
+ #. module: account_financial_report
1402
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1403
+ msgid "Partner Salesperson"
1404
+ msgstr ""
1405
+
1392
1406
  #. module: account_financial_report
1393
1407
  #. odoo-python
1394
1408
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1413,6 +1427,7 @@ msgstr ""
1413
1427
 
1414
1428
  #. module: account_financial_report
1415
1429
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1430
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1416
1431
  msgid "Partners"
1417
1432
  msgstr ""
1418
1433
 
@@ -962,6 +962,7 @@ msgstr "Agrupar movimentos por"
962
962
 
963
963
  #. module: account_financial_report
964
964
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
965
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
965
966
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
966
967
  msgid "Grouped By"
967
968
  msgstr "Agrupar Por"
@@ -1189,11 +1190,19 @@ msgstr "Linha"
1189
1190
  #. odoo-python
1190
1191
  #: code:addons/account_financial_report/report/general_ledger.py:0
1191
1192
  #: code:addons/account_financial_report/report/open_items.py:0
1193
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1192
1194
  #: code:addons/account_financial_report/report/trial_balance.py:0
1193
1195
  #, python-format
1194
1196
  msgid "Missing Partner"
1195
1197
  msgstr "Parceiro em Falta"
1196
1198
 
1199
+ #. module: account_financial_report
1200
+ #. odoo-python
1201
+ #: code:addons/account_financial_report/report/open_items.py:0
1202
+ #, python-format
1203
+ msgid "Missing Salesperson"
1204
+ msgstr ""
1205
+
1197
1206
  #. module: account_financial_report
1198
1207
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1199
1208
  msgid "Model to set interval lines for Age partner balance report"
@@ -1406,6 +1415,11 @@ msgstr ""
1406
1415
  msgid "Partner Initial balance"
1407
1416
  msgstr "Saldo inicial de Parceiro"
1408
1417
 
1418
+ #. module: account_financial_report
1419
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1420
+ msgid "Partner Salesperson"
1421
+ msgstr ""
1422
+
1409
1423
  #. module: account_financial_report
1410
1424
  #. odoo-python
1411
1425
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1430,6 +1444,7 @@ msgstr "Saldo inicial do parceiro"
1430
1444
 
1431
1445
  #. module: account_financial_report
1432
1446
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1447
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1433
1448
  msgid "Partners"
1434
1449
  msgstr "Parceiros"
1435
1450
 
@@ -959,6 +959,7 @@ msgstr "Agrupar lan??amentos por"
959
959
 
960
960
  #. module: account_financial_report
961
961
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
962
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
962
963
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
963
964
  msgid "Grouped By"
964
965
  msgstr "Agrupado Por"
@@ -1186,11 +1187,19 @@ msgstr "Linha"
1186
1187
  #. odoo-python
1187
1188
  #: code:addons/account_financial_report/report/general_ledger.py:0
1188
1189
  #: code:addons/account_financial_report/report/open_items.py:0
1190
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1189
1191
  #: code:addons/account_financial_report/report/trial_balance.py:0
1190
1192
  #, python-format
1191
1193
  msgid "Missing Partner"
1192
1194
  msgstr ""
1193
1195
 
1196
+ #. module: account_financial_report
1197
+ #. odoo-python
1198
+ #: code:addons/account_financial_report/report/open_items.py:0
1199
+ #, python-format
1200
+ msgid "Missing Salesperson"
1201
+ msgstr ""
1202
+
1194
1203
  #. module: account_financial_report
1195
1204
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1196
1205
  msgid "Model to set interval lines for Age partner balance report"
@@ -1400,6 +1409,11 @@ msgstr ""
1400
1409
  msgid "Partner Initial balance"
1401
1410
  msgstr "Saldo inicial do parceiro"
1402
1411
 
1412
+ #. module: account_financial_report
1413
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1414
+ msgid "Partner Salesperson"
1415
+ msgstr ""
1416
+
1403
1417
  #. module: account_financial_report
1404
1418
  #. odoo-python
1405
1419
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1424,6 +1438,7 @@ msgstr "Saldo inicial do Parceiro"
1424
1438
 
1425
1439
  #. module: account_financial_report
1426
1440
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1441
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1427
1442
  msgid "Partners"
1428
1443
  msgstr "Parceiros"
1429
1444
 
@@ -959,6 +959,7 @@ msgstr "Intr??ri de grup dup??"
959
959
 
960
960
  #. module: account_financial_report
961
961
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
962
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
962
963
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
963
964
  msgid "Grouped By"
964
965
  msgstr ""
@@ -1186,11 +1187,19 @@ msgstr "Linie"
1186
1187
  #. odoo-python
1187
1188
  #: code:addons/account_financial_report/report/general_ledger.py:0
1188
1189
  #: code:addons/account_financial_report/report/open_items.py:0
1190
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1189
1191
  #: code:addons/account_financial_report/report/trial_balance.py:0
1190
1192
  #, python-format
1191
1193
  msgid "Missing Partner"
1192
1194
  msgstr ""
1193
1195
 
1196
+ #. module: account_financial_report
1197
+ #. odoo-python
1198
+ #: code:addons/account_financial_report/report/open_items.py:0
1199
+ #, python-format
1200
+ msgid "Missing Salesperson"
1201
+ msgstr ""
1202
+
1194
1203
  #. module: account_financial_report
1195
1204
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1196
1205
  msgid "Model to set interval lines for Age partner balance report"
@@ -1398,6 +1407,11 @@ msgstr ""
1398
1407
  msgid "Partner Initial balance"
1399
1408
  msgstr "Sold ini??ial partener"
1400
1409
 
1410
+ #. module: account_financial_report
1411
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1412
+ msgid "Partner Salesperson"
1413
+ msgstr ""
1414
+
1401
1415
  #. module: account_financial_report
1402
1416
  #. odoo-python
1403
1417
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1422,6 +1436,7 @@ msgstr ""
1422
1436
 
1423
1437
  #. module: account_financial_report
1424
1438
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1439
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1425
1440
  msgid "Partners"
1426
1441
  msgstr ""
1427
1442
 
@@ -967,6 +967,7 @@ msgstr "Gruppinlägg efter"
967
967
 
968
968
  #. module: account_financial_report
969
969
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
970
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
970
971
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
971
972
  msgid "Grouped By"
972
973
  msgstr "Grupperad efter"
@@ -1195,11 +1196,19 @@ msgstr "Linje"
1195
1196
  #. odoo-python
1196
1197
  #: code:addons/account_financial_report/report/general_ledger.py:0
1197
1198
  #: code:addons/account_financial_report/report/open_items.py:0
1199
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1198
1200
  #: code:addons/account_financial_report/report/trial_balance.py:0
1199
1201
  #, python-format
1200
1202
  msgid "Missing Partner"
1201
1203
  msgstr "Saknad partner"
1202
1204
 
1205
+ #. module: account_financial_report
1206
+ #. odoo-python
1207
+ #: code:addons/account_financial_report/report/open_items.py:0
1208
+ #, python-format
1209
+ msgid "Missing Salesperson"
1210
+ msgstr ""
1211
+
1203
1212
  #. module: account_financial_report
1204
1213
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1205
1214
  msgid "Model to set interval lines for Age partner balance report"
@@ -1409,6 +1418,11 @@ msgstr ""
1409
1418
  msgid "Partner Initial balance"
1410
1419
  msgstr "Kund initial balans"
1411
1420
 
1421
+ #. module: account_financial_report
1422
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1423
+ msgid "Partner Salesperson"
1424
+ msgstr ""
1425
+
1412
1426
  #. module: account_financial_report
1413
1427
  #. odoo-python
1414
1428
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1433,6 +1447,7 @@ msgstr "Partnerns initiala balans"
1433
1447
 
1434
1448
  #. module: account_financial_report
1435
1449
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1450
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1436
1451
  msgid "Partners"
1437
1452
  msgstr "Partner"
1438
1453
 
@@ -958,6 +958,7 @@ msgstr ""
958
958
 
959
959
  #. module: account_financial_report
960
960
  #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by
961
+ #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__grouped_by
961
962
  #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__grouped_by
962
963
  msgid "Grouped By"
963
964
  msgstr "Gruplanma"
@@ -1181,11 +1182,19 @@ msgstr ""
1181
1182
  #. odoo-python
1182
1183
  #: code:addons/account_financial_report/report/general_ledger.py:0
1183
1184
  #: code:addons/account_financial_report/report/open_items.py:0
1185
+ #: code:addons/account_financial_report/report/open_items_xlsx.py:0
1184
1186
  #: code:addons/account_financial_report/report/trial_balance.py:0
1185
1187
  #, python-format
1186
1188
  msgid "Missing Partner"
1187
1189
  msgstr ""
1188
1190
 
1191
+ #. module: account_financial_report
1192
+ #. odoo-python
1193
+ #: code:addons/account_financial_report/report/open_items.py:0
1194
+ #, python-format
1195
+ msgid "Missing Salesperson"
1196
+ msgstr ""
1197
+
1189
1198
  #. module: account_financial_report
1190
1199
  #: model:ir.model,name:account_financial_report.model_account_age_report_configuration_line
1191
1200
  msgid "Model to set interval lines for Age partner balance report"
@@ -1393,6 +1402,11 @@ msgstr ""
1393
1402
  msgid "Partner Initial balance"
1394
1403
  msgstr "İş Ortağı Başlangıç bakiyesi"
1395
1404
 
1405
+ #. module: account_financial_report
1406
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__salesperson
1407
+ msgid "Partner Salesperson"
1408
+ msgstr ""
1409
+
1396
1410
  #. module: account_financial_report
1397
1411
  #. odoo-python
1398
1412
  #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0
@@ -1417,6 +1431,7 @@ msgstr "Ortak başlangıç bakiyesi"
1417
1431
 
1418
1432
  #. module: account_financial_report
1419
1433
  #: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners
1434
+ #: model:ir.model.fields.selection,name:account_financial_report.selection__open_items_report_wizard__grouped_by__partners
1420
1435
  msgid "Partners"
1421
1436
  msgstr "İş Ortakları"
1422
1437
 
@@ -1,5 +1,6 @@
1
1
  # ?? 2016 Julien Coux (Camptocamp)
2
2
  # Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
3
+ # Copyright 2024 Tecnativa - Carolina Fernandez
3
4
  # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4
5
 
5
6
  import operator
@@ -66,6 +67,7 @@ class OpenItemsReport(models.AbstractModel):
66
67
  only_posted_moves,
67
68
  company_id,
68
69
  date_from,
70
+ grouped_by,
69
71
  ):
70
72
  domain = self._get_move_lines_domain_not_reconciled(
71
73
  company_id, account_ids, partner_ids, only_posted_moves, date_from
@@ -75,7 +77,7 @@ class OpenItemsReport(models.AbstractModel):
75
77
  domain=domain, fields=ml_fields
76
78
  )
77
79
  journals_ids = set()
78
- partners_ids = set()
80
+ group_ids = set()
79
81
  partners_data = {}
80
82
  if date_at_object < date.today():
81
83
  (
@@ -119,29 +121,27 @@ class OpenItemsReport(models.AbstractModel):
119
121
  journals_ids.add(move_line["journal_id"][0])
120
122
  acc_id = move_line["account_id"][0]
121
123
  # Partners data
122
- if move_line["partner_id"]:
123
- prt_id = move_line["partner_id"][0]
124
- prt_name = move_line["partner_id"][1]
124
+ partner = self.env["res.partner"]
125
+ if move_line.get("partner_id"):
126
+ partner = self.env["res.partner"].browse(move_line["partner_id"][0])
127
+ if grouped_by == "salesperson":
128
+ user = partner.user_id
129
+ group_id = user.id or 0
130
+ group_name = user.name or _("Missing Salesperson")
125
131
  else:
126
- prt_id = 0
127
- prt_name = _("Missing Partner")
128
- if prt_id not in partners_ids:
129
- partners_data.update({prt_id: {"id": prt_id, "name": prt_name}})
130
- partners_ids.add(prt_id)
131
-
132
+ group_id = partner.id or 0
133
+ group_name = partner.name or _("Missing Partner")
134
+ if group_id not in group_ids:
135
+ partners_data.update({group_id: {"id": group_id, "name": group_name}})
136
+ group_ids.add(group_id)
132
137
  # Move line update
133
- original = 0
134
-
135
138
  if not float_is_zero(move_line["credit"], precision_digits=2):
136
139
  original = move_line["credit"] * (-1)
137
- if not float_is_zero(move_line["debit"], precision_digits=2):
140
+ else:
138
141
  original = move_line["debit"]
139
142
 
140
143
  if move_line["ref"] == move_line["name"]:
141
- if move_line["ref"]:
142
- ref_label = move_line["ref"]
143
- else:
144
- ref_label = ""
144
+ ref_label = move_line["ref"] or ""
145
145
  elif not move_line["ref"]:
146
146
  ref_label = move_line["name"]
147
147
  elif not move_line["name"]:
@@ -155,8 +155,8 @@ class OpenItemsReport(models.AbstractModel):
155
155
  "date_maturity": move_line["date_maturity"]
156
156
  and move_line["date_maturity"].strftime("%d/%m/%Y"),
157
157
  "original": original,
158
- "partner_id": prt_id,
159
- "partner_name": prt_name,
158
+ "partner_id": partner.id or 0,
159
+ "partner_name": partner.name or "",
160
160
  "ref_label": ref_label,
161
161
  "journal_id": move_line["journal_id"][0],
162
162
  "move_name": move_line["move_id"][1],
@@ -172,12 +172,12 @@ class OpenItemsReport(models.AbstractModel):
172
172
 
173
173
  # Open Items Move Lines Data
174
174
  if acc_id not in open_items_move_lines_data.keys():
175
- open_items_move_lines_data[acc_id] = {prt_id: [move_line]}
175
+ open_items_move_lines_data[acc_id] = {group_id: [move_line]}
176
176
  else:
177
- if prt_id not in open_items_move_lines_data[acc_id].keys():
178
- open_items_move_lines_data[acc_id][prt_id] = [move_line]
177
+ if group_id not in open_items_move_lines_data[acc_id].keys():
178
+ open_items_move_lines_data[acc_id][group_id] = [move_line]
179
179
  else:
180
- open_items_move_lines_data[acc_id][prt_id].append(move_line)
180
+ open_items_move_lines_data[acc_id][group_id].append(move_line)
181
181
  journals_data = self._get_journals_data(list(journals_ids))
182
182
  accounts_data = self._get_accounts_data(open_items_move_lines_data.keys())
183
183
  return (
@@ -236,7 +236,9 @@ class OpenItemsReport(models.AbstractModel):
236
236
  move_lines = []
237
237
  for move_line in open_items_move_lines_data[acc_id][prt_id]:
238
238
  move_lines += [move_line]
239
- move_lines = sorted(move_lines, key=lambda k: (k["date"]))
239
+ move_lines = sorted(
240
+ move_lines, key=lambda k: (k["date"], k["partner_id"])
241
+ )
240
242
  new_open_items[acc_id][prt_id] = move_lines
241
243
  return new_open_items
242
244
 
@@ -251,7 +253,7 @@ class OpenItemsReport(models.AbstractModel):
251
253
  date_from = data["date_from"]
252
254
  only_posted_moves = data["only_posted_moves"]
253
255
  show_partner_details = data["show_partner_details"]
254
-
256
+ grouped_by = data["grouped_by"]
255
257
  (
256
258
  move_lines_data,
257
259
  partners_data,
@@ -265,6 +267,7 @@ class OpenItemsReport(models.AbstractModel):
265
267
  only_posted_moves,
266
268
  company_id,
267
269
  date_from,
270
+ grouped_by,
268
271
  )
269
272
 
270
273
  total_amount = self._calculate_amounts(open_items_move_lines_data)
@@ -290,6 +293,7 @@ class OpenItemsReport(models.AbstractModel):
290
293
  "accounts_data": accounts_data,
291
294
  "total_amount": total_amount,
292
295
  "Open_Items": open_items_move_lines_data,
296
+ "grouped_by": grouped_by,
293
297
  }
294
298
 
295
299
  def _get_ml_fields(self):
@@ -101,11 +101,126 @@ class OpenItemsXslx(models.AbstractModel):
101
101
  def _get_col_pos_final_balance_label(self):
102
102
  return 5
103
103
 
104
- def _generate_report_content(self, workbook, report, data, report_data):
105
- res_data = self.env[
106
- "report.account_financial_report.open_items"
107
- ]._get_report_values(report, data)
108
- # For each account
104
+ def _calculate_amounts_by_partner(self, account_id, open_items_move_lines_data):
105
+ total_amount = {}
106
+ for line in open_items_move_lines_data:
107
+ partner_id_key = line["partner_id"]
108
+ if account_id not in total_amount:
109
+ total_amount[account_id] = {}
110
+ if partner_id_key not in total_amount[account_id]:
111
+ total_amount[account_id][partner_id_key] = {"residual": 0.0}
112
+ total_amount[account_id][partner_id_key]["residual"] += line[
113
+ "amount_residual"
114
+ ]
115
+ return total_amount
116
+
117
+ def _generate_report_content_by_salesperson(
118
+ self, workbook, report, data, report_data, res_data
119
+ ):
120
+ Open_items = res_data["Open_Items"]
121
+ accounts_data = res_data["accounts_data"]
122
+ partners_data = res_data["partners_data"]
123
+ journals_data = res_data["journals_data"]
124
+ total_amount = res_data["total_amount"]
125
+
126
+ for partner_id in partners_data.keys():
127
+ # Create a new sheet for each partner
128
+ partner_totals = {}
129
+ partner_name = partners_data[partner_id]["name"]
130
+ new_sheet = workbook.add_worksheet(partner_name[:31])
131
+ report_data["sheet"] = new_sheet
132
+ report_data["row_pos"] = 0
133
+
134
+ for account_id in Open_items.keys():
135
+ if partner_id in Open_items[account_id]:
136
+ self.write_array_title(
137
+ accounts_data[account_id]["code"]
138
+ + " - "
139
+ + accounts_data[account_id]["name"],
140
+ report_data,
141
+ )
142
+
143
+ # For each partner
144
+ if Open_items[account_id]:
145
+ type_object = "partner"
146
+ # Write partner title
147
+ self.write_array_title(
148
+ partners_data[partner_id]["name"], report_data
149
+ )
150
+
151
+ # Calculate totals by partner_id
152
+ partner_totals = self._calculate_amounts_by_partner(
153
+ account_id, Open_items[account_id][partner_id]
154
+ )
155
+ # Display array header for move lines
156
+ self.write_array_header(report_data)
157
+ # Display account move lines
158
+ has_lines = False
159
+ for partner_id_key, total_amount_dict in partner_totals.get(
160
+ account_id, {}
161
+ ).items():
162
+ for line in Open_items[account_id][partner_id]:
163
+ if line["partner_id"] == partner_id_key:
164
+ line.update(
165
+ {
166
+ "account": accounts_data[account_id][
167
+ "code"
168
+ ],
169
+ "journal": journals_data[
170
+ line["journal_id"]
171
+ ]["code"],
172
+ }
173
+ )
174
+ self.write_line_from_dict(line, report_data)
175
+ has_lines = True
176
+ if has_lines:
177
+ partner = self.env["res.partner"].browse(partner_id_key)
178
+ # Display ending balance line for partner
179
+ partner_data = {
180
+ "id": partner_id_key,
181
+ "name": partner.name
182
+ if partner
183
+ else _("Missing Partner"),
184
+ "currency_id": accounts_data[account_id][
185
+ "currency_id"
186
+ ],
187
+ "currency_name": accounts_data[account_id][
188
+ "currency_name"
189
+ ],
190
+ "residual": total_amount_dict,
191
+ }
192
+ self.write_ending_balance_from_dict(
193
+ partner_data,
194
+ "partner_subtotal",
195
+ partner_totals,
196
+ report_data,
197
+ account_id=account_id,
198
+ partner_id=partner_id_key,
199
+ )
200
+ has_lines = False
201
+ # Display ending balance line for salesperson
202
+ partners_data[partner_id].update(
203
+ {
204
+ "currency_id": accounts_data[account_id]["currency_id"],
205
+ "currency_name": accounts_data[account_id][
206
+ "currency_name"
207
+ ],
208
+ }
209
+ )
210
+ self.write_ending_balance_from_dict(
211
+ partners_data[partner_id],
212
+ type_object,
213
+ total_amount,
214
+ report_data,
215
+ account_id=account_id,
216
+ partner_id=partner_id,
217
+ )
218
+ # Line break
219
+ report_data["row_pos"] += 1
220
+
221
+ def _generate_report_content_by_partner(
222
+ self, workbook, report, data, report_data, res_data
223
+ ):
109
224
  Open_items = res_data["Open_Items"]
110
225
  accounts_data = res_data["accounts_data"]
111
226
  partners_data = res_data["partners_data"]
@@ -120,7 +235,6 @@ class OpenItemsXslx(models.AbstractModel):
120
235
  + accounts_data[account_id]["name"],
121
236
  report_data,
122
237
  )
123
-
124
238
  # For each partner
125
239
  if Open_items[account_id]:
126
240
  if show_partner_details:
@@ -180,18 +294,33 @@ class OpenItemsXslx(models.AbstractModel):
180
294
  )
181
295
  self.write_line_from_dict(line, report_data)
182
296
 
183
- # Display ending balance line for account
184
- type_object = "account"
185
- self.write_ending_balance_from_dict(
186
- accounts_data[account_id],
187
- type_object,
188
- total_amount,
189
- report_data,
190
- account_id=account_id,
191
- )
297
+ # Display ending balance line for account
298
+ type_object = "account"
299
+ self.write_ending_balance_from_dict(
300
+ accounts_data[account_id],
301
+ type_object,
302
+ total_amount,
303
+ report_data,
304
+ account_id=account_id,
305
+ )
306
+
307
+ # 2 lines break
308
+ report_data["row_pos"] += 2
192
309
 
193
- # 2 lines break
194
- report_data["row_pos"] += 2
310
+ def _generate_report_content(self, workbook, report, data, report_data):
311
+ res_data = self.env[
312
+ "report.account_financial_report.open_items"
313
+ ]._get_report_values(report, data)
314
+ show_partner_details = res_data["show_partner_details"]
315
+ grouped_by = res_data["grouped_by"]
316
+ if grouped_by == "salesperson" and show_partner_details:
317
+ return self._generate_report_content_by_salesperson(
318
+ workbook, report, data, report_data, res_data
319
+ )
320
+ else:
321
+ return self._generate_report_content_by_partner(
322
+ workbook, report, data, report_data, res_data
323
+ )
195
324
 
196
325
  def write_ending_balance_from_dict(
197
326
  self,
@@ -211,6 +340,10 @@ class OpenItemsXslx(models.AbstractModel):
211
340
  name = my_object["code"] + " - " + my_object["name"]
212
341
  my_object["residual"] = total_amount[account_id]["residual"]
213
342
  label = _("Ending balance")
343
+ elif type_object == "partner_subtotal":
344
+ name = my_object["name"]
345
+ my_object["residual"] = total_amount[account_id][partner_id]["residual"]
346
+ label = _("Ending balance")
214
347
  return super().write_ending_balance_from_dict(
215
348
  my_object, name, label, report_data
216
349
  )