Merge lp:~vxkikevx/addons-cluster/payment_statement into lp:addons-cluster

Proposed by Eduardo Ochoa - Cluster Brands
Status: Merged
Merged at revision: 125
Proposed branch: lp:~vxkikevx/addons-cluster/payment_statement
Merge into: lp:addons-cluster
Diff against target: 286 lines (+184/-4)
9 files modified
payment_instrument/__openerp__.py (+1/-0)
payment_instrument/model/__init__.py (+2/-0)
payment_instrument/model/account_bank_statement.py (+14/-0)
payment_instrument/model/payment_instrument.py (+2/-0)
payment_instrument/model/point_of_sale.py (+113/-0)
payment_instrument/static/src/js/models.js (+12/-1)
payment_instrument/view/account_view.xml (+24/-3)
payment_instrument/view/payment_instrument_view.xml (+1/-0)
payment_instrument/view/point_of_sale_view.xml (+15/-0)
To merge this branch: bzr merge lp:~vxkikevx/addons-cluster/payment_statement
Reviewer Review Type Date Requested Status
Eduardo Ochoa - Cluster Brands Pending
Review via email: mp+186446@code.launchpad.net

Description of the change

-Modified some views to display the payment instruments.
-Added some fields needed to process the lots

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 'payment_instrument/__openerp__.py'
2--- payment_instrument/__openerp__.py 2013-08-29 20:46:46 +0000
3+++ payment_instrument/__openerp__.py 2013-09-18 21:07:20 +0000
4@@ -47,6 +47,7 @@
5 'data': [
6 'view/account_view.xml',
7 'view/payment_instrument_view.xml',
8+ 'view/point_of_sale_view.xml',
9 ],
10 'js': [
11 'static/src/js/backbone-super-min.js',
12
13=== modified file 'payment_instrument/model/__init__.py'
14--- payment_instrument/model/__init__.py 2013-08-22 16:09:03 +0000
15+++ payment_instrument/model/__init__.py 2013-09-18 21:07:20 +0000
16@@ -1,2 +1,4 @@
17 import account
18 import payment_instrument
19+import account_bank_statement
20+import point_of_sale
21
22=== added file 'payment_instrument/model/account_bank_statement.py'
23--- payment_instrument/model/account_bank_statement.py 1970-01-01 00:00:00 +0000
24+++ payment_instrument/model/account_bank_statement.py 2013-09-18 21:07:20 +0000
25@@ -0,0 +1,14 @@
26+from openerp.osv import fields, osv
27+from openerp import tools
28+from openerp.tools.translate import _
29+
30+from osv import osv
31+from osv import fields
32+
33+class account_bank_statement(osv.Model):
34+ _inherit = 'account.bank.statement'
35+ _columns = {
36+ 'instrument_id':fields.many2one('payment_instrument.instrument',
37+ 'Payment Instrument', help="""Payment Instrument linked to Statement"""),
38+ }
39+ _order = 'journal_id, instrument_id'
40
41=== modified file 'payment_instrument/model/payment_instrument.py'
42--- payment_instrument/model/payment_instrument.py 2013-08-21 21:12:57 +0000
43+++ payment_instrument/model/payment_instrument.py 2013-09-18 21:07:20 +0000
44@@ -72,6 +72,8 @@
45 ('fix', 'Fixed Amount')],
46 'Amount Type', required=True,
47 help="The computation method for the rule amount."),
48+ 'condition_account_id':fields.many2one('account.account', """Imputing Condition Account""",
49+ help="""Account to imputing computation of condition"""),
50 'amount_fix': fields.float('Fixed Amount'),
51 'amount_percentage': fields.float('Percentage (%)'),
52 }
53
54=== added file 'payment_instrument/model/point_of_sale.py'
55--- payment_instrument/model/point_of_sale.py 1970-01-01 00:00:00 +0000
56+++ payment_instrument/model/point_of_sale.py 2013-09-18 21:07:20 +0000
57@@ -0,0 +1,113 @@
58+from datetime import datetime
59+from dateutil.relativedelta import relativedelta
60+from decimal import Decimal
61+import logging
62+import pdb
63+import time
64+
65+from openerp.osv import fields, osv
66+from openerp import tools
67+from openerp.tools.translate import _
68+
69+from osv import osv
70+from osv import fields
71+
72+class pos_session(osv.Model):
73+ _inherit = 'pos.session'
74+
75+ def create(self, cr, uid, values, context=None):
76+ context = context or {}
77+
78+ res = super(pos_session, self).create(cr, uid, values, context=context)
79+ ses_brw = self.browse(cr,uid,res,context=context)
80+
81+ statement_obj = self.pool.get('account.bank.statement')
82+
83+ config_id = ses_brw.config_id.id
84+
85+ jobj = self.pool.get('pos.config')
86+
87+ pos_config = jobj.browse(cr, uid, config_id, context=context)
88+ bank_statement_ids = []
89+ for journal in pos_config.journal_ids:
90+ if journal.payment_instrument_ids:
91+ for inst in journal.payment_instrument_ids:
92+ stmt_id = statement_obj.search(cr, uid, [('pos_session_id','=',res),
93+ ('instrument_id','=',False),
94+ ('journal_id','=',journal.id)],
95+ context=context)
96+ if stmt_id:
97+ #actualizar instrument (inst.id) en el statement
98+ statement_obj.write(cr, uid, [stmt_id[0]], {'instrument_id' : inst.id }, context=context)
99+ bank_statement_ids.append(stmt_id[0])
100+ else:
101+ #crear bank statememt
102+ st_number = self.pool.get('ir.sequence').next_by_id(cr, uid,
103+ journal.sequence_id.id, context=context)
104+ bank_values = {
105+ 'journal_id' : journal.id,
106+ 'instrument_id': inst.id,
107+ 'user_id' : uid,
108+ 'state': 'open',
109+ 'name': st_number,
110+ 'pos_session_id': res,
111+ 'company_id' : pos_config.shop_id.company_id.id
112+ }
113+ statement_id = statement_obj.create(cr, uid, bank_values, context=context)
114+ bank_statement_ids.append(statement_id)
115+ else:
116+ stmt_id = statement_obj.search(cr, uid, [('pos_session_id','=',res),
117+ ('journal_id','=',journal.id)],
118+ context=context)
119+ bank_statement_ids.append(stmt_id[0])
120+
121+ self.pool.get('pos.session').write(cr, uid, res, {'statement_ids':[(6, 0,
122+ bank_statement_ids)]}, context=context)
123+
124+ return res
125+
126+class pos_order(osv.Model):
127+ _inherit = 'pos.order'
128+
129+ def add_payment(self, cr, uid, order_id, data, context=None):
130+ """Create a new payment for the order"""
131+ if not context:
132+ context = {}
133+ statement_line_obj = self.pool.get('account.bank.statement.line')
134+ property_obj = self.pool.get('ir.property')
135+ order = self.browse(cr, uid, order_id, context=context)
136+ args = {
137+ 'amount': data['amount'],
138+ 'date': data.get('payment_date', time.strftime('%Y-%m-%d')),
139+ 'name': order.name + ': ' + (data.get('payment_name', '') or ''),
140+ }
141+
142+ account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
143+ args['account_id'] = (order.partner_id and order.partner_id.property_account_receivable \
144+ and order.partner_id.property_account_receivable.id) or (account_def and account_def.id) or False
145+ args['partner_id'] = order.partner_id and order.partner_id.id or None
146+
147+ if not args['account_id']:
148+ if not args['partner_id']:
149+ msg = _('There is no receivable account defined to make payment.')
150+ else:
151+ msg = _('There is no receivable account defined to make payment for the partner: "%s" (id:%d).') % (order.partner_id.name, order.partner_id.id,)
152+ raise osv.except_osv(_('Configuration Error!'), msg)
153+
154+ context.pop('pos_session_id', False)
155+
156+ journal_id = data.get('journal', False)
157+ statement_id = data.get('statement_id', False)
158+ assert journal_id or statement_id, "No statement_id or journal_id passed to the method!"
159+
160+ args.update({
161+ 'statement_id' : statement_id,
162+ 'pos_statement_id' : order_id,
163+ 'journal_id' : journal_id,
164+ 'type' : 'customer',
165+ 'ref' : order.session_id.name,
166+ })
167+
168+ statement_line_obj.create(cr, uid, args, context=context)
169+
170+ return statement_id
171
172=== modified file 'payment_instrument/static/src/js/models.js'
173--- payment_instrument/static/src/js/models.js 2013-09-04 16:27:19 +0000
174+++ payment_instrument/static/src/js/models.js 2013-09-18 21:07:20 +0000
175@@ -28,6 +28,16 @@
176 journal = _(journals).find(function(j) {
177 return j.id == instrument.journal_id[0]
178 })
179+ self.fetch(
180+ 'account.bank.statement',
181+ ['id'], [['state','=','open'], ['journal_id','=',journal.id],
182+ ['pos_session_id', '=', self.get('pos_session').id],
183+ ['instrument_id','=',instrument.id]]
184+ ).then(function(stm){
185+ if (stm.length > 0) {
186+ instrument.statement_id = stm[0].id;
187+ }
188+ });
189 instrument.journal_name = journal.name;
190 instrument.journal_id = journal.id;
191 instrument.journal_image = instance.session.url('/web/binary/image', {model: 'account.journal', field: 'image_small', id: journal.id});
192@@ -47,6 +57,7 @@
193 if (instrument)
194 _(data).extend({
195 "instrument_id": instrument.id,
196+ "statement_id": instrument.statement_id,
197 });
198 return data;
199
200@@ -62,4 +73,4 @@
201 return data;
202 },
203 })
204-}
205\ No newline at end of file
206+}
207
208=== modified file 'payment_instrument/view/account_view.xml'
209--- payment_instrument/view/account_view.xml 2013-08-21 21:12:57 +0000
210+++ payment_instrument/view/account_view.xml 2013-09-18 21:07:20 +0000
211@@ -1,4 +1,4 @@
212-<?xml version="1.0" encoding="UTF-8"?>
213+<?xml version="1.0"?>
214 <openerp>
215 <data>
216 <record model="ir.ui.view" id="view_account_journal_payment_instrument_form">
217@@ -7,7 +7,7 @@
218 <field name="inherit_id" ref="account.view_account_journal_form"/>
219 <field name="arch" type="xml">
220 <xpath expr="//div[@class='oe_title']" position="before">
221- <field name="image_small" widget="image" class="oe_avatar oe_left"/>
222+ <field name="image_small" widget="image" class="oe_avatar oe_left"/>
223 </xpath>
224 <xpath expr="//page[last()]" position="after">
225 <page string="Payment Instruments">
226@@ -21,5 +21,26 @@
227 </xpath>
228 </field>
229 </record>
230+
231+ <record model="ir.ui.view" id="view_bank_statement_inherit_tree">
232+ <field name="name">Bank Statements</field>
233+ <field name="model">account.bank.statement</field>
234+ <field name="inherit_id" ref="account.view_bank_statement_tree"/>
235+ <field name="arch" type="xml">
236+ <xpath expr="//field[@name='journal_id']" position="after">
237+ <field name="instrument_id" />
238+ </xpath>
239+ </field>
240+ </record>
241+ <record model="ir.ui.view" id="view_bank_statement_inherit_form">
242+ <field name="name">Bank Statements</field>
243+ <field name="model">account.bank.statement</field>
244+ <field name="inherit_id" ref="account.view_bank_statement_form"/>
245+ <field name="arch" type="xml">
246+ <xpath expr="//field[@name='journal_id']" position="after">
247+ <field name="instrument_id" readonly="1" />
248+ </xpath>
249+ </field>
250+ </record>
251 </data>
252-</openerp>
253\ No newline at end of file
254+</openerp>
255
256=== modified file 'payment_instrument/view/payment_instrument_view.xml'
257--- payment_instrument/view/payment_instrument_view.xml 2013-08-21 21:12:57 +0000
258+++ payment_instrument/view/payment_instrument_view.xml 2013-09-18 21:07:20 +0000
259@@ -37,6 +37,7 @@
260 <field name="condition_range_min" attrs= "{'invisible':[('condition_select','not in',('range'))]}"/>
261 <field name="condition_range_max" attrs= "{'invisible':[('condition_select','not in',('range'))]}"/>
262 <separator colspan="4" string="Computation"/>
263+ <field name="condition_account_id" domain="[('type','not in',('view','closed','consolidation'))]" />
264 <field name="amount_select" />
265 <field name="amount_fix" attrs= "{'invisible':[('amount_select','not in',('fix'))]}"/>
266 <field name="amount_percentage" attrs= "{'invisible':[('amount_select','not in',('percentage'))]}"/>
267
268=== added file 'payment_instrument/view/point_of_sale_view.xml'
269--- payment_instrument/view/point_of_sale_view.xml 1970-01-01 00:00:00 +0000
270+++ payment_instrument/view/point_of_sale_view.xml 2013-09-18 21:07:20 +0000
271@@ -0,0 +1,15 @@
272+<?xml version="1.0"?>
273+<openerp>
274+ <data>
275+ <record model="ir.ui.view" id="view_pos_session_code_inherit_form_">
276+ <field name="name">pos.session.code.inherit.form</field>
277+ <field name="model">pos.session</field>
278+ <field name="inherit_id" ref="point_of_sale.view_pos_session_form"/>
279+ <field name="arch" type="xml">
280+ <xpath expr="//tree[@string='Statements']//field[@name='journal_id']" position="after">
281+ <field name="instrument_id" string="Instrument" />
282+ </xpath>
283+ </field>
284+ </record>
285+ </data>
286+</openerp>

Subscribers

People subscribed via source and target branches