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

Proposed by jftempo
Status: Merged
Merged at revision: 4407
Proposed branch: lp:~julie-w/unifield-server/US-1764
Merge into: lp:unifield-server
Diff against target: 231 lines (+121/-7)
5 files modified
bin/addons/account_mcdb/account_period_state.py (+49/-0)
bin/addons/account_override/account.py (+33/-0)
bin/addons/account_period_closing_level/account_year_end_closing.py (+8/-3)
bin/addons/account_reconciliation/account_move_line.py (+9/-2)
bin/addons/msf_profile/i18n/fr_MF.po (+22/-2)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-1764
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+326760@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/account_mcdb/account_period_state.py'
2--- bin/addons/account_mcdb/account_period_state.py 2016-02-08 08:37:05 +0000
3+++ bin/addons/account_mcdb/account_period_state.py 2017-07-04 09:20:54 +0000
4@@ -145,6 +145,55 @@
5
6 return super(account_fiscalyear_state, self).create(cr, uid, vals, context=context)
7
8+ def write(self, cr, uid, ids, vals, context=None):
9+ """
10+ When the "FY HQ-closure" update is received via sync in coordo: if during FY mission-closure "Balance move to 0" lines
11+ had been generated, the system will reconcile each of these lines together with the lines there have balanced
12+ """
13+ if not ids:
14+ return True
15+ if isinstance(ids, (int, long)):
16+ ids = [ids]
17+ if context is None:
18+ context = {}
19+ aml_obj = self.pool.get('account.move.line')
20+ year_end_closing_obj = self.pool.get('account.year.end.closing')
21+ user_obj = self.pool.get('res.users')
22+ journal_code = 'EOY'
23+ period_number = 16
24+ company_instance = user_obj.browse(cr, uid, [uid], fields_to_fetch=['company_id'], context=context)[0].company_id.instance_id
25+ instance_ids = year_end_closing_obj._get_mission_ids_from_coordo(cr, uid, company_instance.id, context=context)
26+ if context.get('sync_update_execution', False) and vals.get('state', False) == 'done' and company_instance.level == 'coordo':
27+ sql = '''SELECT ml.id
28+ FROM account_move_line ml
29+ INNER JOIN account_move m ON m.id = ml.move_id
30+ WHERE ml.instance_id in %s
31+ AND ml.date >= %s AND ml.date <= %s AND m.period_id != %s
32+ AND ml.account_id = %s AND ml.currency_id = %s;
33+ '''
34+ for fy_state_id in ids:
35+ fy = self.browse(cr, uid, fy_state_id, fields_to_fetch=['fy_id'], context=context).fy_id
36+ period_id = year_end_closing_obj._get_period_id(cr, uid, fy.id, period_number, context=context)
37+ if not period_id:
38+ raise osv.except_osv(_('Error'), _("FY 'Period %d' not found") % (period_number,))
39+ balance_line_domain = [('journal_id.code', '=', journal_code),
40+ ('period_id.number', '=', period_number),
41+ ('period_id.fiscalyear_id', '=', fy.id),
42+ ('account_id.include_in_yearly_move', '=', True)]
43+ balance_line_ids = aml_obj.search(cr, uid, balance_line_domain, context=context, order='NO_ORDER')
44+ # get the entries balanced by each "Balance move to 0" line
45+ for balance_line in aml_obj.browse(cr, uid, balance_line_ids,
46+ fields_to_fetch=['account_id', 'currency_id'], context=context):
47+ cr.execute(sql, (tuple(instance_ids), fy.date_start, fy.date_stop, period_id,
48+ balance_line.account_id.id, balance_line.currency_id.id,))
49+ aml_ids = map(lambda x: x[0], cr.fetchall())
50+ aml_ids.append(balance_line.id)
51+ # with 'fy_hq_closing' in context we don't check if the account is reconcilable
52+ # (but the check that no entry is already reconciled is kept)
53+ context['fy_hq_closing'] = True
54+ aml_obj.reconcile(cr, uid, aml_ids, context=context)
55+ return super(account_fiscalyear_state, self).write(cr, uid, ids, vals, context=context)
56+
57 def get_fy(self, cr, uid, ids, context=None):
58 mod_obj = self.pool.get('ir.model.data')
59 view_id = mod_obj.get_object_reference(cr, uid, 'account_mcdb',
60
61=== modified file 'bin/addons/account_override/account.py'
62--- bin/addons/account_override/account.py 2017-04-19 13:25:50 +0000
63+++ bin/addons/account_override/account.py 2017-07-04 09:20:54 +0000
64@@ -497,16 +497,49 @@
65 'has_partner_type_section' in vals and not vals['has_partner_type_section']:
66 raise osv.except_osv(_('Warning !'), _('At least one Allowed Partner type must be selected.'))
67
68+ def _check_reconcile_status(self, cr, uid, vals, account_id=None, context=None):
69+ """
70+ Prevent an account from being set as reconcilable if it is included in the yearly move to 0.
71+ """
72+ if context is None:
73+ context = {}
74+ reconcile = False
75+ include_in_yearly_move = False
76+ account = False
77+ # if one of the fields to check isn't in vals, use its current value if it exists
78+ if 'reconcile' in vals:
79+ reconcile = vals['reconcile']
80+ elif account_id is not None:
81+ account = self.browse(cr, uid, account_id,
82+ fields_to_fetch=['reconcile', 'include_in_yearly_move'], context=context)
83+ reconcile = account.reconcile
84+ if 'include_in_yearly_move' in vals:
85+ include_in_yearly_move = vals['include_in_yearly_move']
86+ elif account_id is not None:
87+ account = account or self.browse(cr, uid, account_id,
88+ fields_to_fetch=['include_in_yearly_move'], context=context)
89+ include_in_yearly_move = account.include_in_yearly_move
90+ if reconcile and include_in_yearly_move:
91+ raise osv.except_osv(_('Warning !'),
92+ _("An account can't be both reconcilable and included in the yearly move to 0."))
93+
94 def create(self, cr, uid, vals, context=None):
95 self._check_date(vals)
96 self._check_allowed_partner_type(vals)
97+ self._check_reconcile_status(cr, uid, vals, context=context)
98 return super(account_account, self).create(cr, uid, vals, context=context)
99
100 def write(self, cr, uid, ids, vals, context=None):
101 if not ids:
102 return True
103+ if isinstance(ids, (int, long)):
104+ ids = [ids]
105+ if context is None:
106+ context = {}
107 self._check_date(vals)
108 self._check_allowed_partner_type(vals)
109+ for account_id in ids:
110+ self._check_reconcile_status(cr, uid, vals, account_id=account_id, context=context)
111 return super(account_account, self).write(cr, uid, ids, vals, context=context)
112
113 def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
114
115=== modified file 'bin/addons/account_period_closing_level/account_year_end_closing.py'
116--- bin/addons/account_period_closing_level/account_year_end_closing.py 2016-07-06 10:23:25 +0000
117+++ bin/addons/account_period_closing_level/account_year_end_closing.py 2017-07-04 09:20:54 +0000
118@@ -400,14 +400,15 @@
119 sql = '''select ml.account_id as account_id, max(a.code) as account_code,
120 ml.currency_id as currency_id, max(c.name) as currency_code,
121 (sum(ml.debit_currency) - sum(ml.credit_currency)) as balance_currency,
122- (sum(ml.debit) - sum(ml.credit)) as balance
123+ (sum(ml.debit) - sum(ml.credit)) as balance,
124+ ml.reconcile_id, ml.reconcile_partial_id
125 from account_move_line ml
126 inner join account_move m on m.id = ml.move_id
127 inner join account_account a on a.id = ml.account_id
128 inner join res_currency c on c.id = ml.currency_id
129 where ml.instance_id in %s and a.include_in_yearly_move = 't'
130 and ml.date >= %s and ml.date <= %s and m.period_id != %s
131- group by ml.account_id, ml.currency_id
132+ group by ml.account_id, ml.currency_id, ml.reconcile_id, ml.reconcile_partial_id
133 '''
134 cr.execute(sql, (tuple(instance_ids), fy_rec.date_start,
135 fy_rec.date_stop, period_id, ))
136@@ -416,7 +417,11 @@
137
138 je_by_acc_ccy = {} # JE/ ACC/CCY, key: (acc_id, ccy_id), value: JE id
139 for account_id, account_code, ccy_id, ccy_code, \
140- balance_currency, balance in cr.fetchall():
141+ balance_currency, balance, reconcile_id, reconcile_partial_id in cr.fetchall():
142+ if reconcile_id or reconcile_partial_id:
143+ raise osv.except_osv(_('Warning'),
144+ _("The yearly closure can't be processed due to one or several reconciled entries "
145+ "that are included in the move to 0."))
146 balance_currency = float(balance_currency)
147 balance = float(balance)
148
149
150=== modified file 'bin/addons/account_reconciliation/account_move_line.py'
151--- bin/addons/account_reconciliation/account_move_line.py 2017-05-12 12:36:30 +0000
152+++ bin/addons/account_reconciliation/account_move_line.py 2017-07-04 09:20:54 +0000
153@@ -243,6 +243,7 @@
154 account_id = line['account_id']['id']
155 partner_id = (line['partner_id'] and line['partner_id']['id']) or False
156 func_balance = func_debit - func_credit
157+ book_balance = debit - credit
158
159 cr.execute('SELECT account_id, reconcile_id '\
160 'FROM account_move_line '\
161@@ -256,12 +257,18 @@
162 if not unrec_lines:
163 raise osv.except_osv(_('Error'), _('Entry is already reconciled'))
164 account = account_obj.browse(cr, uid, account_id, context=context)
165- if not context.get('fy_closing', False) and not account.reconcile:
166+ if not context.get('fy_closing', False) and not context.get('fy_hq_closing', False) and not account.reconcile:
167 raise osv.except_osv(_('Error'), _('The account is not defined to be reconciled !'))
168 if r[0][1] != None:
169 raise osv.except_osv(_('Error'), _('Some entries are already reconciled !'))
170
171- if abs(func_balance) > 10**-3: # FIX UF-1903 problem
172+ if context.get('fy_hq_closing', False):
173+ if abs(func_balance) > 10**-3 or abs(book_balance) > 10**-3:
174+ # yearly move to zero entries should be balanced in functional and booking currency
175+ raise osv.except_osv(_('Error'),
176+ _("The entries included in the yearly move to zero can't be reconciled together "
177+ "because they are unbalanced."))
178+ elif abs(func_balance) > 10**-3: # FIX UF-1903 problem
179 partner_line_id = self.create_addendum_line(cr, uid, [x.id for x in unrec_lines], func_balance)
180 if partner_line_id:
181 # Add partner_line to do total reconciliation
182
183=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
184--- bin/addons/msf_profile/i18n/fr_MF.po 2017-06-12 15:48:51 +0000
185+++ bin/addons/msf_profile/i18n/fr_MF.po 2017-07-04 09:20:54 +0000
186@@ -71913,6 +71913,7 @@
187 #: code:addons/unifield_setup/installer/project_leadtime.py:61
188 #: code:addons/unifield_setup/installer/restrictive_country.py:138
189 #: code:addons/unifield_setup/setup_configuration.py:110
190+#: code:addons/account_mcdb/account_period_state.py:178
191 #: view:allocation.stock.setup:0
192 #: field:allocation.stock.setup,error_central_ok:0
193 #: field:allocation.stock.setup,error_cross_ok:0
194@@ -92566,12 +92567,13 @@
195 msgid "Date start:"
196 msgstr "Date start:"
197
198-#. module: account_period_closing_level
199+#. modules: account_period_closing_level, account_mcdb
200 #: code:addons/account_period_closing_level/account_year_end_closing.py:393
201 #: code:addons/account_period_closing_level/account_year_end_closing.py:533
202+#: code:addons/account_mcdb/account_period_state.py:178
203 #, python-format
204 msgid "FY 'Period %d' not found"
205-msgstr "FY 'Period %d' not found"
206+msgstr "'Période %d' de l'année fiscale non trouvée"
207
208 #. module: account
209 #: model:ir.actions.report.xml,name:account.account_analytic_account_inverted_balance
210@@ -98688,3 +98690,21 @@
211 #, python-format
212 msgid "Warning, you have removed header value source location! The lines will be re-set to have 'Other Supplier' as the source location. Please check this is correct!"
213 msgstr "Attention, vous avez supprimé la zone source d'en-tête! La zone source des lignes va être réinitialisée avec la valeur 'Autre Fournisseur'. Merci de vérifier leur cohérence!"
214+
215+#. module: account_override
216+#: code:addons/account_override/account.py:524
217+#, python-format
218+msgid "An account can't be both reconcilable and included in the yearly move to 0."
219+msgstr "Un compte ne peut pas être à la fois lettrable et inclus dans la mise à zéro annuelle."
220+
221+#. module: account_period_closing_level
222+#: code:addons/account_period_closing_level/account_year_end_closing.py:423
223+#, python-format
224+msgid "The yearly closure can't be processed due to one or several reconciled entries that are included in the move to 0."
225+msgstr "La fermeture de l'année fiscale ne peut pas être effectuée car une ou plusieurs écritures incluses dans la mise à zéro sont déjà lettrées."
226+
227+#. module: account_reconciliation
228+#: code:addons/account_reconciliation/account_move_line.py:269
229+#, python-format
230+msgid "The entries included in the yearly move to zero can't be reconciled together because they are unbalanced."
231+msgstr "Les écritures incluses dans la mise à zéro annuelle ne peuvent pas être lettrées ensemble car elles ne sont pas équilibrées."

Subscribers

People subscribed via source and target branches