Merge lp:~julie-w/unifield-server/US-3853 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4715
Proposed branch: lp:~julie-w/unifield-server/US-3853
Merge into: lp:unifield-server
Diff against target: 116 lines (+55/-26)
2 files modified
bin/addons/msf_profile/i18n/fr_MF.po (+6/-0)
bin/addons/register_accounting/wizard/wizard_register_import.py (+49/-26)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-3853
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+336237@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
2--- bin/addons/msf_profile/i18n/fr_MF.po 2017-12-12 10:23:48 +0000
3+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-01-17 15:53:17 +0000
4@@ -101136,3 +101136,9 @@
5 #, python-format
6 msgid "You must select at least one currency of transfers."
7 msgstr "Vous devez sélectionner au moins une devise de virement."
8+
9+#. module: register_accounting
10+#: code:addons/register_accounting/wizard/wizard_register_import.py:490
11+#, python-format
12+msgid "Line %s. Third Party %s not found or not compatible with the Type for specific treatment of the account '%s - %s'."
13+msgstr "Ligne %s. Tiers %s non trouvé ou non compatible avec le Type pour traitement spécifique du compte '%s - %s'."
14
15=== modified file 'bin/addons/register_accounting/wizard/wizard_register_import.py'
16--- bin/addons/register_accounting/wizard/wizard_register_import.py 2017-04-19 13:19:37 +0000
17+++ bin/addons/register_accounting/wizard/wizard_register_import.py 2018-01-17 15:53:17 +0000
18@@ -234,6 +234,9 @@
19 processed = 0
20 errors = []
21 cheque_numbers = []
22+ employee_obj = self.pool.get('hr.employee')
23+ journal_obj = self.pool.get('account.journal')
24+ partner_obj = self.pool.get('res.partner')
25 try:
26 msf_fp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'analytic_distribution', 'analytic_account_msf_private_funds')[1]
27 except ValueError:
28@@ -309,7 +312,7 @@
29 if isinstance(instance_ids, (int, long)):
30 instance_ids = [instance_ids]
31 # Check second info: journal's code
32- journal_ids = self.pool.get('account.journal').search(cr, uid, [('code', '=', journal_code)])
33+ journal_ids = journal_obj.search(cr, uid, [('code', '=', journal_code)])
34 if not journal_ids or len(journal_ids) > 1:
35 raise osv.except_osv(_('Warning'), _('Journal %s not found.') % (journal_code or '',))
36 if isinstance(journal_ids, (int, long)):
37@@ -454,34 +457,54 @@
38 cheque_numbers.append(r_cheque_number)
39 else:
40 errors.append(_('Line %s. Cheque number is missing') % (current_line_num,))
41- # Check that Third party exists (if not empty)
42+
43+ # Check Account/Third Party compatibility regarding the Account "Type for specific treatment"
44 partner_type = 'partner'
45- if line[cols['third_party']]:
46- if type_for_register == 'advance':
47- tp_ids = self.pool.get('hr.employee').search(cr, uid, [('name', '=', line[cols['third_party']])])
48- partner_type = 'employee'
49- elif type_for_register in ['transfer', 'transfer_same']:
50- tp_ids = self.pool.get('account.journal').search(cr, uid, [('code', '=', line[cols['third_party']])])
51- if tp_ids:
52+ tp_ids = []
53+ has_specific_type = type_for_register in ['advance', 'transfer', 'transfer_same', 'down_payment', 'payroll'] or False
54+ if has_specific_type:
55+ if line[cols['third_party']]:
56+ # Type Operational Advance ==> EMPLOYEE required
57+ if type_for_register == 'advance':
58+ tp_ids = employee_obj.search(cr, uid, [('name', '=', line[cols['third_party']])], context=context)
59+ partner_type = 'employee'
60+ # Type Internal transfer ==> JOURNAL required
61+ elif type_for_register in ['transfer', 'transfer_same']:
62+ tp_ids = journal_obj.search(cr, uid, [('code', '=', line[cols['third_party']])], context=context)
63 partner_type = 'journal'
64- tp_journal = self.pool.get('account.journal').browse(cr, uid, tp_ids, context=context)[0]
65- if type_for_register == 'transfer':
66- if tp_journal.currency.id == register_currency:
67- errors.append(_('Line %s. A Transfer Journal must have a different currency than the register.') % (current_line_num,))
68- if type_for_register == 'transfer_same':
69- if tp_journal.currency.id != register_currency:
70- errors.append(_('Line %s. A Transfer Same Journal must have the same currency as the register.') % (current_line_num,))
71- else:
72- tp_ids = self.pool.get('res.partner').search(cr, uid, [('name', '=', line[cols['third_party']])])
73- partner_type = 'partner'
74- if not tp_ids:
75- # Search now if employee exists
76- tp_ids = self.pool.get('hr.employee').search(cr, uid, [('name', '=', line[cols['third_party']])])
77+ if tp_ids:
78+ tp_journal = journal_obj.browse(cr, uid, tp_ids, fields_to_fetch=['currency'], context=context)[0]
79+ if type_for_register == 'transfer':
80+ if tp_journal.currency.id == register_currency:
81+ errors.append(_('Line %s. A Transfer Journal must have a different currency than the register.') % (current_line_num,))
82+ continue
83+ if type_for_register == 'transfer_same':
84+ if tp_journal.currency.id != register_currency:
85+ errors.append(_('Line %s. A Transfer Same Journal must have the same currency as the register.') % (current_line_num,))
86+ continue
87+ # Type DP or payroll ==> PARTNER required
88+ elif type_for_register in ['down_payment', 'payroll']:
89+ tp_ids = partner_obj.search(cr, uid, [('name', '=', line[cols['third_party']])], context=context)
90+ partner_type = 'partner'
91+ # Any type for Spec. Treatment listed above ==> EMPTY partner NOT allowed
92+ if not tp_ids:
93+ errors.append(
94+ _("Line %s. Third Party %s not found or not compatible with the Type for specific"
95+ " treatment of the account '%s - %s'.") % (current_line_num, line[cols['third_party']] or '',
96+ account['code'], account['name'],))
97+ continue
98+ elif line[cols['third_party']]:
99+ # if the account has no specific type, search for a partner, then an employee
100+ # (the journal type is ignored in that case. If used it should trigger an error message)
101+ tp_ids = partner_obj.search(cr, uid, [('name', '=', line[cols['third_party']])], context=context)
102+ partner_type = 'partner'
103+ if not tp_ids:
104+ tp_ids = employee_obj.search(cr, uid, [('name', '=', line[cols['third_party']])], context=context)
105 partner_type = 'employee'
106- # If really not, raise an error for this line
107- if not tp_ids:
108- errors.append(_('Line %s. Third party not found: %s') % (current_line_num, line[cols['third_party']],))
109- continue
110+ if not tp_ids:
111+ errors.append(_('Line %s. Third party not found: %s') % (current_line_num, line[cols['third_party']],))
112+ continue
113+ if tp_ids:
114 r_partner = tp_ids[0]
115
116 # US-672 TP compat with account

Subscribers

People subscribed via source and target branches