Merge lp:~ovnicraft/openobject-addons/dev-point_of_sale into lp:openobject-addons

Proposed by Cristian Salamea
Status: Merged
Merged at revision: 4142
Proposed branch: lp:~ovnicraft/openobject-addons/dev-point_of_sale
Merge into: lp:openobject-addons
Diff against target: 232 lines (+44/-18)
3 files modified
point_of_sale/point_of_sale.py (+37/-16)
point_of_sale/point_of_sale_view.xml (+2/-0)
point_of_sale/wizard/pos_scan_product.py (+5/-2)
To merge this branch: bzr merge lp:~ovnicraft/openobject-addons/dev-point_of_sale
Reviewer Review Type Date Requested Status
qdp (OpenERP) Approve
Review via email: mp+40210@code.launchpad.net

Description of the change

Fix some code errors (spaces between = )
Fix assign the same account when invoicing
Add buttons in Point of Sale main view (add product and scan product)

To post a comment you must log in.
Revision history for this message
qdp (OpenERP) (qdp) wrote :

Hello Cristian Salamea (Gnuthink),

your branch has been merged on revision 4142. I just removed the changes related to the change in form view of point of sale: the usual place for the buttons in openERP is at the bottom right of the screen (one of this button was already present there for the second one 'ill check the reason it's not visible anywhere)

