Merge lp:~dorian-kemps/unifield-server/US-2445 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5527
Proposed branch: lp:~dorian-kemps/unifield-server/US-2445
Merge into: lp:unifield-server
Diff against target: 135 lines (+63/-1)
4 files modified
bin/addons/msf_doc_import/initial_stock_inventory.py (+11/-0)
bin/addons/msf_profile/i18n/fr_MF.po (+6/-0)
bin/addons/specific_rules/stock_view.xml (+1/-1)
bin/addons/stock/stock.py (+45/-0)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-2445
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+371099@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_doc_import/initial_stock_inventory.py'
2--- bin/addons/msf_doc_import/initial_stock_inventory.py 2019-07-30 09:13:43 +0000
3+++ bin/addons/msf_doc_import/initial_stock_inventory.py 2019-10-22 09:01:56 +0000
4@@ -635,6 +635,7 @@
5 location_obj = self.pool.get('stock.location')
6 obj_data = self.pool.get('ir.model.data')
7
8+
9 vals = {}
10 vals['inventory_line_id'] = []
11 msg_to_return = _("All lines successfully imported")
12@@ -647,6 +648,7 @@
13 product_non_stockable_cache = {}
14 product_error = []
15 no_product_error = []
16+ wrong_location = []
17
18 fileobj = SpreadsheetXML(xmlstring=base64.decodestring(obj.file_to_import))
19
20@@ -751,6 +753,10 @@
21 location_not_found = True
22 else:
23 location_id = loc_ids[0]
24+ loc = location_obj.browse(cr, uid, location_id, fields_to_fetch=['initial_stock_inv_display', 'usage'],
25+ context=context)
26+ if not loc.initial_stock_inv_display or loc.usage != 'internal':
27+ wrong_location.append(_('Line #%s: The location "%s" is not allowed') % (line_num, location_name))
28 except Exception:
29 location_id = False
30
31@@ -903,6 +909,11 @@
32 len(no_product_error) > 1 and 's' or '',
33 ' / '.join(tools.ustr(x) for x in no_product_error)),
34 )
35+ if wrong_location:
36+ raise osv.except_osv(
37+ _('Error'),
38+ '\n'.join(wrong_location)
39+ )
40
41 # write order line on Inventory
42 vals.update({'file_to_import': False})
43
44=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
45--- bin/addons/msf_profile/i18n/fr_MF.po 2019-10-18 15:58:30 +0000
46+++ bin/addons/msf_profile/i18n/fr_MF.po 2019-10-22 09:01:56 +0000
47@@ -106911,6 +106911,12 @@
48 msgid "Stop report"
49 msgstr "ArrĂȘter le rapport"
50
51+#. module: msf_doc_import
52+#: code:addons/msf_doc_import/initial_stock_inventory.py:648
53+#, python-format
54+msgid "Line #%s: The location \"%s\" is not allowed"
55+msgstr "Ligne #%s: La Zone \"%s\" n'est pas autorisée"
56+
57 #. module: stock
58 #: code:addons/stock/stock.py:1780
59 #, python-format
60
61=== modified file 'bin/addons/specific_rules/stock_view.xml'
62--- bin/addons/specific_rules/stock_view.xml 2016-05-23 12:40:15 +0000
63+++ bin/addons/specific_rules/stock_view.xml 2019-10-22 09:01:56 +0000
64@@ -51,7 +51,7 @@
65 on_change="product_change(product_id, location_id, 'product_id', True, prod_lot_id)" />
66 <field name="average_cost" />
67 <field name="currency_id" />
68- <field name="location_id" domain="[('usage', '=', 'internal')]" on_change="product_change(product_id, location_id, 'location_id', prod_lot_id)" required="True" />
69+ <field name="location_id" domain="['&amp;', ('usage', '=', 'internal'), ('initial_stock_inv_display', '!=', False)]" on_change="product_change(product_id, location_id, 'location_id', prod_lot_id)" required="True" />
70 <field name="prodlot_name"
71 attrs="{'required': [('hidden_batch_management_mandatory', '=', True)], 'readonly': [('hidden_batch_management_mandatory', '=', False)]}" />
72 <field name="expiry_date"
73
74=== modified file 'bin/addons/stock/stock.py'
75--- bin/addons/stock/stock.py 2019-09-25 14:20:09 +0000
76+++ bin/addons/stock/stock.py 2019-10-22 09:01:56 +0000
77@@ -155,6 +155,50 @@
78 result[loc_id][f] += amount
79 return result
80
81+ def _get_loc_ids_to_hide(self, cr, uid, ids, context=None):
82+ if context is None:
83+ context = {}
84+
85+ loc_to_hide = [
86+ 'msf_cross_docking_stock_location_input',
87+ 'stock_stock_location_stock',
88+ 'stock_stock_location_output',
89+ 'msf_outgoing_stock_location_packing',
90+ 'msf_outgoing_stock_location_dispatch',
91+ 'msf_outgoing_stock_location_distribution',
92+ 'stock_location_quarantine_view',
93+ ]
94+
95+ data_domain = [('model', '=', 'stock.location'), ('name', 'in', loc_to_hide)]
96+ if ids:
97+ data_domain.append(('res_id', 'in', ids))
98+ loc_ids_to_hide = self.pool.get('ir.model.data').search(cr, uid, data_domain, context=context)
99+
100+ return [x.get('res_id') for x in self.pool.get('ir.model.data').read(cr, uid, loc_ids_to_hide, ['res_id'], context=context)]
101+
102+ def _get_initial_stock_inv_display(self, cr, uid, ids, name, args, context=None):
103+ if context is None:
104+ context = {}
105+
106+ res = {}
107+
108+ loc_ids_to_hide = self._get_loc_ids_to_hide(cr, uid, ids, context=context)
109+ for _id in ids:
110+ res[_id] = True
111+ if _id in loc_ids_to_hide:
112+ res[_id] = False
113+
114+ return res
115+
116+ def _search_initial_stock_inv_display(self, cr, uid, obj, name, args, context=None):
117+ '''
118+ Returns locations allowed in the Initial Stock Inventory
119+ '''
120+ if context is None:
121+ context = {}
122+
123+ return [('id', 'not in', self._get_loc_ids_to_hide(cr, uid, [], context=context))]
124+
125 _columns = {
126 'name': fields.char('Location Name', size=64, required=True, translate=True),
127 'active': fields.boolean('Active', help="By unchecking the active field, you may hide a location without deleting it."),
128@@ -214,6 +258,7 @@
129 'scrap_location': fields.boolean('Scrap Location', help='Check this box to allow using this location to put scrapped/damaged goods.'),
130 'valuation_in_account_id': fields.many2one('account.account', 'Stock Input Account',domain = [('type','=','other')], help='This account will be used to value stock moves that have this location as destination, instead of the stock output account from the product.'),
131 'valuation_out_account_id': fields.many2one('account.account', 'Stock Output Account',domain = [('type','=','other')], help='This account will be used to value stock moves that have this location as source, instead of the stock input account from the product.'),
132+ 'initial_stock_inv_display': fields.function(_get_initial_stock_inv_display, method=True, type='boolean', store=False, fnct_search=_search_initial_stock_inv_display, string='Display in Initial stock inventory', readonly=True),
133 }
134 _defaults = {
135 'active': True,

Subscribers

People subscribed via source and target branches