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
1=== modified file 'bin/addons/specific_rules/report/report_stock_inventory.py'
2--- bin/addons/specific_rules/report/report_stock_inventory.py 2019-03-29 08:46:15 +0000
3+++ bin/addons/specific_rules/report/report_stock_inventory.py 2021-02-09 15:57:38 +0000
4@@ -311,9 +311,10 @@
5 with_zero = False
6 values = {'state': 'done'}
7 cond = ['state=%(state)s']
8+ having = ['having round(sum(product_qty), 6) != 0']
9
10- having = "having round(sum(product_qty), 6) != 0"
11 full_prod_list = []
12+ batch_list = []
13
14 cond.append('location_id in %(location_ids)s')
15 if report.location_id:
16@@ -323,8 +324,8 @@
17
18 if report.product_id:
19 cond.append('product_id in %(product_ids)s')
20+ full_prod_list = [report.product_id.id]
21 values['product_ids'] = (report.product_id.id,)
22- with_zero = True
23 elif report.product_list_id:
24 cond.append('product_id in %(product_ids)s')
25 full_prod_list = self.pool.get('product.product').search(self.cr, self.uid, [('list_ids', '=', report.product_list_id.id)], context=self.localcontext)
26@@ -345,29 +346,41 @@
27 cond.append('date<%(stock_level_date)s')
28 values['stock_level_date'] = '%s 23:59:59' % report.stock_level_date
29
30- if (not report.product_id or not report.product_list_id or not report.prodlot_id or not report.expiry_date) \
31- and report.display_0:
32- with_zero = True
33+ if (not report.product_list_id or not report.prodlot_id or not report.expiry_date) and report.display_0:
34 to_date = datetime.now()
35 if report.stock_level_date:
36 to_date = datetime.strptime(values['stock_level_date'], '%Y-%m-%d %H:%M:%S')
37 from_date = (to_date + relativedelta(months=-int(report.in_last_x_months))).strftime('%Y-%m-%d 00:00:00')
38-
39- self.cr.execute("""select distinct(product_id) from stock_move
40- where state='done' and (location_id in %s or location_dest_id in %s) and date >= %s and date <= %s""",
41+ with_zero = True
42+
43+ plus_bn, w_prod = "", ""
44+ if report.product_id:
45+ plus_bn = ", prodlot_id"
46+ w_prod = " product_id = %s AND" % report.product_id.id
47+
48+ self.cr.execute("""select distinct product_id""" + plus_bn + """ from stock_move
49+ where""" + w_prod + """ state='done' and (location_id in %s or location_dest_id in %s) and date >= %s and date <= %s""",
50 (values['location_ids'], values['location_ids'], from_date, to_date))
51 for x in self.cr.fetchall():
52 full_prod_list.append(x[0])
53+ if report.product_id and x[1]:
54+ batch_list.append(x[1])
55
56- if with_zero:
57- having = ""
58+ if report.product_id and report.display_0:
59+ if batch_list:
60+ having.append('or prodlot_id in %(batch_list)s')
61+ values['batch_list'] = tuple(batch_list)
62+ else:
63+ having.append('or prodlot_id is NULL')
64+ elif with_zero:
65+ having = []
66
67 self.cr.execute("""select sum(product_qty), product_id, expired_date, prodlot_id, location_id
68 from report_stock_inventory
69 where
70- """+' and '.join(cond)+"""
71+ """ + ' and '.join(cond) + """
72 group by product_id, expired_date, uom_id, prodlot_id, location_id
73- """ + having, values)
74+ """ + ' '.join(having), values)
75
76 all_product_ids = {}
77 all_bn_ids = {}
78@@ -442,7 +455,7 @@
79 'product_name': product_data[product_id].name,
80 'uom': product_data[product_id].uom_id.name,
81 'sum_value': cost_price * rounded_qty,
82- 'with_product_list': with_zero,
83+ 'with_zero': with_zero,
84 'lines': {},
85 }
86 total_value += final_result[product_code]['sum_value']
87
88=== modified file 'bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako'
89--- bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako 2019-02-25 09:43:25 +0000
90+++ bin/addons/specific_rules/report/report_stock_inventory_all_locations_xls.mako 2021-02-09 15:57:38 +0000
91@@ -230,7 +230,7 @@
92
93 % for prd in lines:
94 % for line in prd['lines'].itervalues():
95- % if line['qty'] or prd['with_product_list']:
96+ % if line['qty'] or prd['with_zero']:
97 <Row ss:AutoFitHeight="1">
98 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>
99 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>
100
101=== modified file 'bin/addons/specific_rules/report/report_stock_inventory_view.xml'
102--- bin/addons/specific_rules/report/report_stock_inventory_view.xml 2019-03-18 16:21:17 +0000
103+++ bin/addons/specific_rules/report/report_stock_inventory_view.xml 2021-02-09 15:57:38 +0000
104@@ -55,9 +55,9 @@
105 domain="[('src_product_id', '=', product_id)]" attrs="{'readonly': ['|', ('state', '!=', 'draft'), ('product_list_id', '!=', False)]}" />
106 <field name="expiry_date" attrs="{'readonly': ['|', ('prodlot_id', '!=', False), ('state', '!=', 'draft')]}" />
107 <newline/>
108- <field name="display_0" attrs="{'invisible': ['|', '|', '|', ('product_id', '!=', False), ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False)]}" />
109+ <field name="display_0" attrs="{'invisible': ['|', '|', ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False)]}" />
110 <field name="in_last_x_months" nolabel="1" colspan="2"
111- 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')]}" />
112+ attrs="{'readonly': [('state', '!=', 'draft')], 'invisible': ['|', '|', '|', ('product_list_id', '!=', False), ('prodlot_id', '!=', False), ('expiry_date', '!=', False), ('display_0', '=', False)], 'required': [('display_0', '=', True), ('state', '=', 'draft')]}" />
113
114 <separator colspan="4" string="Actions" />
115 <group colspan="4" col="2">
116
117=== modified file 'bin/addons/specific_rules/report/report_stock_inventory_xls.mako'
118--- bin/addons/specific_rules/report/report_stock_inventory_xls.mako 2019-03-18 16:21:17 +0000
119+++ bin/addons/specific_rules/report/report_stock_inventory_xls.mako 2021-02-09 15:57:38 +0000
120@@ -232,7 +232,7 @@
121 </Row>
122
123 % for prd in lines:
124- % if prd['sum_qty'] or prd['with_product_list']:
125+ % if prd['sum_qty'] or prd['with_zero']:
126 <Row ss:AutoFitHeight="1">
127 <Cell ss:StyleID="sumline"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>
128 <Cell ss:StyleID="sumline"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>
129@@ -245,7 +245,7 @@
130 <Cell ss:StyleID="sumline"><Data ss:Type="Number">${(round(prd['sum_value'], 2))|x}</Data></Cell>
131 </Row>
132 % for line in prd['lines'].itervalues():
133- % if line['qty'] or prd['with_product_list']:
134+ % if line['qty'] or prd['with_zero']:
135 <Row ss:AutoFitHeight="1">
136 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_code'])|x}</Data></Cell>
137 <Cell ss:StyleID="line"><Data ss:Type="String">${(prd['product_name'])|x}</Data></Cell>

Subscribers

People subscribed via source and target branches