diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index 524c6a4549c..0b548ce2891 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 5.0.0-rc1\n" +"Project-Id-Version: OpenERP Server 5.0.0_rc1\n" "Report-Msgid-Bugs-To: support@openerp.com\n" -"POT-Creation-Date: 2008-11-28 17:09:36+0000\n" -"PO-Revision-Date: 2008-11-28 17:09:36+0000\n" +"POT-Creation-Date: 2008-12-20 19:51:31+0000\n" +"PO-Revision-Date: 2008-12-20 19:51:31+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -42,11 +42,22 @@ msgstr "" msgid "Discount :" msgstr "" +#. module: point_of_sale +#: wizard_field:pos.payment,ask_pay,payment_nb:0 +#: field:pos.payment,payment_nb:0 +msgid "Piece number" +msgstr "" + #. module: point_of_sale #: field:pos.order,name:0 msgid "Order Description" msgstr "" +#. module: point_of_sale +#: model:ir.actions.wizard,name:point_of_sale.pos_scan_product +msgid "Scan Product" +msgstr "" + #. module: point_of_sale #: rml:pos.invoice:0 msgid "Document" @@ -87,6 +98,11 @@ msgstr "" msgid "Base" msgstr "" +#. module: point_of_sale +#: wizard_view:pos.scan_product,init:0 +msgid "Scan product" +msgstr "" + #. module: point_of_sale #: field:pos.order.line,price_subtotal:0 msgid "Subtotal" @@ -112,6 +128,11 @@ msgstr "" msgid "Ok" msgstr "" +#. module: point_of_sale +#: wizard_view:pos.scan_product,init:0 +msgid "Scan gencod" +msgstr "" + #. module: point_of_sale #: field:pos.order,last_out_picking:0 msgid "Last output picking" @@ -152,6 +173,7 @@ msgid "Number of transaction" msgstr "" #. module: point_of_sale +#: model:ir.actions.act_window,name:point_of_sale.action_pos_order_line #: model:ir.actions.act_window,name:point_of_sale.action_pos_order_line_day msgid "Sale line" msgstr "" @@ -283,6 +305,26 @@ msgstr "" msgid "Sum of subtotals" msgstr "" +#. module: point_of_sale +#: wizard_field:pos.payment,ask_pay,payment_date:0 +#: field:pos.payment,payment_date:0 +msgid "Payment date" +msgstr "" + +#. module: point_of_sale +#: wizard_field:pos.payment,ask_pay,payment_name:0 +#: field:pos.payment,payment_name:0 +msgid "Payment name" +msgstr "" + +#. module: point_of_sale +#: selection:pos.payment,ask_pay,journal:0 +#: selection:pos.config.journal,init,default_journal_rebate:0 +#: selection:pos.config.journal,init,default_journal_gift:0 +#: selection:pos.config.journal,init,default_journal:0 +msgid "x Bank Journal" +msgstr "" + #. module: point_of_sale #: field:pos.order,lines:0 msgid "Order Lines" @@ -457,6 +499,16 @@ msgstr "" msgid "Disc :" msgstr "" +#. module: point_of_sale +#: wizard_field:pos.scan_product,init,gencod:0 +msgid "Gencod" +msgstr "" + +#. module: point_of_sale +#: wizard_button:pos.scan_product,init,add:0 +msgid "Add" +msgstr "" + #. module: point_of_sale #: selection:pos.order,state:0 msgid "Draft" @@ -487,6 +539,14 @@ msgstr "" msgid "E-mail :" msgstr "" +#. module: point_of_sale +#: selection:pos.payment,ask_pay,journal:0 +#: selection:pos.config.journal,init,default_journal_rebate:0 +#: selection:pos.config.journal,init,default_journal_gift:0 +#: selection:pos.config.journal,init,default_journal:0 +msgid "x Checks Journal" +msgstr "" + #. module: point_of_sale #: rml:pos.details_summary:0 #: rml:pos.details:0 @@ -679,6 +739,7 @@ msgstr "" #: wizard_button:pos.payment,ask_pay,end:0 #: wizard_button:pos.refund_order,init,end:0 #: wizard_button:pos.sale.get,init,end:0 +#: wizard_button:pos.scan_product,init,end:0 #: wizard_button:pos.config.journal,init,end:0 #: selection:pos.order,state:0 #: view:pos.order:0 @@ -863,6 +924,12 @@ msgstr "" msgid "Account Entry" msgstr "" +#. module: point_of_sale +#: wizard_field:pos.payment,ask_pay,payment_id:0 +#: field:pos.payment,payment_id:0 +msgid "Payment Term" +msgstr "" + #. module: point_of_sale #: rml:pos.invoice:0 #: wizard_field:pos.payment,ask_pay,amount:0 diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index d3f1e3a9b1b..18f37db8806 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -24,6 +24,7 @@ import time import netsvc from osv import fields, osv from mx import DateTime +from tools.translate import _ class pos_config_journal(osv.osv): @@ -408,18 +409,28 @@ class pos_order(osv.osv): return True - def add_payment(self, cr, uid, order_id, amount, journal, context=None): + def add_payment(self, cr, uid, order_id, data, context=None): """Create a new payment for the order""" order = self.browse(cr, uid, order_id, context) if order.invoice_wanted and not order.partner_id: raise osv.except_osv("Error", "Cannot create invoice without a partner.") - payment_id = self.pool.get('pos.payment').create(cr, uid, { + args = { 'order_id': order_id, - 'journal_id': journal, - 'amount': amount, - }) + 'journal_id': data['journal'], + 'amount': data['amount'], + 'payment_id': data['payment_id'], + } + + if 'payment_date' in data.keys(): + args['payment_date'] = data['payment_date'] + if 'payment_name' in data.keys(): + args['payment_name'] = data['payment_name'] + if 'payment_nb' in data.keys(): + args['payment_nb'] = data['payment_nb'] + + payment_id = self.pool.get('pos.payment').create(cr, uid, args ) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'pos.order', order_id, 'payment', cr) @@ -801,6 +812,52 @@ class pos_order_line(osv.osv): return False return super(pos_order_line, self).write(cr, user, ids, values, context) + def _scan_product(self, cr, uid, ean, qty, order): + # search pricelist_id + pricelist_id = self.pool.get('pos.order').read(cr, uid, [order], ['pricelist_id'] ) + if not pricelist_id: + return False + + new_line = True + + product_id = self.pool.get('product.product').search(cr, uid, [('ean13','=', ean)]) + if not product_id: + return false + + # search price product + product = self.pool.get('product.product').read(cr, uid, product_id) + product_name = product[0]['name'] + price = self.price_by_product(cr, uid, 0, pricelist_id[0]['pricelist_id'][0], product_id[0], 1) + + order_line_ids = self.search(cr, uid, [('name','=',product_name),('order_id','=',order)]) + if order_line_ids: + new_line = False + order_line_id = order_line_ids[0] + qty += self.read(cr, uid, order_line_ids[0], ['qty'])['qty'] + + if new_line: + vals = {'product_id': product_id[0], + 'price_unit': price, + 'qty': qty, + 'name': product_name, + 'order_id': order, + } + line_id = self.create(cr, uid, vals) + if not line_id: + raise wizard.except_wizard(_('Error'), _('Create line failed !')) + else: + vals = { + 'qty': qty, + 'price_unit': price + } + line_id = self.write(cr, uid, order_line_id, vals) + if not line_id: + raise wizard.except_wizard(_('Error'), _('Modify line failed !')) + line_id = order_line_id + + price_line = float(qty)*float(price) + return {'name': product_name, 'product_id': product_id[0], 'price': price, 'price_line': price_line ,'qty': qty } + pos_order_line() @@ -826,11 +883,16 @@ class pos_payment(osv.osv): 'name': fields.char('Description', size=64), 'order_id': fields.many2one('pos.order', 'Order Ref', required=True, ondelete='cascade'), 'journal_id': fields.many2one('account.journal', "Journal", required=True), + 'payment_id': fields.many2one('account.payment.term','Payment Term', select=True), + 'payment_nb': fields.char('Piece number', size=32), + 'payment_name': fields.char('Payment name', size=32), + 'payment_date': fields.date('Payment date', required=True), 'amount': fields.float('Amount', required=True), } _defaults = { 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.payment'), 'journal_id': _journal_default, + 'payment_date': lambda *a: time.strftime('%Y-%m-%d'), } def create(self, cr, user, vals, context={}): diff --git a/addons/point_of_sale/pos_view.xml b/addons/point_of_sale/pos_view.xml index 4c6510f4abb..68eb8ebf3ed 100644 --- a/addons/point_of_sale/pos_view.xml +++ b/addons/point_of_sale/pos_view.xml @@ -9,6 +9,8 @@