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
1=== modified file 'bin/addons/msf_profile/data/patches.xml'
2--- bin/addons/msf_profile/data/patches.xml 2016-06-10 14:09:35 +0000
3+++ bin/addons/msf_profile/data/patches.xml 2016-06-17 09:25:31 +0000
4@@ -61,5 +61,9 @@
5 <record id="us_1297_patch" model="patch.scripts">
6 <field name="method">us_1297_patch</field>
7 </record>
8+
9+ <record id="us_1427_patch" model="patch.scripts">
10+ <field name="method">us_1427_patch</field>
11+ </record>
12 </data>
13 </openerp>
14
15=== modified file 'bin/addons/msf_profile/msf_profile.py'
16--- bin/addons/msf_profile/msf_profile.py 2016-06-10 14:09:35 +0000
17+++ bin/addons/msf_profile/msf_profile.py 2016-06-17 09:25:31 +0000
18@@ -605,6 +605,34 @@
19 budget_obj.update_parent_budgets(cr, uid, budget_to_correct_ids)
20 return True
21
22+ def us_1427_patch(self, cr, uid, *a, **b):
23+ """
24+ Put active all inactive products with stock quantities in internal locations
25+ """
26+ sql = """
27+ UPDATE product_product SET active = 't' WHERE id IN (
28+ SELECT DISTINCT(q.product_id) FROM (
29+ SELECT location_id, product_id, sum(sm.product_qty) AS qty
30+ FROM (
31+ (
32+ SELECT location_id, product_id, sum(-product_qty) AS product_qty
33+ FROM stock_move
34+ WHERE location_id IN (SELECT id FROM stock_location WHERE usage = 'internal') AND state = 'done'
35+ GROUP BY location_id, product_id
36+ )
37+ UNION
38+ (
39+ SELECT location_dest_id, product_id, sum(product_qty) AS product_qty
40+ FROM stock_move
41+ WHERE location_dest_id IN (SELECT id FROM stock_location WHERE usage = 'internal') AND state = 'done'
42+ GROUP BY location_dest_id, product_id
43+ )
44+ ) AS sm GROUP BY location_id, product_id) AS q
45+ LEFT JOIN product_product pp ON q.product_id = pp.id WHERE q.qty > 0 AND pp.active = 'f' ORDER BY q.product_id)
46+ """
47+ cr.execute(sql)
48+ return True
49+
50 patch_scripts()
51
52
53
54=== modified file 'bin/addons/product_attributes/product_attributes.py'
55--- bin/addons/product_attributes/product_attributes.py 2016-05-11 16:10:35 +0000
56+++ bin/addons/product_attributes/product_attributes.py 2016-06-17 09:25:31 +0000
57@@ -1387,9 +1387,6 @@
58
59 internal_loc = location_obj.search(cr, uid, [('usage', '=', 'internal')], context=context)
60
61- c = context.copy()
62- c.update({'location_id': internal_loc})
63-
64 for product in self.browse(cr, uid, ids, context=context):
65 # Raise an error if the product is already inactive
66 if not product.active:
67@@ -1448,7 +1445,12 @@
68 ('invoice_id.state', 'not in', ['paid', 'proforma', 'proforma2', 'cancel'])], context=context)
69
70 # Check if the product has stock in internal locations
71- has_stock = product.qty_available
72+ for loc_id in internal_loc:
73+ c = context.copy()
74+ c.update({'location': [loc_id]})
75+ has_stock = self.read(cr, uid, product.id, ['qty_available'], context=c)['qty_available'] > 0.00
76+ if has_stock:
77+ break
78
79 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
80 if has_stock or opened_object:

Subscribers

People subscribed via source and target branches

to all changes: