Merge lp:~openbig/bigconsulting/pack_barcode_check_616658 into lp:bigconsulting
- pack_barcode_check_616658
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 81 |
Proposed branch: | lp:~openbig/bigconsulting/pack_barcode_check_616658 |
Merge into: | lp:bigconsulting |
Diff against target: |
687 lines (+327/-223) 10 files modified
account_payment_discount_extension/account_payment_discount.py (+8/-1) account_payment_discount_extension/account_payment_discount_view.xml (+14/-3) account_payment_discount_extension/account_payment_disocunt_wizard.xml (+2/-1) account_payment_discount_extension/wizard/__init__.py (+2/-1) account_payment_discount_extension/wizard/wizard_discount_pay.py (+80/-0) account_payment_discount_extension/wizard/wizard_payment_discount_order.py (+217/-0) account_payment_discount_extension/wizard/wizard_payment_order1.py (+0/-205) packing_barcode_check/packing_barcode_check.py (+2/-9) packing_barcode_check/packing_barcode_check_view.xml (+0/-1) packing_barcode_check/wizard/scan_product.py (+2/-2) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/pack_barcode_check_616658 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+33868@code.launchpad.net |
Commit message
Description of the change
solve the bug 616658
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 'account_payment_discount_extension/account_payment_discount.py' |
2 | --- account_payment_discount_extension/account_payment_discount.py 2010-08-23 08:21:01 +0000 |
3 | +++ account_payment_discount_extension/account_payment_discount.py 2010-08-27 05:02:39 +0000 |
4 | @@ -48,7 +48,14 @@ |
5 | delay = payment_data[0].delay |
6 | self.write(cr, uid, [inv.id], {'next_payment_date':(datetime.now() + relativedelta(days=delay)).strftime('%Y-%m-%d')}) |
7 | return data |
8 | - |
9 | + |
10 | + def copy(self, cr, uid, id, default=None, context=None): |
11 | + if default is None: |
12 | + default = {} |
13 | + default = default.copy() |
14 | + default.update({'next_payment_date':False}) |
15 | + return super(account_invoice, self).copy(cr, uid, id, default, context) |
16 | + |
17 | account_invoice() |
18 | |
19 | class payment_line(osv.osv): |
20 | |
21 | === modified file 'account_payment_discount_extension/account_payment_discount_view.xml' |
22 | --- account_payment_discount_extension/account_payment_discount_view.xml 2010-08-23 07:25:41 +0000 |
23 | +++ account_payment_discount_extension/account_payment_discount_view.xml 2010-08-27 05:02:39 +0000 |
24 | @@ -34,7 +34,7 @@ |
25 | <field name="inherit_id" ref="account_payment_extension.view_payment_order_form_ext1"/> |
26 | <field name="arch" type="xml"> |
27 | <xpath expr="//button[@string='Select invoices to pay/receive payment']" position="replace"> |
28 | - <button name="%(wizard_populate_payment_ext111)d" string="Select invoices to pay/receive payment" type="action" attrs="{'invisible':[('state','=','done')]}"/> |
29 | + <button name="%(wizard_populate_payment_discount_ext)d" string="Select invoices to pay/receive payment" type="action" attrs="{'invisible':[('state','=','done')]}"/> |
30 | </xpath> |
31 | </field> |
32 | </record> |
33 | @@ -49,7 +49,6 @@ |
34 | <field name="cash_discount" /> |
35 | <field name="discount_date" /> |
36 | <field name="pay_amount" /> |
37 | - <label stirng=""/> |
38 | </xpath> |
39 | </field> |
40 | </record> |
41 | @@ -58,7 +57,7 @@ |
42 | <field name="name">payment.order.form1</field> |
43 | <field name="model">payment.order</field> |
44 | <field name="inherit_id" ref="account_payment.view_payment_order_form"/> |
45 | - <field name="type">form</field> |
46 | + <field name="type">tree</field> |
47 | <field name="arch" type="xml"> |
48 | <xpath expr="//tree/field[@name='amount']" position="after"> |
49 | <field name="cash_discount" /> |
50 | @@ -81,5 +80,17 @@ |
51 | </field> |
52 | </record> |
53 | |
54 | + <record id="view_payment_order_wizard_form" model="ir.ui.view"> |
55 | + <field name="name">payment.order.form1</field> |
56 | + <field name="model">payment.order</field> |
57 | + <field name="type">form</field> |
58 | + <field name="inherit_id" ref="account_payment.view_payment_order_form"/> |
59 | + <field name="arch" type="xml"> |
60 | + <xpath expr="//button[@string='Make Payments']" position="replace"> |
61 | + <button name="%(wizard_pay_discount_payment)d" states="open" string="Make Payments" type="action" /> |
62 | + </xpath> |
63 | + </field> |
64 | + </record> |
65 | + |
66 | </data> |
67 | </openerp> |
68 | |
69 | === modified file 'account_payment_discount_extension/account_payment_disocunt_wizard.xml' |
70 | --- account_payment_discount_extension/account_payment_disocunt_wizard.xml 2010-08-23 08:19:07 +0000 |
71 | +++ account_payment_discount_extension/account_payment_disocunt_wizard.xml 2010-08-27 05:02:39 +0000 |
72 | @@ -1,6 +1,7 @@ |
73 | <?xml version="1.0" encoding="utf-8"?> |
74 | <openerp> |
75 | <data> |
76 | - <wizard id="wizard_populate_payment_ext111" menu="True" model="payment.order" name="populate_payment_ext_filter" string="Populate payment to pay"/> |
77 | + <wizard id="wizard_populate_payment_discount_ext" menu="False" model="payment.order" name="populate_payment_discount_ext" string="Populate payment to pay"/> |
78 | + <wizard id="wizard_pay_discount_payment" menu="False" model="payment.order" name="pay_discount_payment" string="Pay"/> |
79 | </data> |
80 | </openerp> |
81 | |
82 | === modified file 'account_payment_discount_extension/wizard/__init__.py' |
83 | --- account_payment_discount_extension/wizard/__init__.py 2010-08-20 12:17:29 +0000 |
84 | +++ account_payment_discount_extension/wizard/__init__.py 2010-08-27 05:02:39 +0000 |
85 | @@ -20,7 +20,8 @@ |
86 | # |
87 | ############################################################################## |
88 | |
89 | -import wizard_payment_order1 |
90 | +import wizard_payment_discount_order |
91 | +import wizard_discount_pay |
92 | |
93 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
94 | |
95 | |
96 | === added file 'account_payment_discount_extension/wizard/wizard_discount_pay.py' |
97 | --- account_payment_discount_extension/wizard/wizard_discount_pay.py 1970-01-01 00:00:00 +0000 |
98 | +++ account_payment_discount_extension/wizard/wizard_discount_pay.py 2010-08-27 05:02:39 +0000 |
99 | @@ -0,0 +1,80 @@ |
100 | +# -*- encoding: utf-8 -*- |
101 | +############################################################################## |
102 | +# |
103 | +# OpenERP, Open Source Management Solution |
104 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
105 | +# $Id$ |
106 | +# |
107 | +# This program is free software: you can redistribute it and/or modify |
108 | +# it under the terms of the GNU General Public License as published by |
109 | +# the Free Software Foundation, either version 3 of the License, or |
110 | +# (at your option) any later version. |
111 | +# |
112 | +# This program is distributed in the hope that it will be useful, |
113 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
114 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
115 | +# GNU General Public License for more details. |
116 | +# |
117 | +# You should have received a copy of the GNU General Public License |
118 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
119 | +# |
120 | +############################################################################## |
121 | + |
122 | +import wizard |
123 | +from osv import osv |
124 | +import pooler |
125 | +from osv import fields |
126 | +import time |
127 | + |
128 | + |
129 | +def _launch_wizard(self, cr, uid, data, context): |
130 | + """ |
131 | + Search for a wizard to launch according to the type. |
132 | + If type is manual. just confirm the order. |
133 | + """ |
134 | + pool = pooler.get_pool(cr.dbname) |
135 | + order_ref = pool.get('payment.order') |
136 | + order_line = pool.get('payment.line') |
137 | + order = order_ref.browse(cr,uid,data['id'],context) |
138 | + invoice_obj = pool.get('account.invoice') |
139 | + |
140 | + t= order.mode and order.mode.type.code or 'manual' |
141 | + if t == 'manual' : |
142 | + order_ref.set_done(cr,uid,data['id'],context) |
143 | + return {} |
144 | + |
145 | + journal_id = order.mode.journal.id |
146 | + period_ids = pool.get('account.period').find(cr, uid, context=context) |
147 | + |
148 | + for pay_line in order.line_ids: |
149 | + invoice_data = invoice_obj.browse(cr, uid, pay_line.move_line_id.invoice.id, context=context) |
150 | + account_id = order.mode.journal.default_credit_account_id and order.mode.journal.default_credit_account_id.id #invoice_data.partner_id.property_account_payable.id |
151 | + invoice_obj.pay_and_reconcile(cr, uid, [invoice_data.id], |
152 | + pay_line.amount_currency, account_id, period_ids[0], journal_id, False, |
153 | + period_ids[0], journal_id, context, pay_line.name) |
154 | + |
155 | + gw = order_ref.get_wizard(t) |
156 | + if not gw: |
157 | + order_ref.set_done(cr,uid,data['id'],context) |
158 | + return {} |
159 | + |
160 | + mod_obj = pool.get('ir.model.data') |
161 | + act_obj = pool.get('ir.actions.wizard') |
162 | + module, wizard= gw |
163 | + result = mod_obj._get_id(cr, uid, module, wizard) |
164 | + id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] |
165 | + result = act_obj.read(cr, uid, [id])[0] |
166 | + #result['context'] = str({'fiscalyear': data['form']['fiscalyear']}) |
167 | + return result |
168 | + |
169 | +class wizard_pay(wizard.interface): |
170 | + |
171 | + states= {'init' : {'actions': [], |
172 | + 'result':{'type':'action', |
173 | + 'action':_launch_wizard, |
174 | + 'state':'end'} |
175 | + } |
176 | + } |
177 | +wizard_pay('pay_discount_payment') |
178 | + |
179 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
180 | |
181 | === added file 'account_payment_discount_extension/wizard/wizard_payment_discount_order.py' |
182 | --- account_payment_discount_extension/wizard/wizard_payment_discount_order.py 1970-01-01 00:00:00 +0000 |
183 | +++ account_payment_discount_extension/wizard/wizard_payment_discount_order.py 2010-08-27 05:02:39 +0000 |
184 | @@ -0,0 +1,217 @@ |
185 | +# -*- encoding: utf-8 -*- |
186 | +############################################################################## |
187 | +# |
188 | +# OpenERP, Open Source Management Solution |
189 | +# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
190 | +# $Id$ |
191 | +# |
192 | +# This program is free software: you can redistribute it and/or modify |
193 | +# it under the terms of the GNU General Public License as published by |
194 | +# the Free Software Foundation, either version 3 of the License, or |
195 | +# (at your option) any later version. |
196 | +# |
197 | +# This program is distributed in the hope that it will be useful, |
198 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
199 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
200 | +# GNU General Public License for more details. |
201 | +# |
202 | +# You should have received a copy of the GNU General Public License |
203 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
204 | +# |
205 | +############################################################################## |
206 | + |
207 | +import wizard |
208 | +import pooler |
209 | +from tools.misc import UpdateableStr |
210 | +import time |
211 | + |
212 | + |
213 | +FORM = UpdateableStr() |
214 | + |
215 | +FIELDS = { |
216 | + 'entries': {'string':'Entries', 'type':'many2many', 'relation':'account.move.line',}, |
217 | + 'communication2': {'string':'Communication 2', 'type':'char', 'size': 64, 'help':'The successor message of payment communication.'}, |
218 | +} |
219 | + |
220 | +field_duedate={ |
221 | + 'duedate': {'string':'Due Date', 'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d'),}, |
222 | + 'amount': {'string':'Amount', 'type':'float', 'help': 'Next step will automatically select payments up to this amount.'} |
223 | + } |
224 | +arch_duedate='''<?xml version="1.0" encoding="utf-8"?> |
225 | +<form string="Search Payment lines" col="2"> |
226 | + <field name="duedate" /> |
227 | + <field name="amount" /> |
228 | +</form>''' |
229 | + |
230 | + |
231 | +def search_entries(self, cr, uid, data, context): |
232 | + |
233 | + search_due_date = data['form']['duedate'] |
234 | + pool = pooler.get_pool(cr.dbname) |
235 | + order_obj = pool.get('payment.order') |
236 | + line_obj = pool.get('account.move.line') |
237 | + invoice_obj = pool.get('account.invoice') |
238 | + payment = order_obj.browse(cr, uid, data['id'], |
239 | + context=context) |
240 | + ctx = '' |
241 | + if payment.mode: |
242 | + ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id |
243 | + |
244 | + # Search for move line to pay: |
245 | + domain = [('reconcile_id', '=', False),('account_id.type', '=', payment.type)]#,('account_id.type', '=', payment.type),('amount_to_pay', '<>', 0)] |
246 | +# domain = domain + ['|',('date_maturity','<',search_due_date),('date_maturity','=',False)] |
247 | + #if payment.mode: |
248 | + # domain = [('payment_type','=',payment.mode.type.id)] + domain |
249 | + sel_line_ids = line_obj.search(cr, uid, domain, order='date_maturity', context=context) |
250 | + line_ids = [] |
251 | + |
252 | + for line in line_obj.browse(cr, uid, sel_line_ids, context): |
253 | + if line.invoice.id: |
254 | + invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context) |
255 | + if invoice_data.next_payment_date: |
256 | + if invoice_data.next_payment_date >=search_due_date: |
257 | + line_ids.append(line.id) |
258 | + |
259 | + FORM.string = '''<?xml version="1.0" encoding="utf-8"?> |
260 | +<form string="Populate Payment:"> |
261 | + <field name="entries" colspan="4" height="300" width="800" nolabel="1" |
262 | + domain="[('id', 'in', [%s])]" %s/> |
263 | + <separator string="Extra message of payment communication" colspan="4"/> |
264 | + <field name="communication2" colspan="4"/> |
265 | +</form>''' % (','.join([str(x) for x in line_ids]), ctx) |
266 | + |
267 | + selected_ids = [] |
268 | + amount = data['form']['amount'] |
269 | + if amount: |
270 | + if payment.mode and payment.mode.require_bank_account: |
271 | + line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context) |
272 | + else: |
273 | + line2bank = None |
274 | + # If user specified an amount, search what moves match the criteria taking into account |
275 | + # if payment mode allows bank account to be null. |
276 | + for line in line_obj.browse(cr, uid, line_ids, context): |
277 | + if abs(line.amount_to_pay) <= amount: |
278 | + if line2bank and not line2bank.get(line.id): |
279 | + continue |
280 | + amount -= abs(line.amount_to_pay) |
281 | + selected_ids.append(line.id) |
282 | + return { |
283 | + 'entries': selected_ids, |
284 | + } |
285 | + |
286 | +def create_payment(self, cr, uid, data, context): |
287 | + line_ids= data['form']['entries'][0][2] |
288 | + if not line_ids: return {} |
289 | + |
290 | + pool= pooler.get_pool(cr.dbname) |
291 | + order_obj = pool.get('payment.order') |
292 | + order_line_obj = pool.get('payment.line') |
293 | + line_obj = pool.get('account.move.line') |
294 | + invoice_obj = pool.get('account.invoice') |
295 | + payment_term_obj = pool.get('account.payment.term') |
296 | + |
297 | + tax_obj = pool.get('account.tax') |
298 | + invoice_tax_obj = pool.get("account.invoice.tax") |
299 | + |
300 | + payment = order_obj.browse(cr, uid, data['id'], |
301 | + context=context) |
302 | + t = payment.mode and payment.mode.type.id or None |
303 | + line2bank = pool.get('account.move.line').line2bank(cr, uid, |
304 | + line_ids, t, context) |
305 | + |
306 | + ## Finally populate the current payment with new lines: |
307 | + |
308 | + for line in line_obj.browse(cr, uid, line_ids, context=context): |
309 | + invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context) |
310 | + discount = 0.0 |
311 | + account = False |
312 | + payment_data = payment_term_obj.browse(cr, uid, invoice_data.payment_term.id).cash_discount_ids |
313 | + |
314 | + if payment_data: |
315 | + cash_discount = payment_data[0].discount |
316 | + discount = invoice_data.amount_total * cash_discount /100 |
317 | + account =payment_data[0].sup_discount_account_id.id |
318 | + dis_next_date = invoice_data.next_payment_date |
319 | + |
320 | + if payment.date_prefered == "now": |
321 | + #no payment date => immediate payment |
322 | + date_to_pay = False |
323 | + elif payment.date_prefered == 'due': |
324 | + date_to_pay = line.date_maturity |
325 | + elif payment.date_prefered == 'fixed': |
326 | + date_to_pay = payment.date_planned |
327 | + |
328 | + order_line_obj.create(cr,uid,{ |
329 | + 'move_line_id': line.id, |
330 | + 'amount_currency': line.amount_to_pay, |
331 | + 'bank_id': line2bank.get(line.id), |
332 | + 'order_id': payment.id, |
333 | + 'partner_id': line.partner_id and line.partner_id.id or False, |
334 | + 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/', |
335 | + 'communication2': data['form']['communication2'], |
336 | + 'date': date_to_pay, |
337 | + 'currency': line.invoice and line.invoice.currency_id.id or False, |
338 | + 'account_id': line.account_id.id, |
339 | + 'cash_discount':discount, |
340 | + 'discount_date':dis_next_date, |
341 | + 'pay_amount':(line.amount_to_pay-discount), |
342 | + }, context=context) |
343 | + |
344 | + return {} |
345 | + |
346 | +def _get_defaults(self, cr, uid, data, context): |
347 | + pool= pooler.get_pool(cr.dbname) |
348 | + order_obj = pool.get('payment.order') |
349 | + plan_date = order_obj.browse(cr, uid, data['id'], context=context).date_planned |
350 | + data['form']['duedate'] = plan_date |
351 | + return data['form'] |
352 | + |
353 | +class wizard_payment_order(wizard.interface): |
354 | + """ |
355 | + Create a payment object with lines corresponding to the account move line |
356 | + to pay according to the date provided by the user and the mode-type payment of the order. |
357 | + Hypothesis: |
358 | + - Small number of non-reconcilied move line , payment mode and bank account type, |
359 | + - Big number of partner and bank account. |
360 | + |
361 | + If a type is given, unsuitable account move lines are ignored. |
362 | + """ |
363 | + states = { |
364 | + |
365 | + 'init': { |
366 | + 'actions': [_get_defaults], |
367 | + 'result': { |
368 | + 'type': 'form', |
369 | + 'arch': arch_duedate, |
370 | + 'fields':field_duedate, |
371 | + 'state': [ |
372 | + ('end','_Cancel'), |
373 | + ('search','_Search', '', True) |
374 | + ] |
375 | + }, |
376 | + }, |
377 | + |
378 | + 'search': { |
379 | + 'actions': [search_entries], |
380 | + 'result': { |
381 | + 'type': 'form', |
382 | + 'arch': FORM, |
383 | + 'fields': FIELDS, |
384 | + 'state': [ |
385 | + ('end','_Cancel'), |
386 | + ('create','_Add to payment order', '', True) |
387 | + ] |
388 | + }, |
389 | + }, |
390 | + 'create': { |
391 | + 'actions': [], |
392 | + 'result': { |
393 | + 'type': 'action', |
394 | + 'action': create_payment, |
395 | + 'state': 'end'} |
396 | + }, |
397 | + } |
398 | + |
399 | +wizard_payment_order('populate_payment_discount_ext') |
400 | + |
401 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
402 | \ No newline at end of file |
403 | |
404 | === removed file 'account_payment_discount_extension/wizard/wizard_payment_order1.py' |
405 | --- account_payment_discount_extension/wizard/wizard_payment_order1.py 2010-08-23 08:19:07 +0000 |
406 | +++ account_payment_discount_extension/wizard/wizard_payment_order1.py 1970-01-01 00:00:00 +0000 |
407 | @@ -1,205 +0,0 @@ |
408 | -# -*- encoding: utf-8 -*- |
409 | -############################################################################## |
410 | -# |
411 | -# OpenERP, Open Source Management Solution |
412 | -# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
413 | -# $Id$ |
414 | -# |
415 | -# This program is free software: you can redistribute it and/or modify |
416 | -# it under the terms of the GNU General Public License as published by |
417 | -# the Free Software Foundation, either version 3 of the License, or |
418 | -# (at your option) any later version. |
419 | -# |
420 | -# This program is distributed in the hope that it will be useful, |
421 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
422 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
423 | -# GNU General Public License for more details. |
424 | -# |
425 | -# You should have received a copy of the GNU General Public License |
426 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
427 | -# |
428 | -############################################################################## |
429 | - |
430 | -import wizard |
431 | -import pooler |
432 | -from tools.misc import UpdateableStr |
433 | -import time |
434 | - |
435 | - |
436 | -FORM = UpdateableStr() |
437 | - |
438 | -FIELDS = { |
439 | - 'entries': {'string':'Entries', 'type':'many2many', 'relation':'account.move.line',}, |
440 | - 'communication2': {'string':'Communication 2', 'type':'char', 'size': 64, 'help':'The successor message of payment communication.'}, |
441 | -} |
442 | - |
443 | -field_duedate={ |
444 | - 'duedate': {'string':'Due Date', 'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d'),}, |
445 | - 'amount': {'string':'Amount', 'type':'float', 'help': 'Next step will automatically select payments up to this amount.'} |
446 | - } |
447 | -arch_duedate='''<?xml version="1.0" encoding="utf-8"?> |
448 | -<form string="Search Payment lines" col="2"> |
449 | - <field name="duedate" /> |
450 | - <field name="amount" /> |
451 | -</form>''' |
452 | - |
453 | - |
454 | -def search_entries(self, cr, uid, data, context): |
455 | - |
456 | - search_due_date = data['form']['duedate'] |
457 | - pool = pooler.get_pool(cr.dbname) |
458 | - order_obj = pool.get('payment.order') |
459 | - line_obj = pool.get('account.move.line') |
460 | - invoice_obj = pool.get('account.invoice') |
461 | - payment = order_obj.browse(cr, uid, data['id'], |
462 | - context=context) |
463 | - ctx = '' |
464 | - if payment.mode: |
465 | - ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id |
466 | - |
467 | - # Search for move line to pay: |
468 | - domain = [('reconcile_id', '=', False)]#,('account_id.type', '=', payment.type),('amount_to_pay', '<>', 0)] |
469 | -# domain = domain + ['|',('date_maturity','<',search_due_date),('date_maturity','=',False)] |
470 | - #if payment.mode: |
471 | - # domain = [('payment_type','=',payment.mode.type.id)] + domain |
472 | - sel_line_ids = line_obj.search(cr, uid, domain, order='date_maturity', context=context) |
473 | - line_ids = [] |
474 | - |
475 | - for line in line_obj.browse(cr, uid, sel_line_ids, context): |
476 | - if line.invoice.id: |
477 | - invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context) |
478 | - if invoice_data.next_payment_date: |
479 | - if invoice_data.next_payment_date >=search_due_date: |
480 | - line_ids.append(line.id) |
481 | - |
482 | - FORM.string = '''<?xml version="1.0" encoding="utf-8"?> |
483 | - <form string="Populate Payment:"> |
484 | - <field name="entries" colspan="4" height="300" width="800" nolabel="1" |
485 | - domain="[('id', 'in', [%s])]" %s/> |
486 | - <separator string="Extra message of payment communication" colspan="4"/> |
487 | - <field name="communication2" colspan="4"/> |
488 | - </form>''' % (','.join([str(x) for x in line_ids]), ctx) |
489 | - |
490 | - selected_ids = [] |
491 | - amount = data['form']['amount'] |
492 | - if amount: |
493 | - if payment.mode and payment.mode.require_bank_account: |
494 | - line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context) |
495 | - else: |
496 | - line2bank = None |
497 | - # If user specified an amount, search what moves match the criteria taking into account |
498 | - # if payment mode allows bank account to be null. |
499 | - for line in line_obj.browse(cr, uid, line_ids, context): |
500 | - if abs(line.amount_to_pay) <= amount: |
501 | - if line2bank and not line2bank.get(line.id): |
502 | - continue |
503 | - amount -= abs(line.amount_to_pay) |
504 | - selected_ids.append(line.id) |
505 | - return { |
506 | - 'entries': selected_ids, |
507 | - } |
508 | - |
509 | -def create_payment(self, cr, uid, data, context): |
510 | - line_ids= data['form']['entries'][0][2] |
511 | - if not line_ids: return {} |
512 | - |
513 | - pool= pooler.get_pool(cr.dbname) |
514 | - order_obj = pool.get('payment.order') |
515 | - line_obj = pool.get('account.move.line') |
516 | - invoice_obj = pool.get('account.invoice') |
517 | - payment_term_obj = pool.get('account.payment.term') |
518 | - payment_line = pool.get('payment.line') |
519 | - payment = order_obj.browse(cr, uid, data['id'], |
520 | - context=context) |
521 | - t = payment.mode and payment.mode.type.id or None |
522 | - line2bank = line_obj.line2bank(cr, uid, |
523 | - line_ids, t, context) |
524 | - |
525 | - ## Finally populate the current payment with new lines: |
526 | - |
527 | - for line in line_obj.browse(cr, uid, line_ids, context=context): |
528 | - |
529 | - invoice_data = invoice_obj.browse(cr, uid, line.invoice.id, context=context) |
530 | - discount = 0.0 |
531 | - payment_data = payment_term_obj.browse(cr, uid, invoice_data.payment_term.id).cash_discount_ids |
532 | - if payment_data: |
533 | - cash_discount = payment_data[0].discount |
534 | - discount = invoice_data.amount_total * cash_discount /100 |
535 | - dis_next_date = invoice_data.next_payment_date |
536 | - |
537 | - if payment.date_prefered == "now": |
538 | - #no payment date => immediate payment |
539 | - date_to_pay = False |
540 | - elif payment.date_prefered == 'due': |
541 | - date_to_pay = line.date_maturity |
542 | - elif payment.date_prefered == 'fixed': |
543 | - date_to_pay = payment.date_planned |
544 | - |
545 | - payment_line.create(cr,uid,{ |
546 | - 'move_line_id': line.id, |
547 | - 'amount_currency': line.amount_to_pay, |
548 | - 'bank_id': line2bank.get(line.id), |
549 | - 'order_id': payment.id, |
550 | - 'partner_id': line.partner_id and line.partner_id.id or False, |
551 | - 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/', |
552 | - 'communication2': data['form']['communication2'], |
553 | - 'date': date_to_pay, |
554 | - 'currency': line.invoice and line.invoice.currency_id.id or False, |
555 | - 'account_id': line.account_id.id, |
556 | - 'cash_discount':discount, |
557 | - 'discount_date':dis_next_date, |
558 | - 'pay_amount':(line.amount_to_pay+discount), |
559 | - }, context=context) |
560 | - |
561 | - return {} |
562 | - |
563 | - |
564 | -class wizard_payment_order(wizard.interface): |
565 | - """ |
566 | - Create a payment object with lines corresponding to the account move line |
567 | - to pay according to the date provided by the user and the mode-type payment of the order. |
568 | - Hypothesis: |
569 | - - Small number of non-reconcilied move line , payment mode and bank account type, |
570 | - - Big number of partner and bank account. |
571 | - |
572 | - If a type is given, unsuitable account move lines are ignored. |
573 | - """ |
574 | - states = { |
575 | - |
576 | - 'init': { |
577 | - 'actions': [], |
578 | - 'result': { |
579 | - 'type': 'form', |
580 | - 'arch': arch_duedate, |
581 | - 'fields':field_duedate, |
582 | - 'state': [ |
583 | - ('end','_Cancel'), |
584 | - ('search','_Search', '', True) |
585 | - ] |
586 | - }, |
587 | - }, |
588 | - |
589 | - 'search': { |
590 | - 'actions': [search_entries], |
591 | - 'result': { |
592 | - 'type': 'form', |
593 | - 'arch': FORM, |
594 | - 'fields': FIELDS, |
595 | - 'state': [ |
596 | - ('end','_Cancel'), |
597 | - ('create','_Add to payment order', '', True) |
598 | - ] |
599 | - }, |
600 | - }, |
601 | - 'create': { |
602 | - 'actions': [], |
603 | - 'result': { |
604 | - 'type': 'action', |
605 | - 'action': create_payment, |
606 | - 'state': 'end'} |
607 | - }, |
608 | - } |
609 | - |
610 | -wizard_payment_order('populate_payment_ext_filter') |
611 | - |
612 | -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
613 | |
614 | === modified file 'packing_barcode_check/packing_barcode_check.py' |
615 | --- packing_barcode_check/packing_barcode_check.py 2010-08-18 12:56:59 +0000 |
616 | +++ packing_barcode_check/packing_barcode_check.py 2010-08-27 05:02:39 +0000 |
617 | @@ -85,19 +85,12 @@ |
618 | _inherit = "stock.move" |
619 | _columns = { |
620 | 'scaned_qty':fields.float("Scanned Qty"), |
621 | - 'unscaned_qty':fields.float("Unscanned Qty"), |
622 | } |
623 | |
624 | _defaults = { |
625 | 'scaned_qty' : lambda *a:0.0, |
626 | } |
627 | |
628 | - def onchange_quantity(self, cr, uid, ids, product_id, product_qty, product_uom, product_uos): |
629 | - |
630 | - result = super(stock_move, self).onchange_quantity(cr, uid, ids, product_id, product_qty, product_uom, product_uos) |
631 | - if product_id: |
632 | - result['value']['unscaned_qty'] = product_qty |
633 | - return result |
634 | stock_move() |
635 | |
636 | class tobe_scanned_stock(osv.osv): |
637 | @@ -109,7 +102,7 @@ |
638 | 'lot_number':fields.many2one('stock.production.lot','Lot Number', size=64), |
639 | 'quantity':fields.float("Quantity"), |
640 | 'scan_quantity':fields.float("Scanned Quantity"), |
641 | - 'unscan_quantity':fields.float("Unscanned Quantity"), |
642 | + 'unscan_quantity':fields.float("Unscanned Quantity",), |
643 | } |
644 | |
645 | def init(self, cr): |
646 | @@ -121,7 +114,7 @@ |
647 | l.picking_id AS tobe_picking_id, |
648 | sum(l.scaned_qty) AS scan_quantity, |
649 | sum(l.product_qty) AS quantity, |
650 | - sum(l.unscaned_qty) AS unscan_quantity, |
651 | + sum(l.product_qty-l.scaned_qty) AS unscan_quantity, |
652 | l.prodlot_id AS lot_number, |
653 | l.product_id AS product_name |
654 | FROM |
655 | |
656 | === modified file 'packing_barcode_check/packing_barcode_check_view.xml' |
657 | --- packing_barcode_check/packing_barcode_check_view.xml 2010-08-18 12:56:59 +0000 |
658 | +++ packing_barcode_check/packing_barcode_check_view.xml 2010-08-27 05:02:39 +0000 |
659 | @@ -106,7 +106,6 @@ |
660 | <field name="arch" type="xml"> |
661 | <xpath expr="//field[@name='product_qty']" position="after"> |
662 | <field name="scaned_qty"/> |
663 | - <field name="unscaned_qty"/> |
664 | </xpath> |
665 | </field> |
666 | </record> |
667 | |
668 | === modified file 'packing_barcode_check/wizard/scan_product.py' |
669 | --- packing_barcode_check/wizard/scan_product.py 2010-08-19 05:51:29 +0000 |
670 | +++ packing_barcode_check/wizard/scan_product.py 2010-08-27 05:02:39 +0000 |
671 | @@ -62,7 +62,7 @@ |
672 | raise osv.except_osv(_('Warning!'), |
673 | _('Unscanned quantity does not match with the product packaging quantity')) |
674 | |
675 | - stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+quantity, 'unscaned_qty':move_data.unscaned_qty-quantity}, context=context) |
676 | + stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+quantity}, context=context) |
677 | wkf_service = netsvc.LocalService("workflow") |
678 | wkf_service.trg_validate(uid, 'stock.picking', picking_id[0], 'button_scanned', cr) |
679 | |
680 | @@ -107,7 +107,7 @@ |
681 | if check_qty < quantity: |
682 | raise osv.except_osv(_('Warning!'), |
683 | _('Unscanned quantity does not match with the product packaging quantity')) |
684 | - move_obj.write(cr, uid, [stock_move_obj.id],{'scaned_qty':stock_move_obj.scaned_qty+quantity,'unscaned_qty':stock_move_obj.unscaned_qty-quantity}, context=context) |
685 | + move_obj.write(cr, uid, [stock_move_obj.id],{'scaned_qty':stock_move_obj.scaned_qty+quantity}, context=context) |
686 | wkf_service = netsvc.LocalService("workflow") |
687 | wkf_service.trg_validate(uid, 'stock.picking', picking_ids[0], 'button_scanned', cr) |
688 |