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

Proposed by jftempo
Status: Merged
Merge reported by: jftempo
Merged at revision: not available
Proposed branch: lp:~julie-w/unifield-server/US-2897
Merge into: lp:unifield-server
Diff against target: 129 lines (+51/-30)
2 files modified
bin/addons/account_journal/account_journal.py (+33/-23)
bin/addons/account_journal/account_journal_view.xml (+18/-7)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-2897
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+326744@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
=== modified file 'bin/addons/account_journal/account_journal.py'
--- bin/addons/account_journal/account_journal.py 2017-05-26 10:03:57 +0000
+++ bin/addons/account_journal/account_journal.py 2017-07-04 09:20:36 +0000
@@ -216,6 +216,34 @@
216 self.pool.get('account.sequence.fiscalyear').create(cr, uid, {'sequence_id': sequence_id, 'fiscalyear_id': fiscalyear, 'sequence_main_id': main_sequence,})216 self.pool.get('account.sequence.fiscalyear').create(cr, uid, {'sequence_id': sequence_id, 'fiscalyear_id': fiscalyear, 'sequence_main_id': main_sequence,})
217 return True217 return True
218218
219 def _create_linked_register(self, cr, uid, journal_id, vals, context):
220 """
221 If the journal is a liquidity journal creates the register linked to it if it doesn't exist yet
222 """
223 reg_obj = self.pool.get('account.bank.statement')
224 # UTP-182: the register isn't created if the journal comes from another instance via the synchronization
225 if 'type' in vals and vals['type'] in ('cash', 'bank', 'cheque') \
226 and not context.get('sync_update_execution', False) and \
227 not reg_obj.search_exist(cr, uid, [('journal_id', '=', journal_id)], context=context):
228
229 # 'from_journal_creation' in context permits to pass register creation that have a
230 # 'prev_reg_id' mandatory field. This is because this register is the first register from this journal.
231 context.update({'from_journal_creation': True})
232
233 #BKLG-53 get the next draft period from today
234 current_date = datetime.date.today().strftime('%Y-%m-%d')
235 periods = self.pool.get('account.period').search(cr, uid, [
236 ('date_stop', '>=',current_date),
237 ('state', '=', 'draft'),
238 ('special', '=', False),
239 ], context=context, limit=1, order='date_stop')
240 if not periods:
241 raise osv.except_osv(_('Warning'), _('Sorry, No open period for creating the register!'))
242 reg_obj.create(cr, uid, {'journal_id': journal_id,
243 'name': vals['name'],
244 'period_id': periods[0],
245 'currency': vals.get('currency')}, context=context)
246
219 def create(self, cr, uid, vals, context=None):247 def create(self, cr, uid, vals, context=None):
220 """248 """
221 Create the journal with its sequence, a sequence linked to the fiscalyear and some register if this journal type is bank, cash or cheque.249 Create the journal with its sequence, a sequence linked to the fiscalyear and some register if this journal type is bank, cash or cheque.
@@ -270,29 +298,8 @@
270 if vals['type'] in ['cash', 'bank', 'cheque', 'cur_adj']:298 if vals['type'] in ['cash', 'bank', 'cheque', 'cur_adj']:
271 if not vals.get('default_debit_account_id'):299 if not vals.get('default_debit_account_id'):
272 raise osv.except_osv(_('Warning'), _('Default Debit Account is missing.'))300 raise osv.except_osv(_('Warning'), _('Default Debit Account is missing.'))
273301 # if it is a liquidity journal create the linked register
274 # if the journal can be linked to a register, the register is also created302 self._create_linked_register(cr, uid, journal_id, vals, context)
275 # UTP-182: but not create if the journal came from another instance via the synchronization
276 if vals['type'] in ('cash','bank','cheque') and not context.get('sync_update_execution', False):
277 # 'from_journal_creation' in context permits to pass register creation that have a
278 # 'prev_reg_id' mandatory field. This is because this register is the first register from this journal.
279 context.update({'from_journal_creation': True})
280
281 #BKLG-53 get the next draft period from today
282 current_date = datetime.date.today().strftime('%Y-%m-%d')
283 periods = self.pool.get('account.period').search(cr, uid, [
284 ('date_stop','>=',current_date),
285 ('state','=','draft'),
286 ('special', '=', False),
287 ], context=context, limit=1, order='date_stop')
288 if not periods:
289 raise osv.except_osv(_('Warning'), _('Sorry, No open period for creating the register!'))
290 self.pool.get('account.bank.statement') \
291 .create(cr, uid, {'journal_id': journal_id,
292 'name': vals['name'],
293 'period_id': periods[0],
294 'currency': vals.get('currency')}, \
295 context=context)
296303
297 # Prevent user that default account for cur_adj type should be an expense account304 # Prevent user that default account for cur_adj type should be an expense account
298 if vals['type'] in ['cur_adj']:305 if vals['type'] in ['cur_adj']:
@@ -308,6 +315,8 @@
308 """315 """
309 if not ids:316 if not ids:
310 return True317 return True
318 if isinstance(ids, (int, long)):
319 ids = [ids]
311 if context is None:320 if context is None:
312 context = {}321 context = {}
313322
@@ -322,6 +331,7 @@
322 for j in self.browse(cr, uid, ids):331 for j in self.browse(cr, uid, ids):
323 if j.type == 'cur_adj' and j.default_debit_account_id.user_type_code != 'expense':332 if j.type == 'cur_adj' and j.default_debit_account_id.user_type_code != 'expense':
324 raise osv.except_osv(_('Warning'), _('Default Debit Account should be an expense account for Adjustement Journals!'))333 raise osv.except_osv(_('Warning'), _('Default Debit Account should be an expense account for Adjustement Journals!'))
334 self._create_linked_register(cr, uid, j.id, vals, context)
325 # US-265: Check account bank statements if name change335 # US-265: Check account bank statements if name change
326 if not context.get('sync_update_execution'):336 if not context.get('sync_update_execution'):
327 if vals.get('name', False):337 if vals.get('name', False):
328338
=== modified file 'bin/addons/account_journal/account_journal_view.xml'
--- bin/addons/account_journal/account_journal_view.xml 2016-11-04 12:57:37 +0000
+++ bin/addons/account_journal/account_journal_view.xml 2017-07-04 09:20:36 +0000
@@ -14,19 +14,30 @@
14 <group colspan="4" col="6">14 <group colspan="4" col="6">
15 <field name="has_entries" invisible="1"/>15 <field name="has_entries" invisible="1"/>
16 <field name="name" select="1"/>16 <field name="name" select="1"/>
17 <field name="code" select="1" attrs="{'readonly': [('has_entries', '=', True)]}"/>17 <field name="code" select="1"
18 <field name="type" on_change="onchange_type(type, currency, context)"/>18 attrs="{'readonly': [('has_entries', '=', True)]}"/>
19 <field name="type" on_change="onchange_type(type, currency, context)"
20 attrs="{'readonly': [('has_entries', '=', True)]}"/>
19 </group>21 </group>
20 <group col="2" colspan="2">22 <group col="2" colspan="2">
21 <separator string="Accounts" colspan="4"/>23 <separator string="Accounts" colspan="4"/>
22 <field name="default_debit_account_id" domain="[('type','&lt;&gt;','view'), ('cash_domain', '=', type)]" attrs="{'required': [('type', 'in', ('cash', 'bank', 'cheque', 'cur_adj'))]}"/>24 <field name="default_debit_account_id" domain="[('type','&lt;&gt;','view'), ('cash_domain', '=', type)]"
23 <field name="default_credit_account_id" domain="[('type','&lt;&gt;','view'), ('cash_domain', '=', type)]" attrs="{'required': [('type', 'in', ('cash', 'bank', 'cheque', 'cur_adj'))]}"/>25 attrs="{'required': [('type', 'in', ('cash', 'bank', 'cheque', 'cur_adj'))]}"/>
26 <field name="default_credit_account_id" domain="[('type','&lt;&gt;','view'), ('cash_domain', '=', type)]"
27 attrs="{'required': [('type', 'in', ('cash', 'bank', 'cheque', 'cur_adj'))]}"/>
24 </group>28 </group>
25 <group colspan="2" col="2">29 <group colspan="2" col="2">
26 <separator string="Company" colspan="4"/>30 <separator string="Company" colspan="4"/>
27 <field name="currency" attrs="{'required': [('type', 'in', ('cash', 'bank', 'cheque'))]}"/>31 <field name="currency"
28 <field name="analytic_journal_id" domain="[('is_current_instance','=',True)]" attrs="{'required': [('type', 'not in', ('situation', 'stock'))]}"/>32 attrs="{'required': [('type', 'in', ('cash', 'bank', 'cheque'))],
29 <field name="bank_journal_id" attrs="{'invisible': [('type', '!=', 'cheque')], 'required': [('type', '=', 'cheque')]}"/>33 'readonly': [('has_entries', '=', True)]}"/>
34 <field name="analytic_journal_id" domain="[('is_current_instance','=',True)]"
35 attrs="{'required': [('type', 'not in', ('situation', 'stock'))],
36 'readonly': [('has_entries', '=', True)]}"/>
37 <field name="bank_journal_id"
38 attrs="{'invisible': [('type', '!=', 'cheque')],
39 'required': [('type', '=', 'cheque')],
40 'readonly': [('has_entries', '=', True)]}"/>
30 </group>41 </group>
31 <group colspan="4" col="4">42 <group colspan="4" col="4">
32 <label string="" colspan="2"/>43 <label string="" colspan="2"/>

Subscribers

People subscribed via source and target branches