Thanks for the contribution,
Quentin

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'point_of_sale/point_of_sale.py'
2--- point_of_sale/point_of_sale.py 2010-12-21 08:49:41 +0000
3+++ point_of_sale/point_of_sale.py 2010-12-27 05:33:02 +0000
4@@ -33,6 +33,7 @@
5 """ Point of Sale journal configuration"""
6 _name = 'pos.config.journal'
7 _description = "Journal Configuration"
8+
9 _columns = {
10 'name': fields.char('Description', size=64),
11 'code': fields.char('Code', size=64),
12@@ -41,9 +42,11 @@
13
14 pos_config_journal()
15
16+
17 class pos_company_discount(osv.osv):
18 """ Company Discount and Cashboxes """
19 _inherit = 'res.company'
20+
21 _columns = {
22 'company_discount': fields.float('Max Discount(%)', digits_compute=dp.get_precision('Point Of Sale')),
23 'max_diff': fields.float('Max Difference for Cashboxes', digits_compute=dp.get_precision('Point Of Sale Discount')),
24@@ -173,21 +176,23 @@
25 (1-(line.discount or 0.0)/100.0), line.qty),
26 res[order.id]['amount_tax'])
27 elif line.qty != 0.0:
28- for c in tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.qty, line.product_id, line.order_id.partner_id)['taxes']:
29+ for c in tax_obj.compute_all(cr, uid, line.product_id.taxes_id, \
30+ line.price_unit * (1-(line.discount or 0.0)/100.0), \
31+ line.qty, line.product_id, line.order_id.partner_id)['taxes']:
32 val += c.get('amount', 0.0)
33 res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
34 res[order.id]['amount_total'] = res[order.id]['amount_tax'] + cur_obj.round(cr, uid, cur, val1)
35 return res
36
37 def _sale_journal_get(self, cr, uid, context=None):
38- """ To get sale journal for this order"
39+ """ To get sale journal for this order
40 @return: journal """
41 journal_obj = self.pool.get('account.journal')
42 res = journal_obj.search(cr, uid, [('type', '=', 'sale')], limit=1)
43 return res and res[0] or False
44
45 def _shop_get(self, cr, uid, context=None):
46- """ To get Shop for this order"
47+ """ To get Shop for this order
48 @return: Shop id """
49 res = self.pool.get('sale.shop').search(cr, uid, [])
50 return res and res[0] or False
51@@ -207,7 +212,7 @@
52 })
53 return super(pos_order, self).copy(cr, uid, id, default, context=context)
54
55- def _get_v( self, cr, uid, ids, *a):
56+ def _get_v( self, cr, uid, ids, *args):
57 """ Changed the Validation state of order
58 @return: State """
59 res_obj = self.pool.get('res.users')
60@@ -243,8 +248,13 @@
61 'shop_id': fields.many2one('sale.shop', 'Shop', required=True,
62 states={'draft': [('readonly', False)]}, readonly=True),
63 'date_order': fields.datetime('Date Ordered', readonly=True),
64- 'date_validation': fields.function(_get_date_payment, method=True, string='Validation Date', type='date', store=True),
65- 'date_payment': fields.function(_get_date_payment2, method=True, string='Payment Date', type='date', store=True),
66+ 'date_validation': fields.function(_get_date_payment,
67+ method=True,
68+ string='Validation Date',
69+ type='date', store=True),
70+ 'date_payment': fields.function(_get_date_payment2, method=True,
71+ string='Payment Date',
72+ type='date', store=True),
73 'date_validity': fields.date('Validity Date', required=True),
74 'user_id': fields.many2one('res.users', 'Connected Salesman', help="Person who uses the the cash register. It could be a reliever, a student or an interim employee."),
75 'user_salesman_id': fields.many2one('res.users', 'Cashier', required=True, help="User who is logged into the system."),
76@@ -285,7 +295,7 @@
77 }
78
79 def _select_pricelist(self, cr, uid, context=None):
80- """ To get default pricelist for the order"
81+ """ To get default pricelist for the order
82 @param name: Names of fields.
83 @return: pricelist ID
84 """
85@@ -293,7 +303,7 @@
86 return pricelist and pricelist[0] or False
87
88 def _journal_default(self, cr, uid, context=None):
89- """ To get default pricelist for the order"
90+ """ To get default pricelist for the order
91 @param name: Names of fields.
92 @return: journal ID
93 """
94@@ -319,7 +329,7 @@
95
96
97 def test_order_lines(self, cr, uid, order, context=None):
98- """ Test order line is created or not for the order "
99+ """ Test order line is created or not for the order
100 @param name: Names of fields.
101 @return: True
102 """
103@@ -452,7 +462,7 @@
104 location_id, stock_dest_id = stock_dest_id, location_id
105
106 move_obj.create(cr, uid, {
107- 'name': 'Stock move (POS %d)' % (order.id, ),
108+ 'name': '(POS %d)' % (order.id, ),
109 'product_uom': line.product_id.uom_id.id,
110 'product_uos': line.product_id.uom_id.id,
111 'picking_id': picking_id,
112@@ -506,7 +516,7 @@
113
114 def add_payment(self, cr, uid, order_id, data, context=None):
115 """Create a new payment for the order"""
116- statement_obj= self.pool.get('account.bank.statement')
117+ statement_obj = self.pool.get('account.bank.statement')
118 statement_line_obj = self.pool.get('account.bank.statement.line')
119 prod_obj = self.pool.get('product.product')
120 property_obj = self.pool.get('ir.property')
121@@ -524,12 +534,15 @@
122 if 'payment_name' in data.keys():
123 args['name'] = data['payment_name'] + ' ' + order.name
124 account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
125- args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
126+ args['account_id'] = order.partner_id and order.partner_id.property_account_receivable \
127+ and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
128 if data.get('is_acc', False):
129 args['is_acc'] = data['is_acc']
130- args['account_id'] = prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income and prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income.id
131+ args['account_id'] = prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income \
132+ and prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income.id
133 if not args['account_id']:
134- raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')%(prod_obj.browse(cr, uid, data['product_id'], context=context).name))
135+ raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')% \
136+ (prod_obj.browse(cr, uid, data['product_id'], context=context).name))
137 args['partner_id'] = order.partner_id and order.partner_id.id or None
138 args['ref'] = order.contract_number or None
139
140@@ -545,6 +558,8 @@
141 args['statement_id'] = statement_id
142 args['pos_statement_id'] = order_id
143 args['journal_id'] = data['journal']
144+ args['type'] = 'customer'
145+ args['ref'] = order.name
146 statement_line_obj.create(cr, uid, args, context=context)
147 ids_new.append(statement_id)
148
149@@ -555,7 +570,9 @@
150 return statement_id
151
152 def add_product(self, cr, uid, order_id, product_id, qty, context=None):
153+
154 """Create a new order line the order"""
155+
156 line_obj = self.pool.get('pos.order.line')
157 values = self.read(cr, uid, order_id, ['partner_id', 'pricelist_id'])
158
159@@ -576,7 +593,9 @@
160 return order_line_id, price
161
162 def refund(self, cr, uid, ids, context=None):
163+
164 """Create a copy of order for refund order"""
165+
166 clone_list = []
167 line_obj = self.pool.get('pos.order.line')
168
169@@ -601,7 +620,9 @@
170 return clone_list
171
172 def action_invoice(self, cr, uid, ids, context=None):
173+
174 """Create a invoice of order """
175+
176 inv_ref = self.pool.get('account.invoice')
177 inv_line_ref = self.pool.get('account.invoice.line')
178 product_obj = self.pool.get('product.product')
179@@ -644,10 +665,10 @@
180 inv_line.update(inv_line_ref.product_id_change(cr, uid, [],
181 line.product_id.id,
182 line.product_id.uom_id.id,
183- line.qty, partner_id = order.partner_id.id, fposition_id=order.partner_id.property_account_position.id)['value'])
184+ line.qty, partner_id = order.partner_id.id,
185+ fposition_id=order.partner_id.property_account_position.id)['value'])
186 inv_line['price_unit'] = line.price_unit
187 inv_line['discount'] = line.discount
188- inv_line['account_id'] = acc
189 inv_line['name'] = inv_name
190 inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\
191 and [(6, 0, inv_line['invoice_line_tax_id'])] or []
192
193=== modified file 'point_of_sale/point_of_sale_view.xml'
194--- point_of_sale/point_of_sale_view.xml 2010-11-26 16:13:59 +0000
195+++ point_of_sale/point_of_sale_view.xml 2010-12-27 05:33:02 +0000
196@@ -19,6 +19,8 @@
197 <field name="shop_id" widget="selection"/>
198 <field name="partner_id" on_change="onchange_partner_pricelist(partner_id)"/>
199 <field name="contract_number" groups="base.group_extended"/>
200+ <button name="%(point_of_sale.action_pos_scan_product)d" string="Scan Barcode" type="action" states="draft,advance"/>
201+ <button name="%(point_of_sale.action_add_product)d" string="Add Product" type="action" states="draft,advance"/>
202 </group>
203 <notebook colspan="4">
204 <page string="Sale Order">
205
206=== modified file 'point_of_sale/wizard/pos_scan_product.py'
207--- point_of_sale/wizard/pos_scan_product.py 2010-11-23 07:05:05 +0000
208+++ point_of_sale/wizard/pos_scan_product.py 2010-12-27 05:33:02 +0000
209@@ -25,9 +25,11 @@
210 class pos_scan_product(osv.osv_memory):
211 _name = 'pos.scan.product'
212 _description = 'Scan product'
213+
214 _columns = {
215- 'gencod': fields.char('Barcode',size=13,required= True)
216+ 'gencod': fields.char('Barcode', size=13, required=True)
217 }
218+
219 def scan(self, cr, uid, ids, context=None):
220 """
221 To get the gencod and scan product
222@@ -40,9 +42,10 @@
223 if context is None:
224 context = {}
225 data=self.read(cr, uid, ids)[0]
226- record_id = context and context.get('active_id',False)
227+ record_id = context and context.get('active_id', False)
228 result =self. pool.get('pos.order.line')._scan_product(cr, uid, data['gencod'], 1, record_id)
229 return {'gencod': False}
230+
231 pos_scan_product()
232 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
233

Subscribers

People subscribed via source and target branches

to all changes: