[FIX] point_of_sale: removed old reference to warehouse_id in rml file + removed unused pos_return wizard
bzr revid: qdp-launchpad@openerp.com-20140401124712-uz97vqfuyi8kn1un
This commit is contained in:
parent
9989113946
commit
7a3da62754
|
@ -75,7 +75,7 @@
|
||||||
<para style="terp_default_Centre_9">[[ address and display_address(address)]]</para>
|
<para style="terp_default_Centre_9">[[ address and display_address(address)]]</para>
|
||||||
<para style="terp_default_Centre_9">Tel : [[ address and address.phone ]]</para>
|
<para style="terp_default_Centre_9">Tel : [[ address and address.phone ]]</para>
|
||||||
<para style="terp_default_Centre_9">User : [[ o.user_id.name ]]</para>
|
<para style="terp_default_Centre_9">User : [[ o.user_id.name ]]</para>
|
||||||
<para style="terp_default_Centre_9">Warehouse : [[ o.warehouse_id.name ]]</para>
|
<!-- <para style="terp_default_Centre_9">Warehouse : [[ o.warehouse_id.name ]]</para>-->
|
||||||
<para style="terp_default_Centre_9">Date : [[ o.date_order ]]</para>
|
<para style="terp_default_Centre_9">Date : [[ o.date_order ]]</para>
|
||||||
<para style="P4">
|
<para style="P4">
|
||||||
<font color="white"> </font>
|
<font color="white"> </font>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<field name="name">Point Of Sale Config</field>
|
<field name="name">Point Of Sale Config</field>
|
||||||
<field name="model_id" ref="model_pos_config" />
|
<field name="model_id" ref="model_pos_config" />
|
||||||
<field name="global" eval="True" />
|
<field name="global" eval="True" />
|
||||||
<field name="domain_force">[('warehouse_id.company_id','child_of',[user.company_id.id])]</field>
|
<field name="domain_force">[('company_id','child_of',[user.company_id.id])]</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -1,244 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
from openerp.osv import osv,fields
|
|
||||||
from openerp.tools.translate import _
|
|
||||||
import time
|
|
||||||
|
|
||||||
class pos_return(osv.osv_memory):
|
|
||||||
_name = 'pos.return'
|
|
||||||
_description = 'Point of sale return'
|
|
||||||
_columns = {
|
|
||||||
'pos_moves_ids' : fields.one2many('pos.return.memory', 'pos_moves_id', 'Moves'),
|
|
||||||
}
|
|
||||||
|
|
||||||
def default_get(self, cr, uid, fields, context=None):
|
|
||||||
"""
|
|
||||||
To get default values for the object.
|
|
||||||
|
|
||||||
@param self: The object pointer.
|
|
||||||
@param cr: A database cursor
|
|
||||||
@param uid: ID of the user currently logged in
|
|
||||||
@param fields: List of fields for which we want default values
|
|
||||||
@param context: A standard dictionary
|
|
||||||
|
|
||||||
@return: A dictionary which of fields with values.
|
|
||||||
|
|
||||||
"""
|
|
||||||
res = super(pos_return, self).default_get(cr, uid, fields, context=context)
|
|
||||||
order_obj = self.pool.get('pos.order')
|
|
||||||
if context is None:
|
|
||||||
context={}
|
|
||||||
active_ids = context.get('active_ids')
|
|
||||||
result=[]
|
|
||||||
for order in order_obj.browse(cr, uid, active_ids, context=context):
|
|
||||||
for line in order.lines:
|
|
||||||
result.append({
|
|
||||||
'product_id' : line.product_id.id,
|
|
||||||
'quantity' : line.qty,
|
|
||||||
'line_id':line.id
|
|
||||||
})
|
|
||||||
res.update({'pos_moves_ids': result})
|
|
||||||
return res
|
|
||||||
|
|
||||||
def create_returns(self, cr, uid, data, context=None):
|
|
||||||
"""
|
|
||||||
@param self: The object pointer.
|
|
||||||
@param cr: A database cursor
|
|
||||||
@param uid: ID of the user currently logged in
|
|
||||||
@param context: A standard dictionary
|
|
||||||
|
|
||||||
@return: Return the add product form again for adding more product
|
|
||||||
|
|
||||||
"""
|
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
current_rec = self.browse(cr, uid, data, context=context)[0]
|
|
||||||
order_obj =self.pool.get('pos.order')
|
|
||||||
line_obj = self.pool.get('pos.order.line')
|
|
||||||
pos_current = order_obj.browse(cr, uid, context.get('active_id'), context=context)
|
|
||||||
for pos_line in pos_current.lines:
|
|
||||||
for record in current_rec.pos_moves_ids:
|
|
||||||
if pos_line.id == record.line_id:
|
|
||||||
less_qty = record.quantity
|
|
||||||
line_obj.write(cr, uid, pos_line.id, {'qty':pos_line.qty - less_qty}, context=context)
|
|
||||||
return {
|
|
||||||
'name': _('Add Product'),
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'pos.add.product',
|
|
||||||
'view_id': False,
|
|
||||||
'target':'new',
|
|
||||||
'views': False,
|
|
||||||
'context': context,
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class add_product(osv.osv_memory):
|
|
||||||
_inherit = 'pos.add.product'
|
|
||||||
def select_product(self, cr, uid, ids, context=None):
|
|
||||||
"""
|
|
||||||
To get the product and quantity and add in order .
|
|
||||||
@param self: The object pointer.
|
|
||||||
@param cr: A database cursor
|
|
||||||
@param uid: ID of the user currently logged in
|
|
||||||
@param context: A standard dictionary
|
|
||||||
@return : Retrun the add product form again for adding more product
|
|
||||||
"""
|
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
|
|
||||||
active_id=context.get('active_id', False)
|
|
||||||
data = self.read(cr, uid, ids)
|
|
||||||
data = data and data[0] or False
|
|
||||||
if active_id:
|
|
||||||
order_obj = self.pool.get('pos.order')
|
|
||||||
picking_obj = self.pool.get('stock.picking')
|
|
||||||
stock_move_obj = self.pool.get('stock.move')
|
|
||||||
property_obj= self.pool.get("ir.property")
|
|
||||||
date_cur=time.strftime('%Y-%m-%d')
|
|
||||||
uom_obj = self.pool.get('product.uom')
|
|
||||||
prod_obj=self.pool.get('product.product')
|
|
||||||
order_obj.add_product(cr, uid, active_id, data['product_id'], data['quantity'], context=context)
|
|
||||||
|
|
||||||
for order_id in order_obj.browse(cr, uid, [active_id], context=context):
|
|
||||||
prod=data['product_id']
|
|
||||||
qty=data['quantity']
|
|
||||||
stock_dest_id = property_obj.get(cr, uid, 'property_stock_customer', 'res.partner', context=context).id
|
|
||||||
cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
|
|
||||||
"WHERE w.lot_stock_id=s.id AND w.id=%s ",
|
|
||||||
(order_id.warehouse_id.id,))
|
|
||||||
res=cr.fetchone()
|
|
||||||
location_id=res and res[0] or None
|
|
||||||
prod_id=prod_obj.browse(cr, uid, prod, context=context)
|
|
||||||
new_picking=picking_obj.create(cr, uid, {
|
|
||||||
'name':'%s (Added)' %order_id.name,
|
|
||||||
'move_lines':[],
|
|
||||||
'state':'draft',
|
|
||||||
'picking_type_id': self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id,
|
|
||||||
'date':date_cur
|
|
||||||
})
|
|
||||||
stock_move_obj.create(cr, uid, {
|
|
||||||
'product_uom_qty': qty,
|
|
||||||
'product_uos_qty': uom_obj._compute_qty(cr, uid, prod_id.uom_id.id, qty, prod_id.uom_id.id),
|
|
||||||
'picking_id':new_picking,
|
|
||||||
'product_uom':prod_id.uom_id.id,
|
|
||||||
'location_id':location_id,
|
|
||||||
'product_id':prod_id.id,
|
|
||||||
'location_dest_id':stock_dest_id,
|
|
||||||
'name':'%s (return)' %order_id.name,
|
|
||||||
'date':date_cur
|
|
||||||
})
|
|
||||||
|
|
||||||
picking_obj.signal_button_confirm(cr, uid, [new_picking])
|
|
||||||
picking_obj.force_assign(cr, uid, [new_picking], context)
|
|
||||||
order_obj.write(cr,uid,active_id,{'picking_id':new_picking})
|
|
||||||
|
|
||||||
return {
|
|
||||||
'name': _('Add Product'),
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'pos.add.product',
|
|
||||||
'view_id': False,
|
|
||||||
'target':'new',
|
|
||||||
'context':context,
|
|
||||||
'views': False,
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
}
|
|
||||||
|
|
||||||
def close_action(self, cr, uid, ids, context=None):
|
|
||||||
if context is None: context = {}
|
|
||||||
active_ids=context.get('active_ids', False)
|
|
||||||
order_obj = self.pool.get('pos.order')
|
|
||||||
lines_obj = self.pool.get('pos.order.line')
|
|
||||||
picking_obj = self.pool.get('stock.picking')
|
|
||||||
stock_move_obj = self.pool.get('stock.move')
|
|
||||||
property_obj= self.pool.get("ir.property")
|
|
||||||
invoice_obj=self.pool.get('account.invoice')
|
|
||||||
date_cur=time.strftime('%Y-%m-%d %H:%M:%S')
|
|
||||||
uom_obj = self.pool.get('product.uom')
|
|
||||||
return_boj=self.pool.get('pos.return')
|
|
||||||
return_id = return_boj.search(cr,uid,[])
|
|
||||||
data = {}
|
|
||||||
if return_id:
|
|
||||||
data = return_boj.read(cr,uid,return_id,[])[0]
|
|
||||||
|
|
||||||
self_data = self.browse(cr, uid, ids, context=context)[0]
|
|
||||||
order_obj.add_product(cr, uid, active_ids[0], self_data.product_id.id, self_data.quantity, context=context)
|
|
||||||
|
|
||||||
for order_id in order_obj.browse(cr, uid, active_ids, context=context):
|
|
||||||
stock_dest_id = property_obj.get(cr, uid, 'property_stock_customer', 'res.partner', context=context).id
|
|
||||||
cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
|
|
||||||
" WHERE w.lot_stock_id=s.id AND w.id=%s ",
|
|
||||||
(order_id.warehouse_id.id,))
|
|
||||||
res=cr.fetchone()
|
|
||||||
location_id=res and res[0] or None
|
|
||||||
|
|
||||||
if order_id.invoice_id:
|
|
||||||
invoice_obj.refund(cr, uid, [order_id.invoice_id.id], time.strftime('%Y-%m-%d'), False, order_id.name, context=context)
|
|
||||||
new_picking=picking_obj.create(cr, uid, {
|
|
||||||
'name':'%s (return)' %order_id.name,
|
|
||||||
'move_lines':[], 'state':'draft',
|
|
||||||
'type':'in',
|
|
||||||
'date':date_cur
|
|
||||||
})
|
|
||||||
for line in order_id.lines:
|
|
||||||
key= 'return%s' % line.id
|
|
||||||
if line.id:
|
|
||||||
if data.has_key(key):
|
|
||||||
qty = data[key]
|
|
||||||
lines_obj.write(cr,uid,[line.id], {
|
|
||||||
'qty':line.qty-(data[key] or 0.0)
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
qty = line.qty
|
|
||||||
stock_move_obj.create(cr, uid, {
|
|
||||||
'product_uom_qty': qty,
|
|
||||||
'product_uos_qty': uom_obj._compute_qty(cr, uid, qty, line.product_id.uom_id.id),
|
|
||||||
'picking_id':new_picking,
|
|
||||||
'product_uom':line.product_id.uom_id.id,
|
|
||||||
'location_id':location_id,
|
|
||||||
'product_id':line.product_id.id,
|
|
||||||
'location_dest_id':stock_dest_id,
|
|
||||||
'name':'%s (return)' % order_id.name,
|
|
||||||
'date':date_cur,
|
|
||||||
})
|
|
||||||
picking_obj.signal_button_confirm(cr, uid, [new_picking])
|
|
||||||
picking_obj.force_assign(cr, uid, [new_picking], context)
|
|
||||||
obj=order_obj.browse(cr,uid, active_ids[0])
|
|
||||||
context.update({'return':'return'})
|
|
||||||
|
|
||||||
if obj.amount_total != obj.amount_paid:
|
|
||||||
return {
|
|
||||||
'name': _('Make Payment'),
|
|
||||||
'context ':context,
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'pos.make.payment',
|
|
||||||
'view_id': False,
|
|
||||||
'target': 'new',
|
|
||||||
'views': False,
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
}
|
|
||||||
return True
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
@ -1,53 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<openerp>
|
|
||||||
<data>
|
|
||||||
<record id="pos_return_form" model="ir.ui.view">
|
|
||||||
<field name="name">pos.return</field>
|
|
||||||
<field name="model">pos.return</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form string="Return lines" version="7.0">
|
|
||||||
<footer>
|
|
||||||
<button name= "create_returns" string="Return Products" type="object" class="oe_highlight" />
|
|
||||||
or
|
|
||||||
<button string="Cancel" class="oe_link" special="cancel" />
|
|
||||||
</footer>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="action_view_pos_return" model="ir.actions.act_window">
|
|
||||||
<field name="name">Return lines</field>
|
|
||||||
<field name="res_model">pos.return</field>
|
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">form</field>
|
|
||||||
<field name="target">new</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="pos_return_tree_in" model="ir.ui.view">
|
|
||||||
<field name="name">pos.return.memory</field>
|
|
||||||
<field name="model">pos.return.memory</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<tree editable="bottom" string="Return Product">
|
|
||||||
<field name="product_id" />
|
|
||||||
<field name="quantity" />
|
|
||||||
<field name="line_id" invisible="1"/>
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="pos_return_form_in" model="ir.ui.view">
|
|
||||||
<field name="name">pos.return.memory</field>
|
|
||||||
<field name="model">pos.return.memory</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form version="7.0">
|
|
||||||
<group col="4">
|
|
||||||
<field name="product_id" />
|
|
||||||
<field name="quantity" />
|
|
||||||
<field name="line_id" invisible="1"/>
|
|
||||||
</group>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</data>
|
|
||||||
</openerp>
|
|
Loading…
Reference in New Issue