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