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

Proposed by jftempo
Status: Merged
Merged at revision: 5507
Proposed branch: lp:~julie-w/unifield-server/US-6263
Merge into: lp:unifield-server
Diff against target: 65 lines (+18/-2)
2 files modified
bin/addons/msf_instance/add_instance.py (+12/-2)
bin/addons/msf_profile/i18n/fr_MF.po (+6/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-6263
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+372587@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_instance/add_instance.py'
2--- bin/addons/msf_instance/add_instance.py 2019-06-11 08:10:46 +0000
3+++ bin/addons/msf_instance/add_instance.py 2019-09-11 07:42:30 +0000
4@@ -112,6 +112,12 @@
5 ('name_company_uniq', 'unique (name, company_id, instance_id)', 'The name of the journal must be unique per company and instance !'),
6 ]
7
8+ def _raise_no_analytic_journal_error(self, cr, uid, journal_name, instance_id, context=None):
9+ inst_obj = self.pool.get('msf.instance')
10+ inst_code = inst_obj.read(cr, uid, instance_id, context=context)['code']
11+ raise osv.except_osv(_('Error'),
12+ _('No Analytic Journal %s found for the Proprietary Instance %s.') % (journal_name, inst_code))
13+
14 # SP-72: in order to always get an analytic journal with the same instance,
15 # the create and write check and replace with the "good" journal if necessary.
16 def create(self, cr, uid, vals, context=None):
17@@ -119,7 +125,7 @@
18 user_obj = self.pool.get('res.users')
19 if 'instance_id' not in vals: # ensure that the instance_id always exists, in particular for the Track Changes
20 vals['instance_id'] = user_obj.browse(cr, uid, uid, fields_to_fetch=['company_id'], context=context).company_id.instance_id.id
21- if vals.get('type') and vals.get('type') not in ['situation', 'stock'] and vals.get('analytic_journal_id'):
22+ if vals.get('analytic_journal_id'):
23 analytic_journal = analytic_obj.browse(cr, uid, vals['analytic_journal_id'], context=context)
24
25 if analytic_journal and \
26@@ -131,13 +137,15 @@
27 ('instance_id', '=', vals['instance_id'])], context=context)
28 if len(new_journal_ids) > 0:
29 vals['analytic_journal_id'] = new_journal_ids[0]
30+ else:
31+ self._raise_no_analytic_journal_error(cr, uid, analytic_journal.name, vals['instance_id'], context=context)
32 return super(account_journal, self).create(cr, uid, vals, context=context)
33
34 def write(self, cr, uid, ids, vals, context=None):
35 if not ids:
36 return True
37 analytic_obj = self.pool.get('account.analytic.journal')
38- if vals.get('type') and vals.get('type') not in ['situation', 'stock'] and vals.get('analytic_journal_id'):
39+ if vals.get('analytic_journal_id'):
40 analytic_journal = analytic_obj.browse(cr, uid, vals['analytic_journal_id'], context=context)
41
42 instance_id = False
43@@ -155,6 +163,8 @@
44 ('instance_id','=',instance_id)], context=context)
45 if len(new_journal_ids) > 0:
46 vals['analytic_journal_id'] = new_journal_ids[0]
47+ else:
48+ self._raise_no_analytic_journal_error(cr, uid, analytic_journal.name, instance_id, context=context)
49 return super(account_journal, self).write(cr, uid, ids, vals, context=context)
50
51 account_journal()
52
53=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
54--- bin/addons/msf_profile/i18n/fr_MF.po 2019-08-22 10:11:24 +0000
55+++ bin/addons/msf_profile/i18n/fr_MF.po 2019-09-11 07:42:30 +0000
56@@ -107372,3 +107372,9 @@
57 #: report:purchase.order.merged:0
58 msgid "Functional total cost :"
59 msgstr "Total Coût Fonctionnel :"
60+
61+#. module: msf_instance
62+#: code:addons/msf_instance/add_instance.py:119
63+#, python-format
64+msgid "No Analytic Journal %s found for the Proprietary Instance %s."
65+msgstr "Aucun Journal Analytique %s trouvé pour l'Instance Propriétaire %s."

Subscribers

People subscribed via source and target branches