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

Proposed by jftempo
Status: Merged
Merged at revision: 5937
Proposed branch: lp:~dorian-kemps/unifield-server/US-8040
Merge into: lp:unifield-server
Diff against target: 137 lines (+31/-18)
4 files modified
bin/addons/specific_rules/report/report_stock_inventory.py (+26/-13)
bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako (+1/-1)
bin/addons/specific_rules/report/report_stock_inventory_view.xml (+2/-2)
bin/addons/specific_rules/report/report_stock_inventory_xls.mako (+2/-2)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-8040
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+396837@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/specific_rules/report/report_stock_inventory.py'
--- bin/addons/specific_rules/report/report_stock_inventory.py 2019-03-29 08:46:15 +0000
+++ bin/addons/specific_rules/report/report_stock_inventory.py 2021-02-09 15:57:38 +0000
@@ -311,9 +311,10 @@
311 with_zero = False311 with_zero = False
312 values = {'state': 'done'}312 values = {'state': 'done'}
313 cond = ['state=%(state)s']313 cond = ['state=%(state)s']
314 having = ['having round(sum(product_qty), 6) != 0']
314315
315 having = "having round(sum(product_qty), 6) != 0"
316 full_prod_list = []316 full_prod_list = []
317 batch_list = []
317318
318 cond.append('location_id in %(location_ids)s')319 cond.append('location_id in %(location_ids)s')
319 if report.location_id:320 if report.location_id:
@@ -323,8 +324,8 @@
323324
324 if report.product_id:325 if report.product_id:
325 cond.append('product_id in %(product_ids)s')326 cond.append('product_id in %(product_ids)s')
327 full_prod_list = [report.product_id.id]
326 values['product_ids'] = (report.product_id.id,)328 values['product_ids'] = (report.product_id.id,)
327 with_zero = True
328 elif report.product_list_id:329 elif report.product_list_id:
329 cond.append('product_id in %(product_ids)s')330 cond.append('product_id in %(product_ids)s')
330 full_prod_list = self.pool.get('product.product').search(self.cr, self.uid, [('list_ids', '=', report.product_list_id.id)], context=self.localcontext)331 full_prod_list = self.pool.get('product.product').search(self.cr, self.uid, [('list_ids', '=', report.product_list_id.id)], context=self.localcontext)
@@ -345,29 +346,41 @@
345 cond.append('date<%(stock_level_date)s')346 cond.append('date<%(stock_level_date)s')
346 values['stock_level_date'] = '%s 23:59:59' % report.stock_level_date347 values['stock_level_date'] = '%s 23:59:59' % report.stock_level_date
347348
348 if (not report.product_id or not report.product_list_id or not report.prodlot_id or not report.expiry_date) \349 if (not report.product_list_id or not report.prodlot_id or not report.expiry_date) and report.display_0:
349 and report.display_0:
350 with_zero = True
351 to_date = datetime.now()350 to_date = datetime.now()
352 if report.stock_level_date:351 if report.stock_level_date:
353 to_date = datetime.strptime(values['stock_level_date'], '%Y-%m-%d %H:%M:%S')352 to_date = datetime.strptime(values['stock_level_date'], '%Y-%m-%d %H:%M:%S')
354 from_date = (to_date + relativedelta(months=-int(report.in_last_x_months))).strftime('%Y-%m-%d 00:00:00')353 from_date = (to_date + relativedelta(months=-int(report.in_last_x_months))).strftime('%Y-%m-%d 00:00:00')
355354 with_zero = True
356 self.cr.execute("""select distinct(product_id) from stock_move 355
357 where state='done' and (location_id in %s or location_dest_id in %s) and date >= %s and date <= %s""",356 plus_bn, w_prod = "", ""
357 if report.product_id:
358 plus_bn = ", prodlot_id"
359 w_prod = " product_id = %s AND" % report.product_id.id
360
361 self.cr.execute("""select distinct product_id""" + plus_bn + """ from stock_move
362 where""" + w_prod + """ state='done' and (location_id in %s or location_dest_id in %s) and date >= %s and date <= %s""",
358 (values['location_ids'], values['location_ids'], from_date, to_date))363 (values['location_ids'], values['location_ids'], from_date, to_date))
359 for x in self.cr.fetchall():364 for x in self.cr.fetchall():
360 full_prod_list.append(x[0])365 full_prod_list.append(x[0])
366 if report.product_id and x[1]:
367 batch_list.append(x[1])
361368
362 if with_zero:369 if report.product_id and report.display_0:
363 having = ""370 if batch_list:
371 having.append('or prodlot_id in %(batch_list)s')
372 values['batch_list'] = tuple(batch_list)
373 else:
374 having.append('or prodlot_id is NULL')
375 elif with_zero:
376 having = []
364377
365 self.cr.execute("""select sum(product_qty), product_id, expired_date, prodlot_id, location_id378 self.cr.execute("""select sum(product_qty), product_id, expired_date, prodlot_id, location_id
366 from report_stock_inventory379 from report_stock_inventory
367 where380 where
368 """+' and '.join(cond)+"""381 """ + ' and '.join(cond) + """
369 group by product_id, expired_date, uom_id, prodlot_id, location_id382 group by product_id, expired_date, uom_id, prodlot_id, location_id
370 """ + having, values)383 """ + ' '.join(having), values)
371384
372 all_product_ids = {}385 all_product_ids = {}
373 all_bn_ids = {}386 all_bn_ids = {}
@@ -442,7 +455,7 @@
442 'product_name': product_data[product_id].name,455 'product_name': product_data[product_id].name,
443 'uom': product_data[product_id].uom_id.name,456 'uom': product_data[product_id].uom_id.name,
444 'sum_value': cost_price * rounded_qty,457 'sum_value': cost_price * rounded_qty,
445 'with_product_list': with_zero,458 'with_zero': with_zero,
446 'lines': {},459 'lines': {},
447 }460 }
448 total_value += final_result[product_code]['sum_value']461 total_value += final_result[product_code]['sum_value']
449462
=== modified file 'bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako'
--- bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako 2019-02-25 09:43:25 +0000
+++ bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako 2021-02-09 15:57:38 +0000
@@ -230,7 +230,7 @@
230230
231 % for prd in lines:231 % for prd in lines:
232 % for line in prd['lines'].itervalues():232 % for line in prd['lines'].itervalues():
233 % if line['qty'] or prd['with_product_list']:233 % if line['qty'] or prd['with_zero']:
234 <Row ss:AutoFitHeight="1">234 <Row ss:AutoFitHeight="1">
235 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>235 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>
236 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>236 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>
237237
=== modified file 'bin/addons/specific_rules/report/report_stock_inventory_view.xml'
--- bin/addons/specific_rules/report/report_stock_inventory_view.xml 2019-03-18 16:21:17 +0000
+++ bin/addons/specific_rules/report/report_stock_inventory_view.xml 2021-02-09 15:57:38 +0000
@@ -55,9 +55,9 @@
55 domain="[('src_product_id', '=', product_id)]" attrs="{'readonly': ['|', ('state', '!=', 'draft'), ('product_list_id', '!=', False)]}" />55 domain="[('src_product_id', '=', product_id)]" attrs="{'readonly': ['|', ('state', '!=', 'draft'), ('product_list_id', '!=', False)]}" />
56 <field name="expiry_date" attrs="{'readonly': ['|', ('prodlot_id', '!=', False), ('state', '!=', 'draft')]}" />56 <field name="expiry_date" attrs="{'readonly': ['|', ('prodlot_id', '!=', False), ('state', '!=', 'draft')]}" />
57 <newline/>57 <newline/>
58 <field name="display_0" attrs="{'invisible': ['|', '|', '|', ('product_id', '!=', False), ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False)]}" />58 <field name="display_0" attrs="{'invisible': ['|', '|', ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False)]}" />
59 <field name="in_last_x_months" nolabel="1" colspan="2"59 <field name="in_last_x_months" nolabel="1" colspan="2"
60 attrs="{'readonly': [('state', '!=', 'draft')], 'invisible': ['|', '|', '|', '|', ('product_id', '!=', False), ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False), ('display_0', '=', False)], 'required': [('display_0', '=', True), ('state', '=', 'draft')]}" />60 attrs="{'readonly': [('state', '!=', 'draft')], 'invisible': ['|', '|', '|', ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False), ('display_0', '=', False)], 'required': [('display_0', '=', True), ('state', '=', 'draft')]}" />
6161
62 <separator colspan="4" string="Actions" />62 <separator colspan="4" string="Actions" />
63 <group colspan="4" col="2">63 <group colspan="4" col="2">
6464
=== modified file 'bin/addons/specific_rules/report/report_stock_inventory_xls.mako'
--- bin/addons/specific_rules/report/report_stock_inventory_xls.mako 2019-03-18 16:21:17 +0000
+++ bin/addons/specific_rules/report/report_stock_inventory_xls.mako 2021-02-09 15:57:38 +0000
@@ -232,7 +232,7 @@
232 </Row>232 </Row>
233 233
234 % for prd in lines:234 % for prd in lines:
235 % if prd['sum_qty'] or prd['with_product_list']:235 % if prd['sum_qty'] or prd['with_zero']:
236 <Row ss:AutoFitHeight="1">236 <Row ss:AutoFitHeight="1">
237 <Cell ss:StyleID="sumline"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>237 <Cell ss:StyleID="sumline"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>
238 <Cell ss:StyleID="sumline"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>238 <Cell ss:StyleID="sumline"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>
@@ -245,7 +245,7 @@
245 <Cell ss:StyleID="sumline"><Data ss:Type="Number">${(round(prd['sum_value'], 2))|x}</Data></Cell>245 <Cell ss:StyleID="sumline"><Data ss:Type="Number">${(round(prd['sum_value'], 2))|x}</Data></Cell>
246 </Row>246 </Row>
247 % for line in prd['lines'].itervalues():247 % for line in prd['lines'].itervalues():
248 % if line['qty'] or prd['with_product_list']:248 % if line['qty'] or prd['with_zero']:
249 <Row ss:AutoFitHeight="1">249 <Row ss:AutoFitHeight="1">
250 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>250 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>
251 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>251 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>

Subscribers

People subscribed via source and target branches