[MERGE] merge Syleam branch on POS

bzr revid: christophe@cobalt-20081222084037-98sr3qvuqw71gxkg
This commit is contained in:
Christophe Simonis
2008-12-22 09:40:37 +01:00
7 changed files with 234 additions and 17 deletions
+70 -3
View File
@@ -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
+67 -5
View File
@@ -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={}):
+6 -4
View File
@@ -9,6 +9,8 @@
<form string="Sales Order POS">
<notebook >
<page string="Order lines">
<field name="partner_id" on_change="onchange_partner_pricelist(partner_id)"/>
<field name="pricelist_id" domain="[('type','=','sale')]"/>
<field name="lines" colspan="4" nolabel="1">
<tree string="Order lines" editable="bottom">
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)" width="275"/>
@@ -73,15 +75,16 @@
<page string="Payment">
<field name="payments" colspan="4" nolabel="1">
<tree string="Payments" editable="bottom">
<field name="journal_id" select="1" width="200"/>
<field name="payment_id" />
<field name="payment_nb" />
<field name="payment_name" width="200" />
<field name="payment_date" />
<field name="amount" />
</tree>
</field>
<separator string="Invoicing" colspan="4"/>
<field name="nb_print"/>
<newline/>
<field name="partner_id" on_change="onchange_partner_pricelist(partner_id)"/>
<newline/>
<field name="invoice_id"/>
<label/>
<button name="invoice" string="Create _Invoice" states="paid"/>
@@ -91,7 +94,6 @@
</page>
<page string="Other">
<field name="pricelist_id" domain="[('type','=','sale')]"/>
<field name="shop_id" />
<field name="name" select="1"/>
<field name="date_order" select="1"/>
+3
View File
@@ -26,5 +26,8 @@
<wizard string="Get From Order" model="pos.order"
name="pos.sale.get" id="pos_sale_get"/>
<wizard string="Scan Product" model="pos.order"
name="pos.scan_product" id="pos_scan_product"/>
</data>
</openerp>
+1
View File
@@ -27,5 +27,6 @@ import wizard_add_product
import wizard_confirm
import wizard_discount
import wizard_get_sale
import wizard_scan_product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -23,6 +23,7 @@
import pooler
import netsvc
import wizard
import time
def _get_journal(self, cr, uid, context):
@@ -38,6 +39,10 @@ payment_form = """<?xml version="1.0"?>
<form string="Add payment :">
<field name="amount" />
<field name="journal"/>
<field name="payment_id" />
<field name="payment_date" />
<field name="payment_nb" />
<field name="payment_name" />
<field name="invoice_wanted" />
</form>
"""
@@ -50,6 +55,10 @@ payment_fields = {
'selection': _get_journal,
'required': True,
},
'payment_id': {'string': 'Payment Term', 'type': 'many2one', 'relation': 'account.payment.term', 'required': True},
'payment_date': {'string': 'Payment date', 'type': 'date', 'required': True},
'payment_name': {'string': 'Payment name', 'type': 'char', 'size': '32'},
'payment_nb': {'string': 'Piece number', 'type': 'char', 'size': '32'},
}
@@ -95,20 +104,23 @@ def _pre_init(self, cr, uid, data, context):
#invoice_wanted_checked = not not order.partner_id # not not -> boolean
invoice_wanted_checked = False
return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked}
# select the current date
current_date = time.strftime('%Y-%m-%d')
return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked, 'payment_date': current_date}
def _add_pay(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
order_obj = pool.get('pos.order')
amount = data['form']['amount']
journal = data['form']['journal']
invoice_wanted = data['form']['invoice_wanted'] == 1
result = data['form']
invoice_wanted = data['form']['invoice_wanted']
# add 'invoice_wanted' in 'pos.order'
order_obj.write(cr, uid, [data['id']], {'invoice_wanted': invoice_wanted})
order_obj.add_payment(cr, uid, data['id'], amount, journal, context=context)
order_obj.add_payment(cr, uid, data['id'], result, context=context)
return {}
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# Copyright (c) 2008 Sylëam Info Services. (http://www.syleam.fr) All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pooler
import wizard
from osv import osv
form_gencod = """<?xml version="1.0"?>
<form string="Scan product">
<label string="Scan gencod" colspan="4"/>
<field name="gencod" colspan="4" nolabel="1"/>
</form>
"""
fields_gencod = {
'gencod': {'string': 'Gencod',
'type': 'char',
'size': 13,
'required': True}
}
def _scan(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
result = pool.get('pos.order.line')._scan_product(cr, uid, data['form']['gencod'], 1, data['id'])
return {'gencod': False}
def _pre_init(self, cr, uid, data, context):
return {'gencod': False}
class pos_scan_product(wizard.interface):
states = {
'init' : {'actions' : [_pre_init],
'result' : {
'type': 'form',
'arch': form_gencod,
'fields': fields_gencod,
'state': [('end','Cancel','gtk-cancel'),
('add', 'Add', 'gtk-ok', True)],
}
},
'add' : {'actions' : [_scan],
'result' : {
'type': 'state',
'state': 'init',
}
}
}
pos_scan_product('pos.scan_product')