odoo-addon-account-move-payroll-import 16.0.1.0.0__py2.py3-none-any.whl → 16.0.1.0.2__py2.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.
@@ -10,16 +10,20 @@ class PayrollCustomConcept(models.Model):
10
10
 
11
11
  @api.model
12
12
  def create(self, vals):
13
- default_account_ext_id = "l10n_es.%s_%s" % (
14
- self.env.company.id, vals.get("default_account_xml_id", False)
15
- )
16
- if default_account_ext_id:
17
- account = self.env.ref(default_account_ext_id, False)
18
- vals.update({"account_id": account.id if account else False})
13
+ if not vals.get("account_id", False) and vals.get("default_account_xml_id", False):
14
+ default_account_ext_id = "l10n_es.%s_%s" % (
15
+ self.env.company.id, vals.get("default_account_xml_id", False)
16
+ )
17
+ if default_account_ext_id:
18
+ account = self.env.ref(default_account_ext_id, False)
19
+ vals.update({"account_id": account.id if account else False})
19
20
 
20
21
  return super(PayrollCustomConcept, self).create(vals)
21
22
 
22
23
  def _default_account(self):
24
+ if not self.default_account_xml_id:
25
+ return False
26
+
23
27
  default_account_ext_id = "l10n_es.%s_%s" % (
24
28
  self.env.company.id, self.default_account_xml_id
25
29
  )
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- from odoo import models, fields, _, Command
3
+ from odoo import models, fields, api, _, Command
4
4
  from odoo.exceptions import UserError
5
5
 
6
6
  from ..utils.parse_utils import abs_float
@@ -78,6 +78,21 @@ class PayrollImportSetup(models.Model):
78
78
  ),
79
79
  ]
80
80
 
81
+ @api.model_create_multi
82
+ def create(self, vals_list):
83
+ for vals in vals_list:
84
+ for custom_concept in vals.get("custom_concepts_ids", []):
85
+ custom_concept = custom_concept[2] if len(custom_concept) >= 3 else {}
86
+
87
+ if not custom_concept.get("account_id", False):
88
+ raise UserError(
89
+ _(
90
+ "Please select an account for the custom concept '%s'."
91
+ % custom_concept.get("name")
92
+ )
93
+ )
94
+ return super(PayrollImportSetup, self).create(vals_list)
95
+
81
96
  name = fields.Char(
82
97
  string="Name",
83
98
  default=_("Payroll Import A3 2024"),
@@ -323,9 +338,51 @@ class PayrollImportSetup(models.Model):
323
338
  }
324
339
 
325
340
  def validate_column_numbers(self, data_length):
341
+ def validate_indexes(names):
342
+ repeated_indexes = [
343
+ k for k, v in names.items() if list(names.values()).count(v) > 1
344
+ ]
345
+ if repeated_indexes:
346
+ raise UserError(
347
+ _(
348
+ "%s indexes are repeated. Please review your setup."
349
+ % (", ".join(repeated_indexes))
350
+ )
351
+ )
352
+
353
+ for name, idx in names.items():
354
+ if idx < 1:
355
+ raise UserError(
356
+ _(
357
+ "Column index for %s must be greater than or equal to 1."
358
+ % name
359
+ )
360
+ )
361
+ if idx > data_length:
362
+ raise UserError(
363
+ _(
364
+ "Column index for %s must be less or equal than %s."
365
+ % (name, data_length)
366
+ )
367
+ )
368
+
369
+ names = {}
326
370
  for field in [k for k in self._fields.keys() if k.startswith("column_")]:
327
- if getattr(self, field) > data_length:
328
- raise UserError(_("Column %s is out of range." % field))
371
+ index = getattr(self, field)
372
+ name = self.env["ir.model.fields"].search(
373
+ [("model", "=", self._name), ("name", "=", field)],
374
+ limit=1,
375
+ ).field_description
376
+ names[name] = index
377
+
378
+ for custom_concept in self.custom_concepts_ids:
379
+ index = custom_concept.col_index
380
+ name = custom_concept.name
381
+ names[name] = index
382
+
383
+ validate_indexes(names)
384
+
385
+ return True
329
386
 
330
387
  def compute_tc1rlc_ss_cumulative(self, row, cumulative):
331
388
  """
@@ -10,7 +10,8 @@ def get_file_extension(file_name):
10
10
  Get the file extension from the file name.
11
11
  """
12
12
  if file_name:
13
- return os.path.splitext(file_name)[-1]
13
+ ext = os.path.splitext(file_name)[-1]
14
+ return str(ext).lower() if ext else False
14
15
  return False
15
16
 
16
17
 
@@ -39,7 +39,10 @@ class AccountPayrollImportWizard(models.TransientModel):
39
39
  def _default_payroll_import_setup(self):
