[IMP]
* Report syleam_pos improvement to point_of_sale module * Move Partner and Pricelist on the first tab * Add Payment Term, Payment Name, Payment Date and Piece Number on Payment tab * Complete wizard make payment with the new payment fields bzr revid: sebatien.lange@syleam.fr-20081220182938-iponcc59o334xpzb
This commit is contained in:
parent
45bf3769ae
commit
d5705c6b5c
|
@ -408,18 +408,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)
|
||||
|
@ -826,11 +836,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={}):
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -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 {}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue