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

Proposed by jftempo
Status: Merged
Merged at revision: 5130
Proposed branch: lp:~julie-w/unifield-server/US-3677
Merge into: lp:unifield-server
Diff against target: 288 lines (+210/-0) (has conflicts)
3 files modified
bin/addons/account_override/invoice.py (+157/-0)
bin/addons/msf_profile/i18n/fr_MF.po (+43/-0)
bin/osv/orm.py (+10/-0)
Text conflict in bin/addons/msf_profile/i18n/fr_MF.po
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-3677
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+357629@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_override/invoice.py'
--- bin/addons/account_override/invoice.py 2018-08-06 13:07:33 +0000
+++ bin/addons/account_override/invoice.py 2018-10-22 13:50:56 +0000
@@ -27,6 +27,7 @@
27from time import strftime27from time import strftime
28from tools.translate import _28from tools.translate import _
29from lxml import etree29from lxml import etree
30from datetime import datetime
30import re31import re
31import netsvc32import netsvc
3233
@@ -264,6 +265,141 @@
264 'is_merged_by_account': lambda *a: False,265 'is_merged_by_account': lambda *a: False,
265 }266 }
266267
268 def import_data_web(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None, filename=None,
269 display_all_errors=False, has_header=False):
270 """
271 Overrides the standard import_data_web method for account.invoice model:
272 - based on the 3 values for "cost_center_id / destination_id / funding_pool_id", creates a new AD at 100% for
273 each invoice line and add it to "datas"
274 - removes these 3 values that won't be used in the SI line
275 - adapts the "fields" list accordingly
276 - converts the dates from the format '%d/%m/%Y' to the standard one '%Y-%m-%d' so the checks on dates are correctly made
277 """
278 if context is None:
279 context = {}
280 new_data = datas
281 analytic_acc_obj = self.pool.get('account.analytic.account')
282 account_obj = self.pool.get('account.account')
283 analytic_distrib_obj = self.pool.get('analytic.distribution')
284 cc_distrib_line_obj = self.pool.get('cost.center.distribution.line')
285 fp_distrib_line_obj = self.pool.get('funding.pool.distribution.line')
286 curr_obj = self.pool.get('res.currency')
287 nb_ad_fields = 0
288 if 'invoice_line/cost_center_id' in fields:
289 nb_ad_fields += 1
290 if 'invoice_line/destination_id' in fields:
291 nb_ad_fields += 1
292 if 'invoice_line/funding_pool_id' in fields:
293 nb_ad_fields += 1
294 if nb_ad_fields:
295 if nb_ad_fields != 3:
296 raise osv.except_osv(_('Error'),
297 _('Either the Cost Center, the Destination, or the Funding Pool is missing.'))
298 # note: CC, dest and FP indexes always exist at this step
299 cc_index = fields.index('invoice_line/cost_center_id')
300 dest_index = fields.index('invoice_line/destination_id')
301 fp_index = fields.index('invoice_line/funding_pool_id')
302 si_line_name_index = 'invoice_line/name' in fields and fields.index('invoice_line/name')
303 si_journal_index = 'journal_id' in fields and fields.index('journal_id')
304 curr_index = 'currency_id' in fields and fields.index('currency_id')
305 account_index = 'invoice_line/account_id' in fields and fields.index('invoice_line/account_id')
306 doc_date_index = 'document_date' in fields and fields.index('document_date')
307 date_inv_index = 'date_invoice' in fields and fields.index('date_invoice')
308 new_data = []
309 curr = False
310 for data in datas:
311 cc_ids = []
312 dest_ids = []
313 fp_ids = []
314 distrib_id = ''
315 cc = len(data) > cc_index and data[cc_index].strip()
316 dest = len(data) > dest_index and data[dest_index].strip()
317 fp = len(data) > fp_index and data[fp_index].strip()
318 # check if details for SI line are filled in (based on the required field "name")
319 has_si_line = si_line_name_index is not False and len(data) > si_line_name_index and data[si_line_name_index].strip()
320 # process AD only for SI lines where at least one AD field has been filled in
321 # (otherwise no AD should be added to the line AND no error should be displayed)
322 if has_si_line and (cc or dest or fp): # at least one AD field has been filled in
323 if cc:
324 cc_dom = [('category', '=', 'OC'), ('type', '=', 'normal'), '|', ('code', '=ilike', cc), ('name', '=ilike', cc)]
325 cc_ids = analytic_acc_obj.search(cr, uid, cc_dom, order='id', limit=1, context=context)
326 if dest:
327 dest_dom = [('category', '=', 'DEST'), ('type', '=', 'normal'), '|', ('code', '=ilike', dest), ('name', '=ilike', dest)]
328 dest_ids = analytic_acc_obj.search(cr, uid, dest_dom, order='id', limit=1, context=context)
329 if fp:
330 fp_dom = [('category', '=', 'FUNDING'), ('type', '=', 'normal'), '|', ('code', '=ilike', fp), ('name', '=ilike', fp)]
331 fp_ids = analytic_acc_obj.search(cr, uid, fp_dom, order='id', limit=1, context=context)
332 if not cc_ids or not dest_ids or not fp_ids:
333 raise osv.except_osv(_('Error'), _('Either the Cost Center, the Destination, or the Funding Pool '
334 'was not found on the line %s.') % data)
335 else:
336 # create the Analytic Distribution
337 distrib_id = analytic_distrib_obj.create(cr, uid, {}, context=context)
338 # get the next currency to use IF NEED BE (cf for an SI with several lines the curr. is indicated on the first one only)
339 si_journal = si_journal_index is not False and len(data) > si_journal_index and data[si_journal_index].strip()
340 if si_journal: # first line of the SI
341 curr = curr_index is not False and len(data) > curr_index and data[curr_index].strip()
342 curr_ids = []
343 if curr: # must exist at least on the first imported line
344 curr_ids = curr_obj.search(cr, uid, [('name', '=ilike', curr)], limit=1, context=context)
345 if not curr_ids:
346 raise osv.except_osv(_('Error'),
347 _('The currency was not found for the line %s.') % data)
348 vals = {
349 'analytic_id': cc_ids[0], # analytic_id = Cost Center for the CC distrib line
350 'percentage': 100.0,
351 'distribution_id': distrib_id,
352 'currency_id': curr_ids[0],
353 'destination_id': dest_ids[0],
354 }
355 cc_distrib_line_obj.create(cr, uid, vals, context=context)
356 vals.update({
357 'analytic_id': fp_ids[0], # analytic_id = Funding Pool for the FP distrib line
358 'cost_center_id': cc_ids[0],
359 })
360 fp_distrib_line_obj.create(cr, uid, vals, context=context)
361 account_code = account_index is not False and len(data) > account_index and data[account_index].strip()
362 if account_code:
363 account_ids = account_obj.search(cr, uid, [('code', '=', account_code)], context=context, limit=1)
364 if not account_ids:
365 raise osv.except_osv(_('Error'), _('The account %s was not found on the line %s.') % (account_code, data))
366 parent_id = False # no distrib. at header level
367 distrib_state = analytic_distrib_obj._get_distribution_state(cr, uid, distrib_id, parent_id,
368 account_ids[0], context=context)
369 if distrib_state == 'invalid':
370 raise osv.except_osv(_('Error'), _('The analytic distribution is invalid on the line %s.') % data)
371 # create a new list with the new distrib id and without the old AD fields
372 # to be done also if no AD to ensure the size of each data list is always the same
373 i = 0
374 new_sub_list = []
375 for d in data: # loop on each value of the file line
376 if i not in [cc_index, dest_index, fp_index]:
377 if doc_date_index is not False and date_inv_index is not False and i in [doc_date_index, date_inv_index]:
378 # format the date from '%d/%m/%Y' to '%Y-%m-%d' so the checks on dates are correctly made
379 raw_date = len(data) > i and data[i].strip()
380 try:
381 new_date = raw_date and datetime.strptime(raw_date, '%d/%m/%Y').strftime('%Y-%m-%d') or ''
382 except ValueError:
383 new_date = raw_date
384 new_sub_list.append(new_date)
385 else:
386 new_sub_list.append(d)
387 i += 1
388 # add new field value
389 new_sub_list.append(distrib_id)
390 new_data.append(new_sub_list)
391
392 # remove old field names from fields
393 fields.remove('invoice_line/cost_center_id')
394 fields.remove('invoice_line/destination_id')
395 fields.remove('invoice_line/funding_pool_id')
396 # add new field
397 fields.append('invoice_line/analytic_distribution_id/.id') # .id = id in the database
398
399 return super(account_invoice, self).import_data_web(cr, uid, fields, new_data, mode=mode, current_module=current_module,
400 noupdate=noupdate, context=context, filename=filename,
401 display_all_errors=display_all_errors, has_header=has_header)
402
267 def onchange_company_id(self, cr, uid, ids, company_id, part_id, ctype, invoice_line, currency_id):403 def onchange_company_id(self, cr, uid, ids, company_id, part_id, ctype, invoice_line, currency_id):
268 """404 """
269 This is a method to redefine the journal_id domain with the current_instance taken into account405 This is a method to redefine the journal_id domain with the current_instance taken into account
@@ -1529,6 +1665,15 @@
15291665
1530 return res1666 return res
15311667
1668 def _get_fake_m2o(self, cr, uid, ids, field_name=None, arg=None, context=None):
1669 """
1670 Returns False for all ids
1671 """
1672 res = {}
1673 for i in ids:
1674 res[i] = False
1675 return res
1676
1532 _columns = {1677 _columns = {
1533 'line_number': fields.integer(string='Line Number'),1678 'line_number': fields.integer(string='Line Number'),
1534 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Account Computation')),1679 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Account Computation')),
@@ -1543,6 +1688,18 @@
1543 'reversed_invoice_line_id': fields.many2one('account.invoice.line', string='Reversed Invoice Line',1688 'reversed_invoice_line_id': fields.many2one('account.invoice.line', string='Reversed Invoice Line',
1544 help='Invoice line that has been reversed by this one through a '1689 help='Invoice line that has been reversed by this one through a '
1545 '"refund cancel" or "refund modify"'),1690 '"refund cancel" or "refund modify"'),
1691 'cost_center_id': fields.function(_get_fake_m2o, method=True, type='many2one', store=False,
1692 states={'draft': [('readonly', False)]}, # see def detect_data in unifield-web/addons/openerp/controllers/impex.py
1693 relation="account.analytic.account", string='Cost Center',
1694 help="Field used for import only"),
1695 'destination_id': fields.function(_get_fake_m2o, method=True, type='many2one', store=False,
1696 relation="account.analytic.account", string='Destination',
1697 states={'draft': [('readonly', False)]},
1698 help="Field used for import only"),
1699 'funding_pool_id': fields.function(_get_fake_m2o, method=True, type='many2one', store=False,
1700 relation="account.analytic.account", string='Funding Pool',
1701 states={'draft': [('readonly', False)]},
1702 help="Field used for import only"),
1546 }1703 }
15471704
1548 _defaults = {1705 _defaults = {
15491706
=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
--- bin/addons/msf_profile/i18n/fr_MF.po 2018-10-17 09:42:30 +0000
+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-10-22 13:50:56 +0000
@@ -38394,6 +38394,7 @@
38394#: field:hr.analytic.reallocation,funding_pool_id:038394#: field:hr.analytic.reallocation,funding_pool_id:0
38395#: field:hr.employee,funding_pool_id:038395#: field:hr.employee,funding_pool_id:0
38396#: field:hr.payroll.msf,funding_pool_id:038396#: field:hr.payroll.msf,funding_pool_id:0
38397#: field:account.invoice.line,funding_pool_id:0
38397#: report:addons/account/report/free_allocation_report.mako:20838398#: report:addons/account/report/free_allocation_report.mako:208
38398#, python-format38399#, python-format
38399msgid "Funding Pool"38400msgid "Funding Pool"
@@ -81948,6 +81949,7 @@
81948#: report:addons/sale/report/fo_allocation_report.mako:23181949#: report:addons/sale/report/fo_allocation_report.mako:231
81949#: report:sale.order.allocation.report:081950#: report:sale.order.allocation.report:0
81950#: field:purchase.report,cost_center_id:081951#: field:purchase.report,cost_center_id:0
81952#: field:account.invoice.line,cost_center_id:0
81951#: code:addons/register_accounting/wizard/wizard_register_import.py:57081953#: code:addons/register_accounting/wizard/wizard_register_import.py:570
81952#: report:addons/account/report/free_allocation_report.mako:20581954#: report:addons/account/report/free_allocation_report.mako:205
81953#, python-format81955#, python-format
@@ -96141,6 +96143,7 @@
96141#: field:purchase.order.line.allocation.report,destination_id:096143#: field:purchase.order.line.allocation.report,destination_id:0
96142#: code:addons/register_accounting/wizard/wizard_register_import.py:55896144#: code:addons/register_accounting/wizard/wizard_register_import.py:558
96143#: field:wizard.register.import.lines,destination_id:096145#: field:wizard.register.import.lines,destination_id:0
96146#: field:account.invoice.line,destination_id:0
96144#: report:addons/sale/report/fo_allocation_report.mako:22896147#: report:addons/sale/report/fo_allocation_report.mako:228
96145#: report:sale.order.allocation.report:096148#: report:sale.order.allocation.report:0
96146#: field:sale.order.line.cancel,partner_id:096149#: field:sale.order.line.cancel,partner_id:0
@@ -101952,6 +101955,7 @@
101952#: field:account.commitment.line,commit_number:0101955#: field:account.commitment.line,commit_number:0
101953msgid "Commitment Voucher Number"101956msgid "Commitment Voucher Number"
101954msgstr "Numéro du Bon d'Engagement"101957msgstr "Numéro du Bon d'Engagement"
101958<<<<<<< TREE
101955101959
101956#. module: account_mcdb101960#. module: account_mcdb
101957#: code:addons/account_mcdb/account_mcdb.py:1494101961#: code:addons/account_mcdb/account_mcdb.py:1494
@@ -101975,3 +101979,42 @@
101975#: code:addons/account_mcdb/account_mcdb.py:1276101979#: code:addons/account_mcdb/account_mcdb.py:1276
101976msgid "Related entries"101980msgid "Related entries"
101977msgstr "Ecritures associées"101981msgstr "Ecritures associées"
101982=======
101983
101984#. module: account_override
101985#: code:addons/account_override/invoice.py:339
101986#, python-format
101987msgid "The currency was not found for the line %s."
101988msgstr "La devise n'a pas été trouvée pour la ligne %s."
101989
101990#. module: account_override
101991#: code:addons/account_override/invoice.py:293
101992#, python-format
101993msgid "Either the Cost Center, the Destination, or the Funding Pool is missing."
101994msgstr "Il manque le Centre de Coût, la Destination, ou le Funding Pool."
101995
101996#. module: account_override
101997#: code:addons/account_override/invoice.py:325
101998#, python-format
101999msgid "Either the Cost Center, the Destination, or the Funding Pool was not found on the line %s."
102000msgstr "Le Centre de Coût, la Destination, ou le Funding Pool n'a pas été trouvé sur la ligne %s."
102001
102002#. module: account_override
102003#: code:addons/account_override/invoice.py:365
102004#, python-format
102005msgid "The account %s was not found on the line %s."
102006msgstr "Le compte %s n'a pas été trouvé sur la ligne %s."
102007
102008#. module: account_override
102009#: code:addons/account_override/invoice.py:370
102010#, python-format
102011msgid "The analytic distribution is invalid on the line %s."
102012msgstr "La distribution analytique est invalide sur la ligne %s."
102013
102014#. module: account_override
102015#: help:account.invoice.line,cost_center_id:0
102016#: help:account.invoice.line,destination_id:0
102017#: help:account.invoice.line,funding_pool_id:0
102018msgid "Field used for import only"
102019msgstr "Champ utilisé pour l'import uniquement"
102020>>>>>>> MERGE-SOURCE
101978102021
=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py 2018-08-14 14:10:58 +0000
+++ bin/osv/orm.py 2018-10-22 13:50:56 +0000
@@ -1122,6 +1122,16 @@
1122 self._parent_store_compute(cr)1122 self._parent_store_compute(cr)
1123 return (position, 0, 0, 0)1123 return (position, 0, 0, 0)
11241124
1125 def import_data_web(self, cr, uid, fields, datas, mode='init', current_module='', noupdate=False, context=None,
1126 filename=None, display_all_errors=False, has_header=False):
1127 """
1128 Import data method called at import from web ONLY (contrary to the import_data method also used for sync msgs).
1129 Call import_data by default but can be overridden if needed.
1130 """
1131 return super(orm, self).import_data(cr, uid, fields, datas, mode=mode, current_module=current_module,
1132 noupdate=noupdate, context=context, filename=filename,
1133 display_all_errors=display_all_errors, has_header=has_header)
1134
1125 def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):1135 def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
1126 """1136 """
1127 Read records with given ids with the given fields1137 Read records with given ids with the given fields

Subscribers

People subscribed via source and target branches