Merge lp:~unifield-team/unifield-server/us-1427 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3827
Proposed branch: lp:~unifield-team/unifield-server/us-1427
Merge into: lp:unifield-server
Diff against target: 80 lines (+38/-4)
3 files modified
bin/addons/msf_profile/data/patches.xml (+4/-0)
bin/addons/msf_profile/msf_profile.py (+28/-0)
bin/addons/product_attributes/product_attributes.py (+6/-4)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1427
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+297741@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/msf_profile/data/patches.xml'
--- bin/addons/msf_profile/data/patches.xml 2016-06-10 14:09:35 +0000
+++ bin/addons/msf_profile/data/patches.xml 2016-06-17 09:25:31 +0000
@@ -61,5 +61,9 @@
61 <record id="us_1297_patch" model="patch.scripts">61 <record id="us_1297_patch" model="patch.scripts">
62 <field name="method">us_1297_patch</field>62 <field name="method">us_1297_patch</field>
63 </record>63 </record>
64
65 <record id="us_1427_patch" model="patch.scripts">
66 <field name="method">us_1427_patch</field>
67 </record>
64 </data>68 </data>
65</openerp>69</openerp>
6670
=== modified file 'bin/addons/msf_profile/msf_profile.py'
--- bin/addons/msf_profile/msf_profile.py 2016-06-10 14:09:35 +0000
+++ bin/addons/msf_profile/msf_profile.py 2016-06-17 09:25:31 +0000
@@ -605,6 +605,34 @@
605 budget_obj.update_parent_budgets(cr, uid, budget_to_correct_ids)605 budget_obj.update_parent_budgets(cr, uid, budget_to_correct_ids)
606 return True606 return True
607607
608 def us_1427_patch(self, cr, uid, *a, **b):
609 """
610 Put active all inactive products with stock quantities in internal locations
611 """
612 sql = """
613 UPDATE product_product SET active = 't' WHERE id IN (
614 SELECT DISTINCT(q.product_id) FROM (
615 SELECT location_id, product_id, sum(sm.product_qty) AS qty
616 FROM (
617 (
618 SELECT location_id, product_id, sum(-product_qty) AS product_qty
619 FROM stock_move
620 WHERE location_id IN (SELECT id FROM stock_location WHERE usage = 'internal') AND state = 'done'
621 GROUP BY location_id, product_id
622 )
623 UNION
624 (
625 SELECT location_dest_id, product_id, sum(product_qty) AS product_qty
626 FROM stock_move
627 WHERE location_dest_id IN (SELECT id FROM stock_location WHERE usage = 'internal') AND state = 'done'
628 GROUP BY location_dest_id, product_id
629 )
630 ) AS sm GROUP BY location_id, product_id) AS q
631 LEFT JOIN product_product pp ON q.product_id = pp.id WHERE q.qty > 0 AND pp.active = 'f' ORDER BY q.product_id)
632 """
633 cr.execute(sql)
634 return True
635
608patch_scripts()636patch_scripts()
609637
610638
611639
=== modified file 'bin/addons/product_attributes/product_attributes.py'
--- bin/addons/product_attributes/product_attributes.py 2016-05-11 16:10:35 +0000
+++ bin/addons/product_attributes/product_attributes.py 2016-06-17 09:25:31 +0000
@@ -1387,9 +1387,6 @@
13871387
1388 internal_loc = location_obj.search(cr, uid, [('usage', '=', 'internal')], context=context)1388 internal_loc = location_obj.search(cr, uid, [('usage', '=', 'internal')], context=context)
13891389
1390 c = context.copy()
1391 c.update({'location_id': internal_loc})
1392
1393 for product in self.browse(cr, uid, ids, context=context):1390 for product in self.browse(cr, uid, ids, context=context):
1394 # Raise an error if the product is already inactive1391 # Raise an error if the product is already inactive
1395 if not product.active:1392 if not product.active:
@@ -1448,7 +1445,12 @@
1448 ('invoice_id.state', 'not in', ['paid', 'proforma', 'proforma2', 'cancel'])], context=context)1445 ('invoice_id.state', 'not in', ['paid', 'proforma', 'proforma2', 'cancel'])], context=context)
14491446
1450 # Check if the product has stock in internal locations1447 # Check if the product has stock in internal locations
1451 has_stock = product.qty_available1448 for loc_id in internal_loc:
1449 c = context.copy()
1450 c.update({'location': [loc_id]})
1451 has_stock = self.read(cr, uid, product.id, ['qty_available'], context=c)['qty_available'] > 0.00
1452 if has_stock:
1453 break
14521454
1453 opened_object = has_kit or has_initial_inv_line or has_inventory_line or has_move_line or has_fo_line or has_tender_line or has_po_line or has_invoice_line1455 opened_object = has_kit or has_initial_inv_line or has_inventory_line or has_move_line or has_fo_line or has_tender_line or has_po_line or has_invoice_line
1454 if has_stock or opened_object:1456 if has_stock or opened_object:

Subscribers

People subscribed via source and target branches

to all changes: