Merge lp:~unifield-team/unifield-server/uf2-1-1rc1-fixes-qt into lp:unifield-server
- uf2-1-1rc1-fixes-qt
- Merge into trunk
Proposed by
Quentin THEURET @Amaris
Status: | Merged |
---|---|
Merged at revision: | 3687 |
Proposed branch: | lp:~unifield-team/unifield-server/uf2-1-1rc1-fixes-qt |
Merge into: | lp:unifield-server |
Diff against target: |
310 lines (+141/-16) 7 files modified
bin/addons/procurement_request/procurement_request.py (+13/-0) bin/addons/product_attributes/product_attributes.py (+67/-0) bin/addons/product_attributes/product_attributes_view.xml (+1/-1) bin/addons/sale/sale_view.xml (+1/-1) bin/addons/sale_override/sale.py (+36/-11) bin/addons/supplier_catalogue/supplier_catalogue.py (+20/-0) bin/addons/supplier_catalogue/supplier_catalogue_view.xml (+3/-3) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/uf2-1-1rc1-fixes-qt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+290609@code.launchpad.net |
Commit message
Description of the change
Fix for issues raised during UF2-1-1 dev tests.
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/procurement_request/procurement_request.py' |
2 | --- bin/addons/procurement_request/procurement_request.py 2016-03-24 08:35:00 +0000 |
3 | +++ bin/addons/procurement_request/procurement_request.py 2016-03-31 13:27:28 +0000 |
4 | @@ -162,6 +162,8 @@ |
5 | """ |
6 | Check if a same record already exist. If not, create a new record. |
7 | """ |
8 | + mem_obj = self.pool.get('procurement.request.sourcing.document.mem') |
9 | + |
10 | if context is None: |
11 | context = {} |
12 | |
13 | @@ -183,6 +185,7 @@ |
14 | if vals.get('line_ids'): |
15 | create_data['sourcing_lines'] = [(6, 0, (vals.get('line_ids'),))] |
16 | self.create(cr, uid, create_data, context=context) |
17 | + mem_obj.create(cr, uid, create_data, context=context) |
18 | elif vals.get('line_ids'): |
19 | for chk in self.browse(cr, uid, chk_ids, context=context): |
20 | sourcing_lines = [vals.get('line_ids')] |
21 | @@ -198,11 +201,21 @@ |
22 | 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
23 | }, context=context) |
24 | |
25 | + if self._name != 'procurement.request.sourcing.document.mem': |
26 | + mem_obj.chk_create(cr, uid, vals, context=context) |
27 | + |
28 | return True |
29 | |
30 | procurement_request_sourcing_document() |
31 | |
32 | |
33 | +class procurement_request_sourcing_document_mem(osv.osv_memory): |
34 | + _name = 'procurement.request.sourcing.document.mem' |
35 | + _inherit = 'procurement.request.sourcing.document' |
36 | + |
37 | +procurement_request_sourcing_document_mem() |
38 | + |
39 | + |
40 | class procurement_request(osv.osv): |
41 | _name = 'sale.order' |
42 | _inherit = 'sale.order' |
43 | |
44 | === modified file 'bin/addons/product_attributes/product_attributes.py' |
45 | --- bin/addons/product_attributes/product_attributes.py 2016-03-29 06:09:11 +0000 |
46 | +++ bin/addons/product_attributes/product_attributes.py 2016-03-31 13:27:28 +0000 |
47 | @@ -1114,6 +1114,39 @@ |
48 | # (_check_uom_category, _('There are some stock moves with this product on the system. So you should keep the same UoM category than these stock moves.'), ['uom_id', 'uom_po_id']), |
49 | # ] |
50 | |
51 | + def change_soq_quantity(self, cr, uid, ids, soq, uom_id, context=None): |
52 | + """ |
53 | + When the SoQ quantity is changed, check if the new quantity is consistent |
54 | + with rounding value of the product UoM |
55 | + :param cr: Cursor to the database |
56 | + :param uid: ID of the res.users that calls the method |
57 | + :param ids: List of ID of product.product on which the SoQ quantity is changed |
58 | + :param soq: New value for SoQ Quantity |
59 | + :param uom_id: ID of the product.uom linked to the product |
60 | + :param context: Context of the call |
61 | + :return: A dictionary that contains a warning message and the SoQ quantity |
62 | + rounded with the UoM rounding value |
63 | + """ |
64 | + uom_obj = self.pool.get('product.uom') |
65 | + |
66 | + if context is None: |
67 | + context = {} |
68 | + |
69 | + if not soq or not uom_id: |
70 | + return {} |
71 | + |
72 | + res = {} |
73 | + rd_soq = uom_obj._compute_qty(cr, uid, uom_id, soq, uom_id) |
74 | + if rd_soq != soq: |
75 | + res['warning'] = { |
76 | + 'title': _('Warning'), |
77 | + 'message': _('''SoQ quantity value (%s) is not consistent with UoM rounding value. |
78 | + The SoQ quantity has been automatically rounded to consistent value (%s)''') % (soq, rd_soq), |
79 | + } |
80 | + |
81 | + res['value'] = {'soq_quantity': rd_soq} |
82 | + return res |
83 | + |
84 | def _on_change_restriction_error(self, cr, uid, ids, *args, **kwargs): |
85 | ''' |
86 | Update the message on on_change of product |
87 | @@ -1214,6 +1247,14 @@ |
88 | return res |
89 | |
90 | def write(self, cr, uid, ids, vals, context=None): |
91 | + data_obj = self.pool.get('ir.model.data') |
92 | + |
93 | + if context is None: |
94 | + context = {} |
95 | + |
96 | + if isinstance(ids, (int, long)): |
97 | + ids = [ids] |
98 | + |
99 | if 'batch_management' in vals: |
100 | vals['track_production'] = vals['batch_management'] |
101 | vals['track_incoming'] = vals['batch_management'] |
102 | @@ -1253,6 +1294,22 @@ |
103 | vals['heat_sensitive_item'] = heat2_id |
104 | vals.update(self.onchange_heat(cr, uid, ids, vals['heat_sensitive_item'], context=context).get('value', {})) |
105 | |
106 | + if context.get('sync_update_execution') and not context.get('bypass_sync_update', False): |
107 | +# stopped_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'status_3')[1] |
108 | +# phase_out_status = data_obj.get_object_reference(cr, uid, 'product_attributes', 'status_2')[1] |
109 | + if vals.get('active', None) is False: |
110 | + if self.deactivate_product(cr, uid, ids, context=context) is not True: |
111 | + vals.update({ |
112 | + 'active': True, |
113 | +# 'state': stopped_status, |
114 | + }) |
115 | +# elif vals.get('active', None) is True and vals.get('state') == stopped_status: |
116 | + elif vals.get('active', None) is True: |
117 | + vals.update({ |
118 | + 'active': True, |
119 | +# 'state': phase_out_status, |
120 | + }) |
121 | + |
122 | if 'narcotic' in vals or 'controlled_substance' in vals: |
123 | if vals.get('narcotic') == True or tools.ustr(vals.get('controlled_substance', '')) == 'True': |
124 | vals['controlled_substance'] = 'True' |
125 | @@ -1295,6 +1352,7 @@ |
126 | if isinstance(ids, (int, long)): |
127 | ids = [ids] |
128 | |
129 | + data_obj = self.pool.get('ir.model.data') |
130 | location_obj = self.pool.get('stock.location') |
131 | po_line_obj = self.pool.get('purchase.order.line') |
132 | tender_line_obj = self.pool.get('tender.line') |
133 | @@ -1528,6 +1586,13 @@ |
134 | 'doc_ref': invoice.invoice_id.number, |
135 | 'doc_id': invoice.invoice_id.id}, context=context) |
136 | |
137 | + if context.get('sync_update_execution', False): |
138 | + context['bypass_sync_update'] = True |
139 | + self.write(cr, uid, product.id, { |
140 | + 'active': True, |
141 | +# 'state': data_obj.get_object_reference(cr, uid, 'product_attributes', 'status_3')[1], |
142 | + }, context=context) |
143 | + |
144 | return {'type': 'ir.actions.act_window', |
145 | 'res_model': 'product.deactivation.error', |
146 | 'view_type': 'form', |
147 | @@ -1573,6 +1638,8 @@ |
148 | orderpoint_line_obj.unlink(cr, uid, [orderpoint_line.id], |
149 | context=context) |
150 | |
151 | + if context.get('sync_update_execution', False): |
152 | + context['bypass_sync_update'] = True |
153 | self.write(cr, uid, ids, {'active': False}, context=context) |
154 | |
155 | return True |
156 | |
157 | === modified file 'bin/addons/product_attributes/product_attributes_view.xml' |
158 | --- bin/addons/product_attributes/product_attributes_view.xml 2016-03-24 16:43:45 +0000 |
159 | +++ bin/addons/product_attributes/product_attributes_view.xml 2016-03-31 13:27:28 +0000 |
160 | @@ -122,7 +122,7 @@ |
161 | <field name="perishable"/> |
162 | <field name="batch_management" on_change="onchange_batch_management(batch_management)" /> |
163 | <separator string="UOM" colspan="2"/> |
164 | - <field name="soq_quantity" /> |
165 | + <field name="soq_quantity" on_change="change_soq_quantity(soq_quantity, uom_id)" /> |
166 | <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" domain="[('compatible_product_id', '=', active_id)]" /> |
167 | <field name="uom_po_id" string="Exchangeable Unit of Measure" domain="[('compatible_product_id', '=', active_id)]" /> |
168 | </group> |
169 | |
170 | === modified file 'bin/addons/sale/sale_view.xml' |
171 | --- bin/addons/sale/sale_view.xml 2014-03-12 10:01:11 +0000 |
172 | +++ bin/addons/sale/sale_view.xml 2016-03-31 13:27:28 +0000 |
173 | @@ -128,7 +128,7 @@ |
174 | <field colspan="4" |
175 | context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom" |
176 | name="product_id" |
177 | - on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging, parent.fiscal_position, False)" |
178 | + on_change="product_id_on_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging, parent.fiscal_position, False, context)" |
179 | /> |
180 | <field |
181 | context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom" |
182 | |
183 | === modified file 'bin/addons/sale_override/sale.py' |
184 | --- bin/addons/sale_override/sale.py 2016-03-24 08:35:00 +0000 |
185 | +++ bin/addons/sale_override/sale.py 2016-03-31 13:27:28 +0000 |
186 | @@ -193,6 +193,7 @@ |
187 | order_obj = self.pool.get('sale.order') |
188 | sol_obj = self.pool.get('sale.order.line') |
189 | src_doc_obj = self.pool.get('procurement.request.sourcing.document') |
190 | + src_doc_mem = self.pool.get('procurement.request.sourcing.document.mem') |
191 | |
192 | if context is None: |
193 | context = {} |
194 | @@ -223,19 +224,43 @@ |
195 | ('order_id', 'in', order_ids), |
196 | ], count=True, order='NO_ORDER', context=context) |
197 | |
198 | - # Get number of sourced lines by type (MTS or MTO) |
199 | - cr.execute(''' |
200 | - SELECT count(*) AS nb_line, sol.type AS type |
201 | - FROM sale_order_line sol |
202 | - LEFT JOIN sale_line_sourcing_doc_rel slsdr |
203 | - ON slsdr.sale_line_id = sol.id |
204 | - WHERE |
205 | - slsdr.document_id IN %s |
206 | - GROUP BY sol.type |
207 | - ''', (tuple(src_doc_ids),)) |
208 | - res = cr.dictfetchall() |
209 | mem_fsl_nb = 0 |
210 | mem_ool_nb = 0 |
211 | + |
212 | + mem_sol_ids = [] |
213 | + src_doc_mem_ids = src_doc_mem.search(cr, uid, [ |
214 | + ('order_id', 'in', order_ids), |
215 | + ], context=context) |
216 | + for mem_doc in src_doc_mem.browse(cr, uid, src_doc_mem_ids, context=context): |
217 | + for l in mem_doc.sourcing_lines: |
218 | + if l.id not in mem_sol_ids: |
219 | + mem_sol_ids.append(l.id) |
220 | + if l.type == 'make_to_stock': |
221 | + mem_fsl_nb += 1 |
222 | + elif l.type == 'make_to_order': |
223 | + mem_ool_nb += 1 |
224 | + |
225 | + # Get number of sourced lines by type (MTS or MTO) |
226 | + res = [] |
227 | + if src_doc_ids: |
228 | + where_sql = '' |
229 | + where_params = [tuple(src_doc_ids)] |
230 | + if mem_sol_ids: |
231 | + where_sql = ' AND sol.id NOT IN %s' |
232 | + where_params.append(tuple(mem_sol_ids)) |
233 | + sql = ''' |
234 | + SELECT count(*) AS nb_line, sol.type AS type |
235 | + FROM sale_order_line sol |
236 | + LEFT JOIN sale_line_sourcing_doc_rel slsdr |
237 | + ON slsdr.sale_line_id = sol.id |
238 | + WHERE |
239 | + slsdr.document_id IN %%s |
240 | + %s |
241 | + GROUP BY sol.type |
242 | + ''' % where_sql |
243 | + cr.execute(sql, where_params) |
244 | + res = cr.dictfetchall() |
245 | + |
246 | for r in res: |
247 | if r.get('type') == 'make_to_stock': |
248 | mem_fsl_nb += r.get('nb_line', 0) |
249 | |
250 | === modified file 'bin/addons/supplier_catalogue/supplier_catalogue.py' |
251 | --- bin/addons/supplier_catalogue/supplier_catalogue.py 2016-03-17 16:40:58 +0000 |
252 | +++ bin/addons/supplier_catalogue/supplier_catalogue.py 2016-03-31 13:27:28 +0000 |
253 | @@ -1012,6 +1012,26 @@ |
254 | |
255 | return res |
256 | |
257 | + def change_soq_quantity(self, cr, uid, ids, soq, uom_id, context=None): |
258 | + """ |
259 | + When the SoQ quantity is changed, check if the new quantity is consistent |
260 | + with rounding value of the UoM of the catalogue line. |
261 | + :param cr: Cursor to the database |
262 | + :param uid: ID of the res.users that calls the method |
263 | + :param ids: List of ID of product.product on which the SoQ quantity is changed |
264 | + :param soq: New value for SoQ Quantity |
265 | + :param uom_id: ID of the product.uom linked to the product |
266 | + :param context: Context of the call |
267 | + :return: A dictionary that contains a warning message and the SoQ quantity |
268 | + rounded with the UoM rounding value |
269 | + """ |
270 | + res = self.pool.get('product.product').change_soq_quantity(cr, uid, [], soq, uom_id, context=context) |
271 | + |
272 | + if res.get('value', {}).get('soq_quantity', False): |
273 | + res['value']['rounding'] = res['value'].pop('soq_quantity') |
274 | + |
275 | + return res |
276 | + |
277 | def onChangeSearchNomenclature(self, cr, uid, line_id, position, line_type, nomen_manda_0, nomen_manda_1, nomen_manda_2, nomen_manda_3, num=True, context=None): |
278 | ''' |
279 | Method to fill nomenclature fields in search view |
280 | |
281 | === modified file 'bin/addons/supplier_catalogue/supplier_catalogue_view.xml' |
282 | --- bin/addons/supplier_catalogue/supplier_catalogue_view.xml 2014-09-29 12:45:23 +0000 |
283 | +++ bin/addons/supplier_catalogue/supplier_catalogue_view.xml 2016-03-31 13:27:28 +0000 |
284 | @@ -167,7 +167,7 @@ |
285 | <field name="line_uom_id" /> |
286 | <field name="min_qty" /> |
287 | <field name="unit_price" /> |
288 | - <field name="rounding" /> |
289 | + <field name="rounding" on_change="change_soq_quantity(rounding, line_uom_id)" /> |
290 | <field name="min_order_qty" /> |
291 | <field name="comment" /> |
292 | </form> |
293 | @@ -188,7 +188,7 @@ |
294 | domain="[('uom_by_product', '=', product_id)]" /> |
295 | <field name="min_qty" on_change="change_uom_qty(line_uom_id, min_qty, min_order_qty)" /> |
296 | <field name="unit_price" /> |
297 | - <field name="rounding" /> |
298 | + <field name="rounding" on_change="change_soq_quantity(rounding, line_uom_id)" /> |
299 | <field name="min_order_qty" on_change="change_uom_qty(line_uom_id, min_qty, min_order_qty)" /> |
300 | <field name="comment" /> |
301 | <field name="to_correct_ok" invisible="1"/> |
302 | @@ -210,7 +210,7 @@ |
303 | <field name="line_uom_id" /> |
304 | <field name="min_qty" /> |
305 | <field name="unit_price" /> |
306 | - <field name="rounding" /> |
307 | + <field name="rounding" on_change="change_soq_quantity(rounding, line_uom_id)" /> |
308 | <field name="min_order_qty" /> |
309 | <field name="comment" /> |
310 | </tree> |