Merge lp:~sylvain-legal/openupgrade-addons/7.0_point_of_sale into lp:openupgrade-addons
- 7.0_point_of_sale
- Merge into 7.0
Proposed by
Sylvain LE GAL (GRAP)
Status: | Work in progress |
---|---|
Proposed branch: | lp:~sylvain-legal/openupgrade-addons/7.0_point_of_sale |
Merge into: | lp:openupgrade-addons |
Diff against target: |
416 lines (+397/-0) 4 files modified
point_of_sale/migrations/7.0.1.0.1/openupgrade_analysis_work.txt (+169/-0) point_of_sale/migrations/7.0.1.0.1/post-migration.py (+180/-0) point_of_sale/migrations/7.0.1.0.1/pre-migration.py (+34/-0) point_of_sale/migrations/7.0.1.0.1/user_notes.txt (+14/-0) |
To merge this branch: | bzr merge lp:~sylvain-legal/openupgrade-addons/7.0_point_of_sale |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenUpgrade Committers | Pending | ||
Review via email: mp+187221@code.launchpad.net |
Commit message
Description of the change
This branch will manage 'point_of_sale' migration.
Work in progress.
Please don't review until the state changes.
Merge Proposal just to inform to community i'm working on the module.
To post a comment you must log in.
- 8137. By Sylvain LE GAL (GRAP)
-
[ADD] First version Beta for 'point_of_sale' migration.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
How is this work going, Sylvain?
Revision history for this message
Sylvain LE GAL (GRAP) (sylvain-legal) wrote : | # |
Hi,
I realized a migration 6.1 -> 7.0 in November 2013 with this script. I did'nt marked this MP as 'ready to review' because this script was experimental and I think that other developpers have to work on it to make it more correct maybe.
I kept it in the state 'work in progress' because maybe this script can be usefull for any people.
Regards.
Unmerged revisions
- 8137. By Sylvain LE GAL (GRAP)
-
[ADD] First version Beta for 'point_of_sale' migration.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'point_of_sale/migrations/7.0.1.0.1/openupgrade_analysis_work.txt' | |||
2 | --- point_of_sale/migrations/7.0.1.0.1/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000 | |||
3 | +++ point_of_sale/migrations/7.0.1.0.1/openupgrade_analysis_work.txt 2013-10-14 23:49:02 +0000 | |||
4 | @@ -0,0 +1,169 @@ | |||
5 | 1 | # - se faire une base de référence de point of sale en 6.1 | ||
6 | 2 | # passer une migration V7 avec rien, pour voir comment ça réagit. | ||
7 | 3 | |||
8 | 4 | |||
9 | 5 | ---Fields in module 'point_of_sale'--- | ||
10 | 6 | ### Create an session for each bank statement. | ||
11 | 7 | point_of_sale / account.bank.statement / pos_session_id (many2one) : NEW relation: pos.session | ||
12 | 8 | |||
13 | 9 | ### Deleting a field related. Nothing to do. | ||
14 | 10 | point_of_sale / account.bank.statement.line / journal_id (char) : DEL mode: modify | ||
15 | 11 | |||
16 | 12 | |||
17 | 13 | ### This concept are lost in V7. Nothing to do. | ||
18 | 14 | point_of_sale / account.journal / auto_cash (boolean) : DEL | ||
19 | 15 | point_of_sale / account.journal / check_dtls (boolean) : DEL | ||
20 | 16 | ### New concept, use default | ||
21 | 17 | point_of_sale / account.journal / amount_authorized_diff (float): NEW | ||
22 | 18 | point_of_sale / account.journal / self_checkout_payment_method (boolean): NEW | ||
23 | 19 | |||
24 | 20 | ### New concept. hypothesis : create au new pos_config object for each shop_id / sale_journal / user_id | ||
25 | 21 | point_of_sale / pos.config / group_by (boolean) : NEW | ||
26 | 22 | point_of_sale / pos.config / iface_cashdrawer (boolean) : NEW | ||
27 | 23 | point_of_sale / pos.config / iface_electronic_scale (boolean): NEW | ||
28 | 24 | point_of_sale / pos.config / iface_payment_terminal (boolean): NEW | ||
29 | 25 | point_of_sale / pos.config / iface_print_via_proxy (boolean): NEW | ||
30 | 26 | point_of_sale / pos.config / iface_self_checkout (boolean) : NEW | ||
31 | 27 | point_of_sale / pos.config / iface_vkeyboard (boolean) : NEW | ||
32 | 28 | point_of_sale / pos.config / journal_id (many2one) : NEW relation: account.journal | ||
33 | 29 | point_of_sale / pos.config / journal_ids (many2many) : NEW relation: account.journal | ||
34 | 30 | point_of_sale / pos.config / name (char) : NEW required: required | ||
35 | 31 | point_of_sale / pos.config / sequence_id (many2one) : NEW relation: ir.sequence | ||
36 | 32 | point_of_sale / pos.config / session_ids (one2many) : NEW relation: pos.session | ||
37 | 33 | point_of_sale / pos.config / shop_id (many2one) : NEW relation: sale.shop, required: required, req_default: function | ||
38 | 34 | point_of_sale / pos.config / state (selection) : NEW required: required, selection_keys: ['active', 'deprecated', 'inactive'], req_default: active | ||
39 | 35 | |||
40 | 36 | # Pour les pos_order faire un select shop_id, sale_journal. Créer un pos_config & des pos_sessions associés. !!!! Attention aussi aux users. | ||
41 | 37 | |||
42 | 38 | # New optional value. Nothing to do. | ||
43 | 39 | point_of_sale / pos.order / pos_reference (char) : NEW | ||
44 | 40 | ### The script migration will associate a pos.order to a new 'pos.session'. (associated to sale_journal). | ||
45 | 41 | # No Data loss neither, data Change. Nothing to do. | ||
46 | 42 | point_of_sale / pos.order / sale_journal (many2one) : now a function | ||
47 | 43 | # The script migration will associate a pos.order to a new 'pos.session'. | ||
48 | 44 | point_of_sale / pos.order / session_id (many2one) : NEW relation: pos.session | ||
49 | 45 | ### The script migration will associate a pos.order to a new 'pos.session'. (associated to shop_id). | ||
50 | 46 | # No Data loss neither, data Change. Nothing to do. | ||
51 | 47 | point_of_sale / pos.order / shop_id (many2one) : now a function | ||
52 | 48 | |||
53 | 49 | |||
54 | 50 | point_of_sale / pos.session / config_id (many2one) : NEW relation: pos.config, required: required | ||
55 | 51 | point_of_sale / pos.session / name (char) : NEW required: required, req_default: / | ||
56 | 52 | point_of_sale / pos.session / order_ids (one2many) : NEW relation: pos.order | ||
57 | 53 | point_of_sale / pos.session / start_at (datetime) : NEW | ||
58 | 54 | point_of_sale / pos.session / state (selection) : NEW required: required, selection_keys: ['closed', 'closing_control', 'opened', 'opening_control'], req_default: opening_control | ||
59 | 55 | point_of_sale / pos.session / statement_ids (one2many) : NEW relation: account.bank.statement | ||
60 | 56 | point_of_sale / pos.session / stop_at (datetime) : NEW | ||
61 | 57 | point_of_sale / pos.session / user_id (many2one) : NEW relation: res.users, required: required, req_default: function | ||
62 | 58 | |||
63 | 59 | ### 'available_in_pos' is a new concept. If checked, the product will be available to sale in the point of sale. | ||
64 | 60 | # In 6.1, the product was available if the product had a pos_categ_id defined. | ||
65 | 61 | # The script migration will set to True the 'available_in_pos' value for all product with a pos_categ_id defined. | ||
66 | 62 | point_of_sale / product.product / available_in_pos (boolean) : NEW | ||
67 | 63 | |||
68 | 64 | ### 'to_weight' is a a new concept. We assume that all products that have a unit 'uos_id' (or 'uom_id') which 'uom_categ_id' is 'product_uom_categ_kgm' can be weight. | ||
69 | 65 | # The script migration will set to True the 'to_weight' value for that products. | ||
70 | 66 | ## USE : uom_categ, uom_categ_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'product', 'product_uom_categ_kgm') | ||
71 | 67 | point_of_sale / product.product / to_weight (boolean) : NEW | ||
72 | 68 | |||
73 | 69 | # New Concept for 'pos.category'. Nothing to do. | ||
74 | 70 | point_of_sale / pos.category / image (binary) : NEW | ||
75 | 71 | |||
76 | 72 | # New Concept for 'res_user'. Nothing to do. | ||
77 | 73 | point_of_sale / res.users / ean13 (char) : NEW | ||
78 | 74 | |||
79 | 75 | # Script migration will associate a new 'pos.config' to each sale user. | ||
80 | 76 | point_of_sale / res.users / pos_config (many2one) : NEW relation: pos.config | ||
81 | 77 | |||
82 | 78 | ---XML records in module 'point_of_sale'--- | ||
83 | 79 | ### Ignore interface and access records | ||
84 | 80 | NEW ir.actions.act_window: point_of_sale.act_pos_config_sessions | ||
85 | 81 | NEW ir.actions.act_window: point_of_sale.act_pos_session_orders | ||
86 | 82 | NEW ir.actions.act_window: point_of_sale.action_pos_box_in | ||
87 | 83 | NEW ir.actions.act_window: point_of_sale.action_pos_box_out | ||
88 | 84 | NEW ir.actions.act_window: point_of_sale.action_pos_config_pos | ||
89 | 85 | NEW ir.actions.act_window: point_of_sale.action_pos_session | ||
90 | 86 | NEW ir.actions.act_window: point_of_sale.action_pos_session_opening | ||
91 | 87 | DEL ir.actions.act_window: point_of_sale.action_box_entries | ||
92 | 88 | DEL ir.actions.act_window: point_of_sale.action_box_out | ||
93 | 89 | DEL ir.actions.act_window: point_of_sale.action_pos_close_statement | ||
94 | 90 | DEL ir.actions.act_window: point_of_sale.action_pos_confirm | ||
95 | 91 | DEL ir.actions.act_window: point_of_sale.action_pos_sale_all | ||
96 | 92 | DEL ir.actions.act_window: point_of_sale.action_product_input | ||
97 | 93 | DEL ir.actions.act_window: point_of_sale.action_product_output | ||
98 | 94 | DEL ir.actions.act_window: point_of_sale.action_report_cash_register_all | ||
99 | 95 | NEW ir.actions.client: point_of_sale.action_client_pos_menu | ||
100 | 96 | NEW ir.actions.report.xml: point_of_sale.report_user_label | ||
101 | 97 | NEW ir.actions.todo: base.open_menu | ||
102 | 98 | NEW ir.model.access: point_of_sale.access_account_journal_cashbox_line | ||
103 | 99 | NEW ir.model.access: point_of_sale.access_ir_sequence_manager | ||
104 | 100 | NEW ir.model.access: point_of_sale.access_pos_config_user | ||
105 | 101 | NEW ir.model.access: point_of_sale.access_pos_session_user | ||
106 | 102 | DEL ir.model.access: point_of_sale.access_account_journal_column | ||
107 | 103 | DEL ir.model.access: point_of_sale.access_account_journal_column_manager | ||
108 | 104 | DEL ir.model.access: point_of_sale.access_account_journal_view | ||
109 | 105 | DEL ir.model.access: point_of_sale.access_account_journal_view_manager | ||
110 | 106 | DEL ir.model.access: point_of_sale.access_pos_config_journal | ||
111 | 107 | DEL ir.model.access: point_of_sale.access_pos_config_journal_manager | ||
112 | 108 | DEL ir.model.access: point_of_sale.access_report_check_register | ||
113 | 109 | NEW ir.rule: point_of_sale.rule_pos_multi_company | ||
114 | 110 | NEW ir.ui.menu: point_of_sale.menu_pos_config_pos | ||
115 | 111 | NEW ir.ui.menu: point_of_sale.menu_pos_session_all | ||
116 | 112 | NEW ir.ui.menu: point_of_sale.menu_pos_session_opening | ||
117 | 113 | DEL ir.ui.menu: point_of_sale.menu_all_menu_all_register | ||
118 | 114 | DEL ir.ui.menu: point_of_sale.menu_close_statement | ||
119 | 115 | DEL ir.ui.menu: point_of_sale.menu_open_statement | ||
120 | 116 | DEL ir.ui.menu: point_of_sale.menu_point_ofsale_all | ||
121 | 117 | DEL ir.ui.menu: point_of_sale.menu_point_open_config | ||
122 | 118 | DEL ir.ui.menu: point_of_sale.menu_point_root_touchscreen | ||
123 | 119 | DEL ir.ui.menu: point_of_sale.menu_report_cash_register_all | ||
124 | 120 | DEL ir.ui.menu: point_of_sale.menu_wizard_enter_jrnl | ||
125 | 121 | DEL ir.ui.menu: point_of_sale.menu_wizard_enter_jrnl2 | ||
126 | 122 | DEL ir.ui.menu: point_of_sale.menu_wizard_pos_confirm | ||
127 | 123 | DEL ir.ui.menu: point_of_sale.products_for_input_operations | ||
128 | 124 | DEL ir.ui.menu: point_of_sale.products_for_output_operations | ||
129 | 125 | NEW ir.ui.view: point_of_sale.pos_ean13_generator | ||
130 | 126 | NEW ir.ui.view: point_of_sale.pos_session_opening_form_view | ||
131 | 127 | NEW ir.ui.view: point_of_sale.res_users_form_preference_view | ||
132 | 128 | NEW ir.ui.view: point_of_sale.res_users_form_view | ||
133 | 129 | NEW ir.ui.view: point_of_sale.view_partner_property_form | ||
134 | 130 | NEW ir.ui.view: point_of_sale.view_pos_config_form | ||
135 | 131 | NEW ir.ui.view: point_of_sale.view_pos_config_search | ||
136 | 132 | NEW ir.ui.view: point_of_sale.view_pos_config_tree | ||
137 | 133 | NEW ir.ui.view: point_of_sale.view_pos_session_form | ||
138 | 134 | NEW ir.ui.view: point_of_sale.view_pos_session_search | ||
139 | 135 | NEW ir.ui.view: point_of_sale.view_pos_session_tree | ||
140 | 136 | DEL ir.ui.view: point_of_sale.product_normal_form_pos_view | ||
141 | 137 | DEL ir.ui.view: point_of_sale.view_box_entries | ||
142 | 138 | DEL ir.ui.view: point_of_sale.view_pos_box_out | ||
143 | 139 | DEL ir.ui.view: point_of_sale.view_pos_close_statement | ||
144 | 140 | DEL ir.ui.view: point_of_sale.view_report_cash_register_search | ||
145 | 141 | DEL ir.ui.view: point_of_sale.view_report_cash_register_tree | ||
146 | 142 | |||
147 | 143 | ### Ignore new sequence records | ||
148 | 144 | NEW ir.sequence: point_of_sale.seq_pos_session | ||
149 | 145 | NEW ir.sequence.type: point_of_sale.seq_type_pos_session | ||
150 | 146 | |||
151 | 147 | ### Ignore added chatter configuration | ||
152 | 148 | NEW mail.message: point_of_sale.module_install_notification | ||
153 | 149 | |||
154 | 150 | ### New pos_config. script migration will set it in a obsolete state. | ||
155 | 151 | NEW pos.config: point_of_sale.pos_config_main | ||
156 | 152 | |||
157 | 153 | ### New product. Nothing to do. | ||
158 | 154 | NEW product.product: point_of_sale.unreferenced_product | ||
159 | 155 | |||
160 | 156 | ### Completely new workflow for 'pos.dession'. Nothing to do. | ||
161 | 157 | NEW workflow: point_of_sale.wkf_pos_session | ||
162 | 158 | NEW workflow.activity: point_of_sale.act_close | ||
163 | 159 | NEW workflow.activity: point_of_sale.act_closing_control | ||
164 | 160 | NEW workflow.activity: point_of_sale.act_open | ||
165 | 161 | NEW workflow.activity: point_of_sale.act_opening_control | ||
166 | 162 | NEW workflow.activity: point_of_sale.act_start | ||
167 | 163 | NEW workflow.transition: point_of_sale.trans_closing_control_to_close | ||
168 | 164 | NEW workflow.transition: point_of_sale.trans_closing_control_to_close_no_control | ||
169 | 165 | NEW workflow.transition: point_of_sale.trans_open_to_close | ||
170 | 166 | NEW workflow.transition: point_of_sale.trans_open_to_closing_control | ||
171 | 167 | NEW workflow.transition: point_of_sale.trans_opening_control_to_open | ||
172 | 168 | NEW workflow.transition: point_of_sale.trans_start_to_open | ||
173 | 169 | NEW workflow.transition: point_of_sale.trans_start_to_opening_control | ||
174 | 0 | 170 | ||
175 | === added file 'point_of_sale/migrations/7.0.1.0.1/post-migration.py' | |||
176 | --- point_of_sale/migrations/7.0.1.0.1/post-migration.py 1970-01-01 00:00:00 +0000 | |||
177 | +++ point_of_sale/migrations/7.0.1.0.1/post-migration.py 2013-10-14 23:49:02 +0000 | |||
178 | @@ -0,0 +1,180 @@ | |||
179 | 1 | # -*- coding: utf-8 -*- | ||
180 | 2 | ############################################################################## | ||
181 | 3 | # | ||
182 | 4 | # OpenERP, Open Source Management Solution | ||
183 | 5 | # This module copyright (C) 2013 Sylvain LE GAL | ||
184 | 6 | # | ||
185 | 7 | # This program is free software: you can redistribute it and/or modify | ||
186 | 8 | # it under the terms of the GNU Affero General Public License as | ||
187 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
188 | 10 | # License, or (at your option) any later version. | ||
189 | 11 | # | ||
190 | 12 | # This program is distributed in the hope that it will be useful, | ||
191 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
192 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
193 | 15 | # GNU Affero General Public License for more details. | ||
194 | 16 | # | ||
195 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
196 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
197 | 19 | # | ||
198 | 20 | ############################################################################## | ||
199 | 21 | from openerp import pooler, SUPERUSER_ID | ||
200 | 22 | from openerp.openupgrade import openupgrade, openupgrade_70 | ||
201 | 23 | |||
202 | 24 | def migrate_product_available_in_pos(cr, pool): | ||
203 | 25 | """ | ||
204 | 26 | Initialize product that available_in_pos, using old behaviour of | ||
205 | 27 | 6.1 version. (In 6.1, product with pos_categ_id set are available in pos) | ||
206 | 28 | """ | ||
207 | 29 | cr.execute("""UPDATE product_product | ||
208 | 30 | SET available_in_pos = True | ||
209 | 31 | WHERE pos_categ_id is not Null""") | ||
210 | 32 | |||
211 | 33 | def migrate_product_to_weight(cr, pool): | ||
212 | 34 | """ | ||
213 | 35 | Initialize product_to_weight value in 'product.product', assuming that | ||
214 | 36 | product that have an uom weightable will be 'product_to_weight'. | ||
215 | 37 | """ | ||
216 | 38 | product_product_obj = pool.get('product.product') | ||
217 | 39 | uom_categ, uom_categ_id = pool.get('ir.model.data').get_object_reference( | ||
218 | 40 | cr, SUPERUSER_ID, 'product', 'product_uom_categ_kgm') | ||
219 | 41 | uom_ids = pool.get('product.uom').search(cr, SUPERUSER_ID, | ||
220 | 42 | [('category_id', '=', uom_categ_id)]) | ||
221 | 43 | product_ids = product_product_obj.search(cr, SUPERUSER_ID, | ||
222 | 44 | [('uom_id', 'in', uom_ids)]) | ||
223 | 45 | product_product_obj.write(cr, SUPERUSER_ID, | ||
224 | 46 | product_ids, | ||
225 | 47 | {'to_weight' : True,}) | ||
226 | 48 | |||
227 | 49 | def create_pos_config(cr, pool): | ||
228 | 50 | """ | ||
229 | 51 | pos_config is totally new concept. | ||
230 | 52 | Script migration will create pos_config based on datas in point_of_sale (6.1) | ||
231 | 53 | (One pos_config by shop and sale_journal in 6.1.) | ||
232 | 54 | Script migration will create too on pos_config by sale user because it's not | ||
233 | 55 | possible to create 2 pos.session active with the same 'pos.config'. | ||
234 | 56 | """ | ||
235 | 57 | pos_config_obj = pool.get('pos.config') | ||
236 | 58 | shop_obj = pool.get('sale.shop') | ||
237 | 59 | journal_obj = pool.get('account.journal') | ||
238 | 60 | user_obj = pool.get('res.users') | ||
239 | 61 | pos_session_obj = pool.get('pos.session') | ||
240 | 62 | pos_order_obj = pool.get('pos.order') | ||
241 | 63 | # Create a pos config by shop, and sale_journal | ||
242 | 64 | cr.execute(""" | ||
243 | 65 | SELECT shop_id, sale_journal sale_journal_id, user_id | ||
244 | 66 | FROM pos_order | ||
245 | 67 | GROUP BY shop_id, sale_journal, user_id;""") | ||
246 | 68 | |||
247 | 69 | for shop_id, sale_journal_id, user_id in cr.fetchall(): | ||
248 | 70 | # Generate a readable name | ||
249 | 71 | name = shop_obj.read(cr, SUPERUSER_ID, [shop_id], ['name'])[0]['name'] | ||
250 | 72 | name += " - " + journal_obj.read(cr, SUPERUSER_ID, [sale_journal_id], ['code'])[0]['code'] | ||
251 | 73 | name += " - " + user_obj.read(cr, SUPERUSER_ID, [user_id], ['login'])[0]['login'] | ||
252 | 74 | |||
253 | 75 | # Get the bank_journal related to new pos_config, using the history of pos_orders. | ||
254 | 76 | cr.execute(""" | ||
255 | 77 | SELECT abs.journal_id bank_journal_id | ||
256 | 78 | FROM account_bank_statement_line absl | ||
257 | 79 | INNER JOIN account_bank_statement abs ON abs.id = absl.statement_id | ||
258 | 80 | INNER JOIN pos_order po ON absl.pos_statement_id= po.id | ||
259 | 81 | WHERE po.shop_id = {0} and po.sale_journal = {1} | ||
260 | 82 | GROUP BY abs.journal_id; """.format(shop_id, sale_journal_id)) | ||
261 | 83 | |||
262 | 84 | bank_journal_ids = [] | ||
263 | 85 | for bank_journal_id in cr.fetchall(): | ||
264 | 86 | bank_journal_ids.append(bank_journal_id[0]) | ||
265 | 87 | pos_config_id = pos_config_obj.create(cr, SUPERUSER_ID, { | ||
266 | 88 | 'name' : name, | ||
267 | 89 | 'journal_id': sale_journal_id, | ||
268 | 90 | 'shop_id': shop_id, | ||
269 | 91 | 'journal_ids' : [(6,0,bank_journal_ids)], | ||
270 | 92 | }) | ||
271 | 93 | |||
272 | 94 | # associate user to new pos_config. | ||
273 | 95 | user_obj.write(cr, SUPERUSER_ID, [user_id], {'pos_config' : pos_config_id}) | ||
274 | 96 | |||
275 | 97 | # Get all statement_id associated to a pos.session. | ||
276 | 98 | cr.execute(""" | ||
277 | 99 | SELECT absl.statement_id from account_bank_statement_line absl | ||
278 | 100 | INNER JOIN pos_order po on po.id = absl.pos_statement_id | ||
279 | 101 | WHERE po.shop_id={0} AND po.user_id={1} AND po.sale_journal={2} | ||
280 | 102 | GROUP BY absl.statement_id; | ||
281 | 103 | """.format(shop_id, sale_journal_id, user_id)) | ||
282 | 104 | statement_ids = [] | ||
283 | 105 | for statement_id in cr.fetchall(): | ||
284 | 106 | statement_ids.append(statement_id[0]) | ||
285 | 107 | |||
286 | 108 | # create pos session by sql, to avoid automatic creation of account bank statement | ||
287 | 109 | # and other behaviours not wished | ||
288 | 110 | cr.execute(""" | ||
289 | 111 | INSERT INTO pos_session( | ||
290 | 112 | create_uid, create_date, write_uid, write_date, | ||
291 | 113 | config_id, user_id, name, state, | ||
292 | 114 | start_at, stop_at, cash_journal_id, cash_register_id | ||
293 | 115 | ) | ||
294 | 116 | VALUES ( | ||
295 | 117 | {0}, {1}, {0}, {1}, | ||
296 | 118 | {2}, {0}, '{3}', 'closed', | ||
297 | 119 | Null, Null, Null, Null) | ||
298 | 120 | RETURNING id; | ||
299 | 121 | """.format(user_id, | ||
300 | 122 | "(now() at time zone 'UTC')", | ||
301 | 123 | pos_config_id, | ||
302 | 124 | name.encode('utf-8').strip(), | ||
303 | 125 | )) | ||
304 | 126 | pos_session_id = cr.fetchone()[0] | ||
305 | 127 | if statement_ids !=[]: | ||
306 | 128 | #import pdb; pdb.set_trace() | ||
307 | 129 | for sub_ids in cr.split_for_in_conditions(statement_ids): | ||
308 | 130 | cr.execute(""" | ||
309 | 131 | UPDATE account_bank_statement | ||
310 | 132 | SET pos_session_id = %s | ||
311 | 133 | WHERE id in %%s | ||
312 | 134 | """ % (pos_session_id), [tuple(sub_ids)]) | ||
313 | 135 | # pos_session_id = pos_session_obj.create(cr, SUPERUSER_ID, { | ||
314 | 136 | # 'config_id' : pos_config_id, | ||
315 | 137 | # 'start_at' : None, | ||
316 | 138 | # 'state' : 'closed', | ||
317 | 139 | # 'statement_ids' : [(6,0,statement_ids)], | ||
318 | 140 | # 'stop_at' : None, | ||
319 | 141 | # 'user_id' : user_id, | ||
320 | 142 | # }) | ||
321 | 143 | |||
322 | 144 | # associate pos.order to the new pos.session | ||
323 | 145 | cr.execute(""" | ||
324 | 146 | UPDATE pos_order | ||
325 | 147 | SET session_id={3} | ||
326 | 148 | WHERE shop_id={0} AND sale_journal={1} AND user_id={2}; | ||
327 | 149 | """.format(shop_id, sale_journal_id, user_id, pos_session_id)) | ||
328 | 150 | |||
329 | 151 | # cr.execute(""" | ||
330 | 152 | # SELECT id | ||
331 | 153 | # FROM pos_order | ||
332 | 154 | # WHERE shop_id={0} AND sale_journal={1} AND user_id={2}; | ||
333 | 155 | # """.format(shop_id, sale_journal_id, user_id)) | ||
334 | 156 | # pos_order_ids = [] | ||
335 | 157 | # for pos_order_id in cr.fetchall(): | ||
336 | 158 | # pos_order_ids.append(pos_order_id[0]) | ||
337 | 159 | # | ||
338 | 160 | # pos_order_obj.write(cr, SUPERUSER_ID, pos_order_ids, {'session_id' : pos_session_id}) | ||
339 | 161 | |||
340 | 162 | def disable_default_pos_config(cr, pool): | ||
341 | 163 | pass | ||
342 | 164 | pos_config, pos_config_id = pool.get('ir.model.data').get_object_reference( | ||
343 | 165 | cr, SUPERUSER_ID, 'point_of_sale', 'pos_config_main') | ||
344 | 166 | pool.get('pos.config').write(cr, SUPERUSER_ID, | ||
345 | 167 | [pos_config_id], | ||
346 | 168 | {'state' : 'inactive'}) | ||
347 | 169 | |||
348 | 170 | |||
349 | 171 | @openupgrade.migrate() | ||
350 | 172 | def migrate(cr, version): | ||
351 | 173 | pool = pooler.get_pool(cr.dbname) | ||
352 | 174 | migrate_product_available_in_pos(cr, pool) | ||
353 | 175 | migrate_product_to_weight(cr, pool) | ||
354 | 176 | # create new pos_config | ||
355 | 177 | create_pos_config(cr, pool) | ||
356 | 178 | |||
357 | 179 | # disable old default pos_config | ||
358 | 180 | disable_default_pos_config(cr, pool) | ||
359 | 0 | 181 | ||
360 | === added file 'point_of_sale/migrations/7.0.1.0.1/pre-migration.py' | |||
361 | --- point_of_sale/migrations/7.0.1.0.1/pre-migration.py 1970-01-01 00:00:00 +0000 | |||
362 | +++ point_of_sale/migrations/7.0.1.0.1/pre-migration.py 2013-10-14 23:49:02 +0000 | |||
363 | @@ -0,0 +1,34 @@ | |||
364 | 1 | # -*- coding: utf-8 -*- | ||
365 | 2 | ############################################################################## | ||
366 | 3 | # | ||
367 | 4 | # OpenERP, Open Source Management Solution | ||
368 | 5 | # This module copyright (C) 2013 Sylvain LE GAL | ||
369 | 6 | # | ||
370 | 7 | # This program is free software: you can redistribute it and/or modify | ||
371 | 8 | # it under the terms of the GNU Affero General Public License as | ||
372 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
373 | 10 | # License, or (at your option) any later version. | ||
374 | 11 | # | ||
375 | 12 | # This program is distributed in the hope that it will be useful, | ||
376 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
377 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
378 | 15 | # GNU Affero General Public License for more details. | ||
379 | 16 | # | ||
380 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
381 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
382 | 19 | # | ||
383 | 20 | ############################################################################## | ||
384 | 21 | |||
385 | 22 | from openerp.openupgrade import openupgrade | ||
386 | 23 | |||
387 | 24 | column_renames = { | ||
388 | 25 | } | ||
389 | 26 | |||
390 | 27 | xmlid_renames = [ | ||
391 | 28 | ] | ||
392 | 29 | |||
393 | 30 | |||
394 | 31 | @openupgrade.migrate() | ||
395 | 32 | def migrate(cr, version): | ||
396 | 33 | openupgrade.rename_columns(cr, column_renames) | ||
397 | 34 | openupgrade.rename_xmlids(cr, xmlid_renames) | ||
398 | 0 | 35 | ||
399 | === added file 'point_of_sale/migrations/7.0.1.0.1/user_notes.txt' | |||
400 | --- point_of_sale/migrations/7.0.1.0.1/user_notes.txt 1970-01-01 00:00:00 +0000 | |||
401 | +++ point_of_sale/migrations/7.0.1.0.1/user_notes.txt 2013-10-14 23:49:02 +0000 | |||
402 | @@ -0,0 +1,14 @@ | |||
403 | 1 | Point of Sale V7 change the behaviour of the close of bank_statement. | ||
404 | 2 | It's not possible in V7 to close a session if there is some unpaid pos order in the session. | ||
405 | 3 | |||
406 | 4 | |||
407 | 5 | Point of sale V7 is very different. So The script migration will assume that | ||
408 | 6 | The users have used the point of sale V6.1 like a point of sale V7. Specially for the following things : | ||
409 | 7 | - a user can not sale (use a pos.config) if the pos.config is in use by an other user. | ||
410 | 8 | So script migration will create a pos.config for each sale user. | ||
411 | 9 | |||
412 | 10 | - | ||
413 | 11 | |||
414 | 12 | WARNING : standart V7 doesn't allow to close a pos.session (and so associated account.bank.statement) if a pos.order is not paid in the pos.session. | ||
415 | 13 | |||
416 | 14 |
My apologize for the mistake.
2013/10/15 Sylvain LE GAL (GRAP) <email address hidden>
> The proposal to merge /code.launchpad .net/~sylvain- legal/openupgra de-addons/ 7.0_point_ of_sale/ +merge/ 187221 /code.launchpad .net/~sylvain- legal/openupgra de-addons/ 7.0_point_ of_sale/ +merge/ 187221
> lp:~sylvain-legal/openupgrade-addons/7.0_point_of_sale into
> lp:openupgrade-addons has been updated.
>
> Status: Merged => Work in progress
>
> For more details, see:
>
> https:/
> --
>
> https:/
> You are the owner of
> lp:~sylvain-legal/openupgrade-addons/7.0_point_of_sale.
>