40
40
  payroll_import_setup = self.env["payroll.import.setup"].search([], limit=1)
41
41
  if not payroll_import_setup:
42
- payroll_import_setup = self.env["payroll.import.setup"].create({})
42
+ try:
43
+ payroll_import_setup = self.env["payroll.import.setup"].create({})
44
+ except Exception:
45
+ return False
43
46
 
44
47
  return payroll_import_setup
45
48
 
@@ -71,6 +74,15 @@ class AccountPayrollImportWizard(models.TransientModel):
71
74
  if not self.payroll_import_setup_id.journal_id:
72
75
  raise UserError(_("Please select a journal in the import configuration."))
73
76
 
77
+ for custom_concept in self.payroll_import_setup_id.custom_concepts_ids:
78
+ if not custom_concept.account_id:
79
+ raise UserError(
80
+ _(
81
+ "Please select an account for the custom concept: %s."
82
+ % custom_concept.name
83
+ )
84
+ )
85
+
74
86
  extension = is_valid_extension(self.file_name)
75
87
  if not extension:
76
88
  raise UserError(
@@ -278,6 +290,8 @@ class AccountPayrollImportWizard(models.TransientModel):
278
290
  rows, cumulative_tc1rlc_ss = [], 0.0
279
291
  skip_lines = options.get("header_lines", 1) - 1
280
292
  for idx, row in enumerate(getattr(self, f"_read_{extension}")(options)):
293
+ if idx == 0:
294
+ import_setup.validate_column_numbers(len(row))
281
295
  if idx == import_setup.header_ref_line - 1:
282
296
  self.account_move_ref = row[0].strip() or import_setup.name
283
297
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: odoo-addon-account-move-payroll-import
3
- Version: 16.0.1.0.0
3
+ Version: 16.0.1.0.2
4
4
  Summary: ODOO account move spanish payroll data import for social cooperatives.
5
5
  Home-page: https://gitlab.com/somitcoop/erp-research/odoo-accounting
6
6
  Author: Som It Cooperatiu SCCL, Som Connexió SCCL
@@ -1,28 +1,28 @@
1
1
  odoo/addons/account_move_payroll_import/CHANGELOG.md,sha256=COE0An9jnvIrV7eWgGSa6XzTGN8tACjr_LkFmjRbqos,608
2
2
  odoo/addons/account_move_payroll_import/README.rst,sha256=fnLmb6E5pLv2d-kzAVwIs2O1QKyApMwCobkT9nUgXbo,3354
3
3
  odoo/addons/account_move_payroll_import/__init__.py,sha256=xdfbExIUANT_2sXVtonxwfOse1Cqvz2AVNntyx_lINE,68
4
- odoo/addons/account_move_payroll_import/__manifest__.py,sha256=6ABK7Sbxchr-Df-d49ElodKYxFx5eCXvp-OHfM9cMyA,1379
4
+ odoo/addons/account_move_payroll_import/__manifest__.py,sha256=kX0bjjK13GFQaPtzrlk9ibJSc5gzHuOIX8F9Lps5cP4,1379
5
5
  odoo/addons/account_move_payroll_import/data/payroll_import_defaults.xml,sha256=8fnC8Z2ov3ulvcwcaazG5i3DGBzaK5Q0JFhF4dRzn9s,4570
6
- odoo/addons/account_move_payroll_import/i18n/ca_ES.po,sha256=8ucDStleOanDEsdBK1IFKGsbwWjrQ6_-YUCICN3TGaI,38186
7
- odoo/addons/account_move_payroll_import/i18n/es.po,sha256=grQjubV3lz29tHlLtRyUjSF6NrmHyDRRUGo1V7poTpw,38369
6
+ odoo/addons/account_move_payroll_import/i18n/ca_ES.po,sha256=shnWYO_4x0t4HRM7ajXBT06tIOuEmFch6zXc7wfKybQ,41693
7
+ odoo/addons/account_move_payroll_import/i18n/es.po,sha256=MJslDNYJsRPQRk11u3SB-uH6diHLHQoqa-rqTEqt-cw,41915
8
8
  odoo/addons/account_move_payroll_import/models/__init__.py,sha256=MvOdNmgSVk-29bpZZRt415YrRUGryuSE7gpIzoRqw5c,161
9
9
  odoo/addons/account_move_payroll_import/models/account_move.py,sha256=8T-DNpKHc_e4r18NSx8Bh2xFQB4DlLI69ImxmghXJU8,6031
10
- odoo/addons/account_move_payroll_import/models/payroll_custom_concept.py,sha256=xTSojF_wYgpIg-jFwCsZVlsllP7Cratmy7Mh6Gr20g4,1817
10
+ odoo/addons/account_move_payroll_import/models/payroll_custom_concept.py,sha256=m8Wl_xFsWCwOqLJWwBFTmtA669rqIg0mIvGNqDtBnfw,2003
11
11
  odoo/addons/account_move_payroll_import/models/payroll_import_mapping.py,sha256=ARiif1H0CMs17n-0SW563Jv9jA1ta3nhCtq9l4vVbHA,943
12
- odoo/addons/account_move_payroll_import/models/payroll_import_setup.py,sha256=odQtiA_58mrQhDG54poEg15ME72bfMCGa4WPIwD5Lkg,16938
12
+ odoo/addons/account_move_payroll_import/models/payroll_import_setup.py,sha256=_kSbc1HtLHE03-tNZpoSyKJTLYankJcO-DLAh36bYQM,18967
13
13
  odoo/addons/account_move_payroll_import/security/ir.model.access.csv,sha256=YI4EAYd35NkiQvd1URS3Ex_zV3GVuI1-T-thl9mlCrU,536
14
14
  odoo/addons/account_move_payroll_import/static/src/css/styles.css,sha256=JK4NBJ_TIy-sWYIGa5nRlZh-KH1OKr1eBzCYx7pJjyI,522
15
15
  odoo/addons/account_move_payroll_import/static/src/js/payroll_import_button.js,sha256=cK9eHxA9jCSGr0HuZFV5Gvy8WWXe8iwNSDV4bYpJEFc,844
16
16
  odoo/addons/account_move_payroll_import/static/src/xml/payroll_import_templates.xml,sha256=HKgIpLA1aN9JruR-W3yKb5MEFezCGurxJAG1sOhDlQ0,731
17
17
  odoo/addons/account_move_payroll_import/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- odoo/addons/account_move_payroll_import/utils/file_utils.py,sha256=ngbyD5Z9kdJ4nSiuI2jxuuTUTuy9ZrLrXEVjrXVyJpI,566
18
+ odoo/addons/account_move_payroll_import/utils/file_utils.py,sha256=kgf_NfE-HwJlIv6M8aVJFWl7ZHMRGJuCg6cqITXQvOg,615
19
19
  odoo/addons/account_move_payroll_import/utils/parse_utils.py,sha256=G5Crc1A0NzMtD6zSZOl2PVrgMMOfTOZNR2y0Mh9u3FM,1020
20
20
  odoo/addons/account_move_payroll_import/views/assets_template.xml,sha256=SMV2_61cbZG_IjIlsBEiYVLVAb4VmoBRYSsiljou1jU,544
21
21
  odoo/addons/account_move_payroll_import/views/payroll_import_views.xml,sha256=r4PrdTU7MY_KZMJFIcOgms9IaCPv2sirJagnlVWUotI,10386
22
22
  odoo/addons/account_move_payroll_import/wizards/__init__.py,sha256=ZJP90LnlsKPOz5hOqllzpC8O0__7WcIiH6FauPHav_w,60
23
- odoo/addons/account_move_payroll_import/wizards/payroll_import_wizard.py,sha256=MO7ZpnjpEt2_o5LpYbJnDzEXvmzb065hwNlpsYNG_-g,11912
23
+ odoo/addons/account_move_payroll_import/wizards/payroll_import_wizard.py,sha256=bJjuYMjc_kSspxWld8xw6nMvE-JgwDRurYBjEzZ9zoE,12428
24
24
  odoo/addons/account_move_payroll_import/wizards/payroll_import_wizard.xml,sha256=p7ewpc4WKDMdJ3a5DGYLtyX8bYDZWHqUrZ42XKzW868,1926
25
- odoo_addon_account_move_payroll_import-16.0.1.0.0.dist-info/METADATA,sha256=c0fowwohoRC-q-__tYBwpM2dUB1HZnniqWJOi8bFx6I,3905
26
- odoo_addon_account_move_payroll_import-16.0.1.0.0.dist-info/WHEEL,sha256=fS9sRbCBHs7VFcwJLnLXN1MZRR0_TVTxvXKzOnaSFs8,110
27
- odoo_addon_account_move_payroll_import-16.0.1.0.0.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
28
- odoo_addon_account_move_payroll_import-16.0.1.0.0.dist-info/RECORD,,
25
+ odoo_addon_account_move_payroll_import-16.0.1.0.2.dist-info/METADATA,sha256=_psgw__Go9wG65j8ogrE-EjGE5yY552mcmdL39K5Kjs,3905
26
+ odoo_addon_account_move_payroll_import-16.0.1.0.2.dist-info/WHEEL,sha256=QyeGbh-t8WT0nt0_LNSP02jN-g4ymd1egk1U3osCGMU,110
27
+ odoo_addon_account_move_payroll_import-16.0.1.0.2.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
28
+ odoo_addon_account_move_payroll_import-16.0.1.0.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: bdist_wheel (0.45.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any