1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
23 from datetime import datetime
24 from dateutil.relativedelta import relativedelta
27 from osv import fields, osv
28 from tools.translate import _
29 from decimal import Decimal
30 import decimal_precision as dp
32 class pos_config_journal(osv.osv):
33 """ Point of Sale journal configuration"""
34 _name = 'pos.config.journal'
35 _description = "Journal Configuration"
38 'name': fields.char('Description', size=64),
39 'code': fields.char('Code', size=64),
40 'journal_id': fields.many2one('account.journal', "Journal")
45 class pos_order(osv.osv):
47 _description = "Point of Sale"
50 def unlink(self, cr, uid, ids, context=None):
51 for rec in self.browse(cr, uid, ids, context=context):
52 if rec.state not in ('draft','cancel'):
53 raise osv.except_osv(_('Unable to Delete !'), _('In order to delete a sale, it must be new or cancelled.'))
54 return super(pos_order, self).unlink(cr, uid, ids, context=context)
56 def onchange_partner_id(self, cr, uid, ids, part=False, context=None):
59 pricelist = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_product_pricelist.id
60 return {'value': {'pricelist_id': pricelist}}
62 def _amount_all(self, cr, uid, ids, name, args, context=None):
63 tax_obj = self.pool.get('account.tax')
64 cur_obj = self.pool.get('res.currency')
66 for order in self.browse(cr, uid, ids, context=context):
73 cur = order.pricelist_id.currency_id
74 for payment in order.statement_ids:
75 res[order.id]['amount_paid'] += payment.amount
76 res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0)
77 for line in order.lines:
78 val1 += line.price_subtotal_incl
79 val2 += line.price_subtotal
80 res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val1-val2)
81 res[order.id]['amount_total'] = cur_obj.round(cr, uid, cur, val1)
84 def _default_sale_journal(self, cr, uid, context=None):
85 res = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale')], limit=1)
86 return res and res[0] or False
88 def _default_shop(self, cr, uid, context=None):
89 res = self.pool.get('sale.shop').search(cr, uid, [])
90 return res and res[0] or False
92 def copy(self, cr, uid, id, default=None, context=None):
98 'account_move': False,
102 'name': self.pool.get('ir.sequence').get(cr, uid, 'pos.order'),
105 return super(pos_order, self).copy(cr, uid, id, d, context=context)
108 'name': fields.char('Order Ref', size=64, required=True,
109 states={'draft': [('readonly', False)]}, readonly=True),
110 'company_id':fields.many2one('res.company', 'Company', required=True, readonly=True),
111 'shop_id': fields.many2one('sale.shop', 'Shop', required=True,
112 states={'draft': [('readonly', False)]}, readonly=True),
113 'date_order': fields.datetime('Date Ordered', readonly=True, select=True),
114 '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."),
115 'amount_tax': fields.function(_amount_all, string='Taxes', digits_compute=dp.get_precision('Point Of Sale'), multi='all'),
116 'amount_total': fields.function(_amount_all, string='Total', multi='all'),
117 'amount_paid': fields.function(_amount_all, string='Paid', states={'draft': [('readonly', False)]}, readonly=True, digits_compute=dp.get_precision('Point Of Sale'), multi='all'),
118 'amount_return': fields.function(_amount_all, 'Returned', digits_compute=dp.get_precision('Point Of Sale'), multi='all'),
119 'lines': fields.one2many('pos.order.line', 'order_id', 'Order Lines', states={'draft': [('readonly', False)]}, readonly=True),
120 'statement_ids': fields.one2many('account.bank.statement.line', 'pos_statement_id', 'Payments', states={'draft': [('readonly', False)]}, readonly=True),
121 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, states={'draft': [('readonly', False)]}, readonly=True),
122 'partner_id': fields.many2one('res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
124 'state': fields.selection([('draft', 'New'),
127 ('invoiced', 'Invoiced'),
128 ('cancel', 'Cancelled')],
129 'State', readonly=True),
131 'invoice_id': fields.many2one('account.invoice', 'Invoice'),
132 'account_move': fields.many2one('account.move', 'Journal Entry', readonly=True),
133 'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True),
134 'note': fields.text('Internal Notes'),
135 'nb_print': fields.integer('Number of Print', readonly=True),
136 'sale_journal': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True),
139 def _default_pricelist(self, cr, uid, context=None):
140 res = self.pool.get('sale.shop').search(cr, uid, [], context=context)
142 shop = self.pool.get('sale.shop').browse(cr, uid, res[0], context=context)
143 return shop.pricelist_id and shop.pricelist_id.id or False
147 'user_id': lambda self, cr, uid, context: uid,
149 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order'),
150 'date_order': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
152 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
153 'sale_journal': _default_sale_journal,
154 'shop_id': _default_shop,
155 'pricelist_id': _default_pricelist,
158 def test_paid(self, cr, uid, ids, context=None):
159 """A Point of Sale is paid when the sum
162 for order in self.browse(cr, uid, ids, context=context):
163 if order.lines and not order.amount_total:
165 if (not order.lines) or (not order.statement_ids) or \
166 (abs(order.amount_total-order.amount_paid) > 0.00001):
170 def create_picking(self, cr, uid, ids, context=None):
171 """Create a picking for each order and validate it."""
172 picking_obj = self.pool.get('stock.picking')
173 partner_obj = self.pool.get('res.partner')
174 move_obj = self.pool.get('stock.move')
176 for order in self.browse(cr, uid, ids, context=context):
177 addr = order.partner_id and partner_obj.address_get(cr, uid, [order.partner_id.id], ['delivery']) or {}
178 picking_id = picking_obj.create(cr, uid, {
179 'origin': order.name,
180 'address_id': addr.get('delivery',False),
182 'company_id': order.company_id.id,
183 'move_type': 'direct',
184 'note': order.note or "",
185 'invoice_state': 'none',
186 'auto_picking': True,
188 self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
189 location_id = order.shop_id.warehouse_id.lot_stock_id.id
190 output_id = order.shop_id.warehouse_id.lot_output_id.id
192 for line in order.lines:
193 if line.product_id and line.product_id.type == 'service':
196 location_id, output_id = output_id, location_id
198 move_obj.create(cr, uid, {
200 'product_uom': line.product_id.uom_id.id,
201 'product_uos': line.product_id.uom_id.id,
202 'picking_id': picking_id,
203 'product_id': line.product_id.id,
204 'product_uos_qty': abs(line.qty),
205 'product_qty': abs(line.qty),
206 'tracking_id': False,
208 'location_id': location_id,
209 'location_dest_id': output_id,
212 location_id, output_id = output_id, location_id
214 wf_service = netsvc.LocalService("workflow")
215 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
216 picking_obj.force_assign(cr, uid, [picking_id], context)
219 def set_to_draft(self, cr, uid, ids, *args):
222 for order in self.browse(cr, uid, ids, context=context):
223 if order.state<>'cancel':
224 raise osv.except_osv(_('Error!'), _('In order to set to draft a sale, it must be cancelled.'))
225 self.write(cr, uid, ids, {'state': 'draft'})
226 wf_service = netsvc.LocalService("workflow")
228 wf_service.trg_create(uid, 'pos.order', i, cr)
231 def cancel_order(self, cr, uid, ids, context=None):
232 """ Changes order state to cancel
235 stock_picking_obj = self.pool.get('stock.picking')
236 for order in self.browse(cr, uid, ids, context=context):
237 wf_service.trg_validate(uid, 'stock.picking', order.picking_id.id, 'button_cancel', cr)
238 if stock_picking_obj.browse(cr, uid, order.picking_id.id, context=context).state <> 'cancel':
239 raise osv.except_osv(_('Error!'), _('Unable to cancel the picking.'))
240 self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
243 def add_payment(self, cr, uid, order_id, data, context=None):
244 """Create a new payment for the order"""
245 statement_obj = self.pool.get('account.bank.statement')
246 statement_line_obj = self.pool.get('account.bank.statement.line')
247 prod_obj = self.pool.get('product.product')
248 property_obj = self.pool.get('ir.property')
249 curr_c = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
250 curr_company = curr_c.id
251 order = self.browse(cr, uid, order_id, context=context)
254 'amount': data['amount'],
256 if 'payment_date' in data.keys():
257 args['date'] = data['payment_date']
258 args['name'] = order.name
259 if data.get('payment_name', False):
260 args['name'] = args['name'] + ': ' + data['payment_name']
261 account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
262 args['account_id'] = order.partner_id and order.partner_id.property_account_receivable \
263 and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
264 args['partner_id'] = order.partner_id and order.partner_id.id or None
266 statement_id = statement_obj.search(cr,uid, [
267 ('journal_id', '=', data['journal']),
268 ('company_id', '=', curr_company),
269 ('user_id', '=', uid),
270 ('state', '=', 'open')], context=context)
271 if len(statement_id) == 0:
272 raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
274 statement_id = statement_id[0]
275 args['statement_id'] = statement_id
276 args['pos_statement_id'] = order_id
277 args['journal_id'] = data['journal']
278 args['type'] = 'customer'
279 args['ref'] = order.name
280 statement_line_obj.create(cr, uid, args, context=context)
281 ids_new.append(statement_id)
283 wf_service = netsvc.LocalService("workflow")
284 wf_service.trg_validate(uid, 'pos.order', order_id, 'paid', cr)
285 wf_service.trg_write(uid, 'pos.order', order_id, cr)
289 def refund(self, cr, uid, ids, context=None):
290 """Create a copy of order for refund order"""
292 line_obj = self.pool.get('pos.order.line')
293 for order in self.browse(cr, uid, ids, context=context):
294 clone_id = self.copy(cr, uid, order.id, {
295 'name': order.name + ' REFUND',
297 clone_list.append(clone_id)
299 for clone in self.browse(cr, uid, clone_list, context=context):
300 for order_line in clone.lines:
301 line_obj.write(cr, uid, [order_line.id], {
302 'qty': -order_line.qty
305 new_order = ','.join(map(str,clone_list))
307 #'domain': "[('id', 'in', ["+new_order+"])]",
308 'name': _('Return Products'),
311 'res_model': 'pos.order',
312 'res_id':clone_list[0],
315 'type': 'ir.actions.act_window',
321 def action_invoice(self, cr, uid, ids, context=None):
322 inv_ref = self.pool.get('account.invoice')
323 inv_line_ref = self.pool.get('account.invoice.line')
324 product_obj = self.pool.get('product.product')
327 for order in self.pool.get('pos.order').browse(cr, uid, ids, context=context):
329 inv_ids.append(order.invoice_id.id)
332 if not order.partner_id:
333 raise osv.except_osv(_('Error'), _('Please provide a partner for the sale.'))
335 acc = order.partner_id.property_account_receivable.id
337 'name': 'Invoice from POS: '+order.name,
338 'origin': order.name,
340 'journal_id': order.sale_journal.id or None,
341 'type': 'out_invoice',
342 'reference': order.name,
343 'partner_id': order.partner_id.id,
344 'comment': order.note or '',
345 'currency_id': order.pricelist_id.currency_id.id, # considering partner's sale pricelist's currency
347 inv.update(inv_ref.onchange_partner_id(cr, uid, [], 'out_invoice', order.partner_id.id)['value'])
348 if not inv.get('account_id', None):
349 inv['account_id'] = acc
350 inv_id = inv_ref.create(cr, uid, inv, context=context)
352 self.write(cr, uid, [order.id], {'invoice_id': inv_id, 'state': 'invoiced'}, context=context)
353 inv_ids.append(inv_id)
354 for line in order.lines:
356 'invoice_id': inv_id,
357 'product_id': line.product_id.id,
358 'quantity': line.qty,
360 inv_name = product_obj.name_get(cr, uid, [line.product_id.id], context=context)[0][1]
361 inv_line.update(inv_line_ref.product_id_change(cr, uid, [],
363 line.product_id.uom_id.id,
364 line.qty, partner_id = order.partner_id.id,
365 fposition_id=order.partner_id.property_account_position.id)['value'])
366 if line.product_id.description_sale:
367 inv_line['note'] = line.product_id.description_sale
368 inv_line['price_unit'] = line.price_unit
369 inv_line['discount'] = line.discount
370 inv_line['name'] = inv_name
371 inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\
372 and [(6, 0, inv_line['invoice_line_tax_id'])] or []
373 inv_line_ref.create(cr, uid, inv_line, context=context)
374 inv_ref.button_reset_taxes(cr, uid, [inv_id], context=context)
376 if not inv_ids: return {}
377 mod_obj = self.pool.get('ir.model.data')
378 res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
379 res_id = res and res[1] or False
381 'name': _('PoS Invoices'),
385 'res_model': 'account.invoice',
386 'context': "{'type':'out_invoice'}",
387 'type': 'ir.actions.act_window',
390 'res_id': inv_ids and inv_ids[0] or False,
393 def create_account_move(self, cr, uid, ids, context=None):
394 """Create a account move line of order grouped by products or not."""
395 account_move_obj = self.pool.get('account.move')
396 account_move_line_obj = self.pool.get('account.move.line')
397 account_period_obj = self.pool.get('account.period')
398 period = account_period_obj.find(cr, uid, context=context)[0]
399 account_tax_obj = self.pool.get('account.tax')
400 res_obj=self.pool.get('res.users')
401 property_obj=self.pool.get('ir.property')
403 for order in self.browse(cr, uid, ids, context=context):
404 if order.state<>'paid': continue
406 curr_c = res_obj.browse(cr, uid, uid).company_id
407 comp_id = res_obj.browse(cr, order.user_id.id, order.user_id.id).company_id
408 comp_id = comp_id and comp_id.id or False
411 account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context).id
413 order_account = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id
415 # Create an entry for the sale
416 move_id = account_move_obj.create(cr, uid, {
417 'journal_id': order.sale_journal.id,
420 # Create an move for each order line
421 for line in order.lines:
423 taxes = [t for t in line.product_id.taxes_id]
424 computed = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit * (100.0-line.discount) / 100.0, line.qty)
425 computed_taxes = computed['taxes']
427 for tax in computed_taxes:
428 tax_amount += round(tax['amount'], 2)
429 group_key = (tax['tax_code_id'],
431 tax['account_collected_id'])
433 if group_key in group_tax:
434 group_tax[group_key] += round(tax['amount'], 2)
436 group_tax[group_key] = round(tax['amount'], 2)
437 amount = line.price_subtotal
439 # Search for the income account
440 if line.product_id.property_account_income.id:
441 income_account = line.\
442 product_id.property_account_income.id
443 elif line.product_id.categ_id.\
444 property_account_income_categ.id:
445 income_account = line.product_id.categ_id.\
446 property_account_income_categ.id
448 raise osv.except_osv(_('Error !'), _('There is no income '\
449 'account defined for this product: "%s" (id:%d)') \
450 % (line.product_id.name, line.product_id.id, ))
452 # Empty the tax list as long as there is no tax code:
455 while computed_taxes:
456 tax = computed_taxes.pop(0)
458 tax_code_id = tax['base_code_id']
459 tax_amount = line.price_subtotal * tax['base_sign']
461 tax_code_id = tax['ref_base_code_id']
462 tax_amount = line.price_subtotal * tax['ref_base_sign']
463 # If there is one we stop
468 # Create a move for the line
469 account_move_line_obj.create(cr, uid, {
471 'date': order.date_order[:10],
473 'quantity': line.qty,
474 'product_id': line.product_id.id,
476 'account_id': income_account,
477 'company_id': comp_id,
478 'credit': ((amount>0) and amount) or 0.0,
479 'debit': ((amount<0) and -amount) or 0.0,
480 'journal_id': order.sale_journal.id,
482 'tax_code_id': tax_code_id,
483 'tax_amount': tax_amount,
484 'partner_id': order.partner_id and order.partner_id.id or False
487 # For each remaining tax with a code, whe create a move line
488 for tax in computed_taxes:
490 tax_code_id = tax['base_code_id']
491 tax_amount = line.price_subtotal * tax['base_sign']
493 tax_code_id = tax['ref_base_code_id']
494 tax_amount = line.price_subtotal * tax['ref_base_sign']
498 account_move_line_obj.create(cr, uid, {
499 'name': "Tax" + line.name,
500 'date': order.date_order[:10],
502 'product_id':line.product_id.id,
503 'quantity': line.qty,
505 'account_id': income_account,
506 'company_id': comp_id,
509 'journal_id': order.sale_journal.id,
511 'tax_code_id': tax_code_id,
512 'tax_amount': tax_amount,
516 # Create a move for each tax group
517 (tax_code_pos, base_code_pos, account_pos)= (0, 1, 2)
518 for key, amount in group_tax.items():
519 account_move_line_obj.create(cr, uid, {
521 'date': order.date_order[:10],
524 'company_id': comp_id,
525 'quantity': line.qty,
526 'product_id': line.product_id.id,
527 'account_id': key[account_pos],
528 'credit': ((amount>0) and amount) or 0.0,
529 'debit': ((amount<0) and -amount) or 0.0,
530 'journal_id': order.sale_journal.id,
532 'tax_code_id': key[tax_code_pos],
533 'tax_amount': amount,
537 to_reconcile.append(account_move_line_obj.create(cr, uid, {
539 'date': order.date_order[:10],
542 'company_id': comp_id,
543 'account_id': order_account,
544 'credit': ((order.amount_total < 0) and -order.amount_total)\
546 'debit': ((order.amount_total > 0) and order.amount_total)\
548 'journal_id': order.sale_journal.id,
550 'partner_id': order.partner_id and order.partner_id.id or False
552 self.write(cr, uid, order.id, {'state':'done', 'account_move': move_id}, context=context)
555 def action_payment(self, cr, uid, ids, context=None):
556 return self.write(cr, uid, ids, {'state': 'payment'}, context=context)
558 def action_paid(self, cr, uid, ids, context=None):
559 context = context or {}
560 self.create_picking(cr, uid, ids, context=None)
561 self.write(cr, uid, ids, {'state': 'paid'}, context=context)
564 def action_cancel(self, cr, uid, ids, context=None):
565 self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
568 def action_done(self, cr, uid, ids, context=None):
569 self.create_account_move(cr, uid, ids, context=context)
574 class account_bank_statement(osv.osv):
575 _inherit = 'account.bank.statement'
577 'user_id': fields.many2one('res.users', 'User', readonly=True),
580 'user_id': lambda self,cr,uid,c={}: uid
582 account_bank_statement()
584 class account_bank_statement_line(osv.osv):
585 _inherit = 'account.bank.statement.line'
587 'journal_id': fields.related('statement_id','journal_id','name', store=True, string='Journal', type='char', size=64),
588 'pos_statement_id': fields.many2one('pos.order', ondelete='cascade'),
590 account_bank_statement_line()
592 class pos_order_line(osv.osv):
593 _name = "pos.order.line"
594 _description = "Lines of Point of Sale"
595 _rec_name = "product_id"
597 def _amount_line_all(self, cr, uid, ids, field_names, arg, context=None):
598 res = dict([(i, {}) for i in ids])
599 account_tax_obj = self.pool.get('account.tax')
600 cur_obj = self.pool.get('res.currency')
601 for line in self.browse(cr, uid, ids, context=context):
602 taxes = line.product_id.taxes_id
603 price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
604 taxes = account_tax_obj.compute_all(cr, uid, line.product_id.taxes_id, price, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)
606 cur = line.order_id.pricelist_id.currency_id
607 res[line.id]['price_subtotal'] = cur_obj.round(cr, uid, cur, taxes['total'])
608 res[line.id]['price_subtotal_incl'] = cur_obj.round(cr, uid, cur, taxes['total_included'])
611 def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False, context=None):
612 context = context or {}
616 raise osv.except_osv(_('No Pricelist !'),
617 _('You have to select a pricelist in the sale form !\n' \
618 'Please set one before choosing a product.'))
620 price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
621 product_id, qty or 1.0, partner_id)[pricelist]
623 result = self.onchange_qty(cr, uid, ids, product_id, 0.0, qty, price, context=context)
624 result['value']['price_unit'] = price
627 def onchange_qty(self, cr, uid, ids, product, discount, qty, price_unit, context=None):
631 account_tax_obj = self.pool.get('account.tax')
632 cur_obj = self.pool.get('res.currency')
634 prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
636 taxes = prod.taxes_id
637 price = price_unit * (1 - (discount or 0.0) / 100.0)
638 taxes = account_tax_obj.compute_all(cr, uid, prod.taxes_id, price, qty, product=prod, partner=False)
640 result['price_subtotal'] = taxes['total']
641 result['price_subtotal_incl'] = taxes['total_included']
642 return {'value': result}
645 'company_id': fields.many2one('res.company', 'Company', required=True),
646 'name': fields.char('Line No', size=32, required=True),
647 'notice': fields.char('Discount Notice', size=128),
648 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True, change_default=True),
649 'price_unit': fields.float(string='Unit Price', digits=(16, 2)),
650 'qty': fields.float('Quantity', digits=(16, 2)),
651 'price_subtotal': fields.function(_amount_line_all, multi='pos_order_line_amount', string='Subtotal w/o Tax', store=True),
652 'price_subtotal_incl': fields.function(_amount_line_all, multi='pos_order_line_amount', string='Subtotal', store=True),
653 'discount': fields.float('Discount (%)', digits=(16, 2)),
654 'order_id': fields.many2one('pos.order', 'Order Ref', ondelete='cascade'),
655 'create_date': fields.datetime('Creation Date', readonly=True),
659 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order.line'),
661 'discount': lambda *a: 0.0,
662 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
665 def copy_data(self, cr, uid, id, default=None, context=None):
669 'name': self.pool.get('ir.sequence').get(cr, uid, 'pos.order.line')
671 return super(pos_order_line, self).copy_data(cr, uid, id, default, context=context)
675 class pos_category(osv.osv):
676 _name = 'pos.category'
677 _inherit = 'product.category'
679 'parent_id': fields.many2one('pos.category','Parent Category', select=True),
680 'child_id': fields.one2many('pos.category', 'parent_id', string='Child Categories'),
684 class product_product(osv.osv):
685 _inherit = 'product.product'
687 'income_pdt': fields.boolean('Product for Input'),
688 'expense_pdt': fields.boolean('Product for Output'),
689 'img': fields.binary('Pos Image, must be 50x50'),
690 'pos_categ_id': fields.many2one('pos.category','POS Category', change_default=True, domain="[('type','=','normal')]" ,help="Select a pos category for the current product")