Merge lp:~openerp-dev/openobject-addons/mso-trunk-dev-addons1 into lp:~openerp-dev/openobject-addons/trunk-dev-addons1
- mso-trunk-dev-addons1
- Merge into trunk-dev-addons1
Proposed by
mso (OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 3341 |
Proposed branch: | lp:~openerp-dev/openobject-addons/mso-trunk-dev-addons1 |
Merge into: | lp:~openerp-dev/openobject-addons/trunk-dev-addons1 |
Diff against target: |
339 lines (+213/-18) 9 files modified
delivery/delivery.py (+11/-3) delivery/delivery_view.xml (+11/-0) delivery/wizard/delivery_sale_order.py (+5/-1) delivery/wizard/delivery_sale_order_view.xml (+15/-13) sale/sale_view.xml (+1/-1) stock/__openerp__.py (+1/-0) stock/report/__init__.py (+1/-0) stock/report/report_stock_move.py (+62/-0) stock/report/report_stock_move_view.xml (+106/-0) |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/mso-trunk-dev-addons1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Harry (OpenERP) | Approve | ||
Review via email: mp+24100@code.launchpad.net |
Commit message
Description of the change
Task Id 584 - Delivery Cost Improvements on Sale
Task Id 591 - Postgres view of stock moves with filters & groups
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 'delivery/delivery.py' |
2 | --- delivery/delivery.py 2010-02-24 10:55:29 +0000 |
3 | +++ delivery/delivery.py 2010-04-26 05:44:29 +0000 |
4 | @@ -28,6 +28,17 @@ |
5 | _name = "delivery.carrier" |
6 | _description = "Carrier and delivery grids" |
7 | |
8 | + def name_get(self, cr, uid, ids, context={}): |
9 | + if not len(ids): |
10 | + return [] |
11 | + order_id = context.get('order_id',False) |
12 | + if not order_id: |
13 | + res = super(delivery_carrier, self).name_get(cr, uid, ids, context=context) |
14 | + else: |
15 | + order = self.pool.get('sale.order').browse(cr, uid, [order_id])[0] |
16 | + currency = order.pricelist_id.currency_id.name or '' |
17 | + res = [(r['id'], r['name']+' ('+(str(r['price']))+' '+currency+')') for r in self.read(cr, uid, ids, ['name', 'price'], context)] |
18 | + return res |
19 | def get_price(self, cr, uid, ids, field_name, arg=None, context={}): |
20 | res={} |
21 | sale_obj=self.pool.get('sale.order') |
22 | @@ -94,9 +105,7 @@ |
23 | } |
24 | _order = 'sequence' |
25 | |
26 | - |
27 | def get_price(self, cr, uid, id, order, dt, context): |
28 | - |
29 | total = 0 |
30 | weight = 0 |
31 | volume = 0 |
32 | @@ -112,7 +121,6 @@ |
33 | |
34 | def get_price_from_picking(self, cr, uid, id, total, weight, volume, context={}): |
35 | grid = self.browse(cr, uid, id, context) |
36 | - |
37 | price = 0.0 |
38 | ok = False |
39 | |
40 | |
41 | === modified file 'delivery/delivery_view.xml' |
42 | --- delivery/delivery_view.xml 2010-04-18 19:11:09 +0000 |
43 | +++ delivery/delivery_view.xml 2010-04-26 05:44:29 +0000 |
44 | @@ -289,5 +289,16 @@ |
45 | </field> |
46 | </record> |
47 | |
48 | + <record model="ir.ui.view" id="edit_project_multicompany"> |
49 | + <field name="name">sale.order.multicompany</field> |
50 | + <field name="model">sale.order</field> |
51 | + <field name="inherit_id" ref="sale.view_order_form"/> |
52 | + <field name="arch" type="xml"> |
53 | + <xpath expr="/form/notebook/page[@string='Sale Order']/group[1]/button[@name='button_dummy']" position="after"> |
54 | + <button name="%(action_delivery_cost)d" states="draft" string="Delivery Costs" type="action" icon="gtk-execute" context="{'order_id':id}"/> |
55 | + </xpath> |
56 | + </field> |
57 | + </record> |
58 | + |
59 | </data> |
60 | </openerp> |
61 | |
62 | === modified file 'delivery/wizard/delivery_sale_order.py' |
63 | --- delivery/wizard/delivery_sale_order.py 2010-03-29 08:09:47 +0000 |
64 | +++ delivery/wizard/delivery_sale_order.py 2010-04-26 05:44:29 +0000 |
65 | @@ -50,7 +50,11 @@ |
66 | res = super(make_delivery, self).default_get(cr, uid, fields, context=context) |
67 | order_obj = self.pool.get('sale.order') |
68 | for order in order_obj.browse(cr, uid, context.get('active_ids', [])): |
69 | - res.update({'carrier_id': order.partner_id.property_delivery_carrier.id}) |
70 | + carrier = order.carrier_id.id |
71 | + if not carrier: |
72 | + carrier = order.partner_id.property_delivery_carrier.id |
73 | + res.update({'carrier_id': carrier}) |
74 | + |
75 | return res |
76 | |
77 | def view_init(self, cr , uid , fields, context=None): |
78 | |
79 | === modified file 'delivery/wizard/delivery_sale_order_view.xml' |
80 | --- delivery/wizard/delivery_sale_order_view.xml 2010-03-11 14:24:49 +0000 |
81 | +++ delivery/wizard/delivery_sale_order_view.xml 2010-04-26 05:44:29 +0000 |
82 | @@ -11,26 +11,28 @@ |
83 | <field name="arch" type="xml"> |
84 | <form string="Create Deliveries"> |
85 | <separator colspan="4" string="Delivery Method" /> |
86 | - <field name="carrier_id"/> |
87 | + <field name="carrier_id" widget="selection"/> |
88 | <newline/> |
89 | + <separator colspan="4"/> |
90 | <group col="2" colspan="4"> |
91 | <button icon='gtk-cancel' special="cancel" |
92 | string="Cancel" /> |
93 | - <button name="delivery_set" string="Add Delivery Costs" |
94 | - colspan="1" type="object" icon="gtk-ok" /> |
95 | + <button name="delivery_set" string="Apply" |
96 | + colspan="1" type="object" icon="gtk-apply" /> |
97 | </group> |
98 | </form> |
99 | </field> |
100 | </record> |
101 | - |
102 | - <act_window name="Delivery Costs" |
103 | - res_model="delivery.sale.order" |
104 | - src_model="sale.order" |
105 | - view_mode="form" |
106 | - target="new" |
107 | - key2="client_action_multi" |
108 | - id="act_delivery_cost"/> |
109 | - |
110 | - |
111 | + |
112 | + <record id="action_delivery_cost" model="ir.actions.act_window"> |
113 | + <field name="name">Delivery Costs</field> |
114 | + <field name="type">ir.actions.act_window</field> |
115 | + <field name="res_model">delivery.sale.order</field> |
116 | + <field name="view_type">form</field> |
117 | + <field name="view_mode">form</field> |
118 | + <field name="view_id" ref="view_make_delivery_wizard"/> |
119 | + <field name="target">new</field> |
120 | + </record> |
121 | + |
122 | </data> |
123 | </openerp> |
124 | |
125 | === modified file 'sale/sale_view.xml' |
126 | --- sale/sale_view.xml 2010-04-18 19:11:09 +0000 |
127 | +++ sale/sale_view.xml 2010-04-26 05:44:29 +0000 |
128 | @@ -188,7 +188,7 @@ |
129 | </tree> |
130 | </field> |
131 | <newline/> |
132 | - <group col="7" colspan="4"> |
133 | + <group col="8" colspan="5"> |
134 | <field name="amount_untaxed" sum="Untaxed amount"/> |
135 | <field name="amount_tax"/> |
136 | <field name="amount_total" sum="Total amount"/> |
137 | |
138 | === modified file 'stock/__openerp__.py' |
139 | --- stock/__openerp__.py 2010-04-21 10:22:02 +0000 |
140 | +++ stock/__openerp__.py 2010-04-26 05:44:29 +0000 |
141 | @@ -62,6 +62,7 @@ |
142 | "product_data.xml", |
143 | "product_view.xml", |
144 | "partner_view.xml", |
145 | + "report/report_stock_move_view.xml", |
146 | "report/report_stock_view.xml", |
147 | "report/report_stock_picking_view.xml", |
148 | "security/stock_security.xml", |
149 | |
150 | === modified file 'stock/report/__init__.py' |
151 | --- stock/report/__init__.py 2010-03-17 07:02:45 +0000 |
152 | +++ stock/report/__init__.py 2010-04-26 05:44:29 +0000 |
153 | @@ -28,6 +28,7 @@ |
154 | import lot_overview_all |
155 | import report_stock |
156 | import report_stock_picking |
157 | +import report_stock_move |
158 | |
159 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
160 | |
161 | |
162 | === added file 'stock/report/report_stock_move.py' |
163 | --- stock/report/report_stock_move.py 1970-01-01 00:00:00 +0000 |
164 | +++ stock/report/report_stock_move.py 2010-04-26 05:44:29 +0000 |
165 | @@ -0,0 +1,62 @@ |
166 | +# -*- coding: utf-8 -*- |
167 | +############################################################################## |
168 | +# |
169 | +# OpenERP, Open Source Management Solution |
170 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
171 | +# |
172 | +# This program is free software: you can redistribute it and/or modify |
173 | +# it under the terms of the GNU Affero General Public License as |
174 | +# published by the Free Software Foundation, either version 3 of the |
175 | +# License, or (at your option) any later version. |
176 | +# |
177 | +# This program is distributed in the hope that it will be useful, |
178 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
179 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
180 | +# GNU Affero General Public License for more details. |
181 | +# |
182 | +# You should have received a copy of the GNU Affero General Public License |
183 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
184 | +# |
185 | +############################################################################## |
186 | + |
187 | +import tools |
188 | +from osv import fields,osv |
189 | + |
190 | + |
191 | +class report_stock_move(osv.osv): |
192 | + _name = "report.stock.move" |
193 | + _description = "Stock Statistics" |
194 | + _auto = False |
195 | + _columns = { |
196 | + 'date': fields.date('Date', readonly=True), |
197 | + 'year': fields.char('Year', size=4, readonly=True), |
198 | + 'day': fields.char('Day', size=128, readonly=True), |
199 | + 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), |
200 | + ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), |
201 | + ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), |
202 | + 'product_id':fields.many2one('product.product', 'Product', readonly=True), |
203 | + 'location_id':fields.many2one('stock.location', 'Location', readonly=True), |
204 | + 'product_qty':fields.integer('Qty',readonly=True), |
205 | + 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True, |
206 | + help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\ |
207 | + \nThe state is \'Waiting\' if the move is waiting for another one.'), |
208 | + |
209 | + } |
210 | + |
211 | + def init(self, cr): |
212 | + tools.drop_view_if_exists(cr, 'report_stock_move') |
213 | + cr.execute(""" |
214 | + create or replace view report_stock_move as ( |
215 | + select min(m.id) as id, |
216 | + m.date as date, |
217 | + to_char(date_trunc('day',m.date), 'YYYY') as year, |
218 | + to_char(date_trunc('day',m.date), 'MM') as month, |
219 | + to_char(date_trunc('day',m.date), 'YYYY-MM-DD') as day, |
220 | + m.location_id as location_id, |
221 | + m.product_id as product_id, |
222 | + m.state as state, |
223 | + sum(m.product_qty) as product_qty |
224 | + from stock_move as m group by m.product_id, m.location_id, m.id, m.date, m.state |
225 | + ) |
226 | + """) |
227 | +report_stock_move() |
228 | |
229 | === added file 'stock/report/report_stock_move_view.xml' |
230 | --- stock/report/report_stock_move_view.xml 1970-01-01 00:00:00 +0000 |
231 | +++ stock/report/report_stock_move_view.xml 2010-04-26 05:44:29 +0000 |
232 | @@ -0,0 +1,106 @@ |
233 | +<?xml version="1.0" encoding="utf-8"?> |
234 | +<openerp> |
235 | +<data> |
236 | + <record id="view_stock_tree" model="ir.ui.view"> |
237 | + <field name="name">report.stock.move.tree</field> |
238 | + <field name="model">report.stock.move</field> |
239 | + <field name="type">tree</field> |
240 | + <field name="arch" type="xml"> |
241 | + <tree string="Stock Orders Statistics"> |
242 | + <field name="date"/> |
243 | + <field name="year" invisible="1" /> |
244 | + <field name="month" invisible="1"/> |
245 | + <field name="day" invisible="1"/> |
246 | + <field name="product_id"/> |
247 | + <field name="product_qty"/> |
248 | + <field name="location_id"/> |
249 | + <field name="state"/> |
250 | + </tree> |
251 | + </field> |
252 | + </record> |
253 | + |
254 | + <record id="view_stock_graph" model="ir.ui.view"> |
255 | + <field name="name">report.stock.move.graph</field> |
256 | + <field name="model">report.stock.move</field> |
257 | + <field name="type">graph</field> |
258 | + <field name="arch" type="xml"> |
259 | + <graph string="Stock Moves Statistics" type="bar"> |
260 | + <field name="product_id"/> |
261 | + <field name="product_qty"/> |
262 | + </graph> |
263 | + </field> |
264 | + </record> |
265 | + |
266 | + <record id="view_stock_search" model="ir.ui.view"> |
267 | + <field name="name">report.stock.move.search</field> |
268 | + <field name="model">report.stock.move</field> |
269 | + <field name="type">search</field> |
270 | + <field name="arch" type="xml"> |
271 | + <search string="Stock Move"> |
272 | + <group> |
273 | + <filter icon="terp-stock" |
274 | + string="This Year" |
275 | + domain="[('year','=',time.strftime('%%Y'))]" |
276 | + help="Stock Moves of the year"/> |
277 | + <filter icon="terp-stock" |
278 | + string="This Month" |
279 | + domain="[('month','=',time.strftime('%%m'))]" |
280 | + help="Stock Moves of this month"/> |
281 | + <filter icon="terp-stock" |
282 | + string="Current Stock" |
283 | + separator="1" |
284 | + domain="[('date', '=', time.strftime('%%Y-%%m-%%d')]" |
285 | + help="Stock Moves of today"/> |
286 | + <separator orientation="vertical"/> |
287 | + |
288 | + <filter string="Waiting" |
289 | + icon="terp-stock" |
290 | + domain="[('state','=','waiting')]" |
291 | + help = "Confirmed Stock-Moves"/> |
292 | + |
293 | + <filter string="Available" |
294 | + icon="terp-stock" |
295 | + domain="[('state','=','assigned')]" |
296 | + help = "Available Stock-Moves"/> |
297 | + |
298 | + <filter string="Done" |
299 | + icon="terp-stock" |
300 | + domain="[('state','=','done')]" |
301 | + help = "Completed Stock-Moves"/> |
302 | + |
303 | + <separator orientation="vertical"/> |
304 | + <field name="product_id" select="1" widget="selection"/> |
305 | + <field name="location_id" select="1" widget="selection"/> |
306 | + </group> |
307 | + <newline/> |
308 | + <group expand="1" string="Group By..." > |
309 | + <filter string="Product" icon="terp-stock" context="{'group_by':'product_id'}"/> |
310 | + <filter string="Location" icon="terp-stock" context="{'group_by':'location_id'}"/> |
311 | + <filter string="State" icon="terp-stock" context="{'group_by':'state'}"/> |
312 | + <separator orientation="vertical"/> |
313 | + <filter string="Day" icon="terp-stock" context="{'group_by':'day'}"/> |
314 | + <filter string="Month" icon="terp-stock" context="{'group_by':'date'}"/> |
315 | + <filter string="Year" icon="terp-stock" context="{'group_by':'year'}"/> |
316 | + </group> |
317 | + </search> |
318 | + </field> |
319 | + </record> |
320 | + |
321 | + <record id="action_stock_move_report" model="ir.actions.act_window"> |
322 | + <field name="name">Stock Moves</field> |
323 | + <field name="res_model">report.stock.move</field> |
324 | + <field name="view_type">form</field> |
325 | + <field name="view_mode">tree,graph</field> |
326 | + <field name="search_view_id" ref="view_stock_search"/> |
327 | + |
328 | + </record> |
329 | + |
330 | + <menuitem |
331 | + id="stock.next_id_61" |
332 | + name="Reporting" |
333 | + parent="stock.menu_stock_root" groups="base.group_user"/> |
334 | + |
335 | + <menuitem action="action_stock_move_report" id="menu_action_stock_move_report" parent="next_id_61" sequence="5"/> |
336 | + |
337 | +</data> |
338 | +</openerp> |
339 | \ No newline at end of file |
Hello Mitesh,
Your branch is merged into trunk-dev-addons1 branch
Committed revision 3341.
Thanks