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 and account_def.id) or False
264 args['partner_id'] = order.partner_id and order.partner_id.id or None
266 if not args['account_id']:
267 if not args['partner_id']:
268 msg = _('There is no receivable account defined to make payment')
270 msg = _('There is no receivable account defined to make payment for the partner: "%s" (id:%d)') % (order.partner_id.name, order.partner_id.id,)
271 raise osv.except_osv(_('Configuration Error !'), msg)
273 statement_id = statement_obj.search(cr,uid, [
274 ('journal_id', '=', int(data['journal'])),
275 ('company_id', '=', curr_company),
276 ('user_id', '=', uid),
277 ('state', '=', 'open')], context=context)
278 if len(statement_id) == 0:
279 raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
281 statement_id = statement_id[0]
282 args['statement_id'] = statement_id
283 args['pos_statement_id'] = order_id
284 args['journal_id'] = int(data['journal'])
285 args['type'] = 'customer'
286 args['ref'] = order.name
287 statement_line_obj.create(cr, uid, args, context=context)
288 ids_new.append(statement_id)
290 wf_service = netsvc.LocalService("workflow")
291 wf_service.trg_validate(uid, 'pos.order', order_id, 'paid', cr)
292 wf_service.trg_write(uid, 'pos.order', order_id, cr)
296 def refund(self, cr, uid, ids, context=None):
297 """Create a copy of order for refund order"""
299 line_obj = self.pool.get('pos.order.line')
300 for order in self.browse(cr, uid, ids, context=context):
301 clone_id = self.copy(cr, uid, order.id, {
302 'name': order.name + ' REFUND',
304 clone_list.append(clone_id)
306 for clone in self.browse(cr, uid, clone_list, context=context):
307 for order_line in clone.lines:
308 line_obj.write(cr, uid, [order_line.id], {
309 'qty': -order_line.qty
312 new_order = ','.join(map(str,clone_list))
314 #'domain': "[('id', 'in', ["+new_order+"])]",
315 'name': _('Return Products'),
318 'res_model': 'pos.order',
319 'res_id':clone_list[0],
322 'type': 'ir.actions.act_window',
328 def action_invoice(self, cr, uid, ids, context=None):
329 inv_ref = self.pool.get('account.invoice')
330 inv_line_ref = self.pool.get('account.invoice.line')
331 product_obj = self.pool.get('product.product')
334 for order in self.pool.get('pos.order').browse(cr, uid, ids, context=context):
336 inv_ids.append(order.invoice_id.id)
339 if not order.partner_id:
340 raise osv.except_osv(_('Error'), _('Please provide a partner for the sale.'))
342 acc = order.partner_id.property_account_receivable.id
344 'name': 'Invoice from POS: '+order.name,
345 'origin': order.name,
347 'journal_id': order.sale_journal.id or None,
348 'type': 'out_invoice',
349 'reference': order.name,
350 'partner_id': order.partner_id.id,
351 'comment': order.note or '',
352 'currency_id': order.pricelist_id.currency_id.id, # considering partner's sale pricelist's currency
354 inv.update(inv_ref.onchange_partner_id(cr, uid, [], 'out_invoice', order.partner_id.id)['value'])
355 if not inv.get('account_id', None):
356 inv['account_id'] = acc
357 inv_id = inv_ref.create(cr, uid, inv, context=context)
359 self.write(cr, uid, [order.id], {'invoice_id': inv_id, 'state': 'invoiced'}, context=context)
360 inv_ids.append(inv_id)
361 for line in order.lines:
363 'invoice_id': inv_id,
364 'product_id': line.product_id.id,
365 'quantity': line.qty,
367 inv_name = product_obj.name_get(cr, uid, [line.product_id.id], context=context)[0][1]
368 inv_line.update(inv_line_ref.product_id_change(cr, uid, [],
370 line.product_id.uom_id.id,
371 line.qty, partner_id = order.partner_id.id,
372 fposition_id=order.partner_id.property_account_position.id)['value'])
373 if line.product_id.description_sale:
374 inv_line['note'] = line.product_id.description_sale
375 inv_line['price_unit'] = line.price_unit
376 inv_line['discount'] = line.discount
377 inv_line['name'] = inv_name
378 inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\
379 and [(6, 0, inv_line['invoice_line_tax_id'])] or []
380 inv_line_ref.create(cr, uid, inv_line, context=context)
381 inv_ref.button_reset_taxes(cr, uid, [inv_id], context=context)
383 if not inv_ids: return {}
384 mod_obj = self.pool.get('ir.model.data')
385 res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
386 res_id = res and res[1] or False
388 'name': _('PoS Invoices'),
392 'res_model': 'account.invoice',
393 'context': "{'type':'out_invoice'}",
394 'type': 'ir.actions.act_window',
397 'res_id': inv_ids and inv_ids[0] or False,
400 def create_account_move(self, cr, uid, ids, context=None):
401 """Create a account move line of order grouped by products or not."""
402 account_move_obj = self.pool.get('account.move')
403 account_move_line_obj = self.pool.get('account.move.line')
404 account_period_obj = self.pool.get('account.period')
405 period = account_period_obj.find(cr, uid, context=context)[0]
406 account_tax_obj = self.pool.get('account.tax')
407 res_obj=self.pool.get('res.users')
408 property_obj=self.pool.get('ir.property')
410 for order in self.browse(cr, uid, ids, context=context):
411 if order.state<>'paid': continue
413 curr_c = res_obj.browse(cr, uid, uid).company_id
414 comp_id = res_obj.browse(cr, order.user_id.id, order.user_id.id).company_id
415 comp_id = comp_id and comp_id.id or False
418 account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context).id
420 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
422 # Create an entry for the sale
423 move_id = account_move_obj.create(cr, uid, {
424 'journal_id': order.sale_journal.id,
427 # Create an move for each order line
428 for line in order.lines:
430 taxes = [t for t in line.product_id.taxes_id]
431 computed = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit * (100.0-line.discount) / 100.0, line.qty)
432 computed_taxes = computed['taxes']
434 for tax in computed_taxes:
435 tax_amount += round(tax['amount'], 2)
436 group_key = (tax['tax_code_id'],
438 tax['account_collected_id'])
440 if group_key in group_tax:
441 group_tax[group_key] += round(tax['amount'], 2)
443 group_tax[group_key] = round(tax['amount'], 2)
444 amount = line.price_subtotal
446 # Search for the income account
447 if line.product_id.property_account_income.id:
448 income_account = line.\
449 product_id.property_account_income.id
450 elif line.product_id.categ_id.\
451 property_account_income_categ.id:
452 income_account = line.product_id.categ_id.\
453 property_account_income_categ.id
455 raise osv.except_osv(_('Error !'), _('There is no income '\
456 'account defined for this product: "%s" (id:%d)') \
457 % (line.product_id.name, line.product_id.id, ))
459 # Empty the tax list as long as there is no tax code:
462 while computed_taxes:
463 tax = computed_taxes.pop(0)
465 tax_code_id = tax['base_code_id']
466 tax_amount = line.price_subtotal * tax['base_sign']
468 tax_code_id = tax['ref_base_code_id']
469 tax_amount = line.price_subtotal * tax['ref_base_sign']
470 # If there is one we stop
475 # Create a move for the line
476 account_move_line_obj.create(cr, uid, {
478 'date': order.date_order[:10],
480 'quantity': line.qty,
481 'product_id': line.product_id.id,
483 'account_id': income_account,
484 'company_id': comp_id,
485 'credit': ((amount>0) and amount) or 0.0,
486 'debit': ((amount<0) and -amount) or 0.0,
487 'journal_id': order.sale_journal.id,
489 'tax_code_id': tax_code_id,
490 'tax_amount': tax_amount,
491 'partner_id': order.partner_id and order.partner_id.id or False
494 # For each remaining tax with a code, whe create a move line
495 for tax in computed_taxes:
497 tax_code_id = tax['base_code_id']
498 tax_amount = line.price_subtotal * tax['base_sign']
500 tax_code_id = tax['ref_base_code_id']
501 tax_amount = line.price_subtotal * tax['ref_base_sign']
505 account_move_line_obj.create(cr, uid, {
506 'name': "Tax" + line.name,
507 'date': order.date_order[:10],
509 'product_id':line.product_id.id,
510 'quantity': line.qty,
512 'account_id': income_account,
513 'company_id': comp_id,
516 'journal_id': order.sale_journal.id,
518 'tax_code_id': tax_code_id,
519 'tax_amount': tax_amount,
523 # Create a move for each tax group
524 (tax_code_pos, base_code_pos, account_pos)= (0, 1, 2)
525 for key, amount in group_tax.items():
526 account_move_line_obj.create(cr, uid, {
528 'date': order.date_order[:10],
531 'company_id': comp_id,
532 'quantity': line.qty,
533 'product_id': line.product_id.id,
534 'account_id': key[account_pos],
535 'credit': ((amount>0) and amount) or 0.0,
536 'debit': ((amount<0) and -amount) or 0.0,
537 'journal_id': order.sale_journal.id,
539 'tax_code_id': key[tax_code_pos],
540 'tax_amount': amount,
544 to_reconcile.append(account_move_line_obj.create(cr, uid, {
546 'date': order.date_order[:10],
549 'company_id': comp_id,
550 'account_id': order_account,
551 'credit': ((order.amount_total < 0) and -order.amount_total)\
553 'debit': ((order.amount_total > 0) and order.amount_total)\
555 'journal_id': order.sale_journal.id,
557 'partner_id': order.partner_id and order.partner_id.id or False
559 self.write(cr, uid, order.id, {'state':'done', 'account_move': move_id}, context=context)
562 def action_payment(self, cr, uid, ids, context=None):
563 return self.write(cr, uid, ids, {'state': 'payment'}, context=context)
565 def action_paid(self, cr, uid, ids, context=None):
566 context = context or {}
567 self.create_picking(cr, uid, ids, context=None)
568 self.write(cr, uid, ids, {'state': 'paid'}, context=context)
571 def action_cancel(self, cr, uid, ids, context=None):
572 self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
575 def action_done(self, cr, uid, ids, context=None):
576 self.create_account_move(cr, uid, ids, context=context)
581 class account_bank_statement(osv.osv):
582 _inherit = 'account.bank.statement'
584 'user_id': fields.many2one('res.users', 'User', readonly=True),
587 'user_id': lambda self,cr,uid,c={}: uid
589 account_bank_statement()
591 class account_bank_statement_line(osv.osv):
592 _inherit = 'account.bank.statement.line'
594 'journal_id': fields.related('statement_id','journal_id','name', store=True, string='Journal', type='char', size=64),
595 'pos_statement_id': fields.many2one('pos.order', ondelete='cascade'),
597 account_bank_statement_line()
599 class pos_order_line(osv.osv):
600 _name = "pos.order.line"
601 _description = "Lines of Point of Sale"
602 _rec_name = "product_id"
604 def _amount_line_all(self, cr, uid, ids, field_names, arg, context=None):
605 res = dict([(i, {}) for i in ids])
606 account_tax_obj = self.pool.get('account.tax')
607 cur_obj = self.pool.get('res.currency')
608 for line in self.browse(cr, uid, ids, context=context):
609 taxes = line.product_id.taxes_id
610 price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
611 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)
613 cur = line.order_id.pricelist_id.currency_id
614 res[line.id]['price_subtotal'] = cur_obj.round(cr, uid, cur, taxes['total'])
615 res[line.id]['price_subtotal_incl'] = cur_obj.round(cr, uid, cur, taxes['total_included'])
618 def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False, context=None):
619 context = context or {}
623 raise osv.except_osv(_('No Pricelist !'),
624 _('You have to select a pricelist in the sale form !\n' \
625 'Please set one before choosing a product.'))
627 price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
628 product_id, qty or 1.0, partner_id)[pricelist]
630 result = self.onchange_qty(cr, uid, ids, product_id, 0.0, qty, price, context=context)
631 result['value']['price_unit'] = price
634 def onchange_qty(self, cr, uid, ids, product, discount, qty, price_unit, context=None):
638 account_tax_obj = self.pool.get('account.tax')
639 cur_obj = self.pool.get('res.currency')
641 prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
643 taxes = prod.taxes_id
644 price = price_unit * (1 - (discount or 0.0) / 100.0)
645 taxes = account_tax_obj.compute_all(cr, uid, prod.taxes_id, price, qty, product=prod, partner=False)
647 result['price_subtotal'] = taxes['total']
648 result['price_subtotal_incl'] = taxes['total_included']
649 return {'value': result}
652 'company_id': fields.many2one('res.company', 'Company', required=True),
653 'name': fields.char('Line No', size=32, required=True),
654 'notice': fields.char('Discount Notice', size=128),
655 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True, change_default=True),
656 'price_unit': fields.float(string='Unit Price', digits=(16, 2)),
657 'qty': fields.float('Quantity', digits=(16, 2)),
658 'price_subtotal': fields.function(_amount_line_all, multi='pos_order_line_amount', string='Subtotal w/o Tax', store=True),
659 'price_subtotal_incl': fields.function(_amount_line_all, multi='pos_order_line_amount', string='Subtotal', store=True),
660 'discount': fields.float('Discount (%)', digits=(16, 2)),
661 'order_id': fields.many2one('pos.order', 'Order Ref', ondelete='cascade'),
662 'create_date': fields.datetime('Creation Date', readonly=True),
666 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order.line'),
668 'discount': lambda *a: 0.0,
669 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
672 def copy_data(self, cr, uid, id, default=None, context=None):
676 'name': self.pool.get('ir.sequence').get(cr, uid, 'pos.order.line')
678 return super(pos_order_line, self).copy_data(cr, uid, id, default, context=context)
682 class pos_category(osv.osv):
683 _name = 'pos.category'
684 _inherit = 'product.category'
686 'parent_id': fields.many2one('pos.category','Parent Category', select=True),
687 'child_id': fields.one2many('pos.category', 'parent_id', string='Child Categories'),
691 class product_product(osv.osv):
692 _inherit = 'product.product'
694 'income_pdt': fields.boolean('Product for Input'),
695 'expense_pdt': fields.boolean('Product for Output'),
696 'img': fields.binary('Pos Image, must be 50x50'),
697 'pos_categ_id': fields.many2one('pos.category','POS Category', change_default=True, domain="[('type','=','normal')]" ,help="Select a pos category for the current product")