[MERGE] merge branch that fixes point of sale accordingly to changes made in stock
bzr revid: qdp-launchpad@openerp.com-20140328145710-ibzo59dv1p06jbg3
This commit is contained in:
commit
9989113946
|
@ -210,8 +210,6 @@ class EscposDriver(Thread):
|
||||||
eprint.text(receipt['company']['name'] + '\n')
|
eprint.text(receipt['company']['name'] + '\n')
|
||||||
|
|
||||||
eprint.set(align='center',type='b')
|
eprint.set(align='center',type='b')
|
||||||
if check(receipt['shop']['name']):
|
|
||||||
eprint.text(receipt['shop']['name'] + '\n')
|
|
||||||
if check(receipt['company']['contact_address']):
|
if check(receipt['company']['contact_address']):
|
||||||
eprint.text(receipt['company']['contact_address'] + '\n')
|
eprint.text(receipt['company']['contact_address'] + '\n')
|
||||||
if check(receipt['company']['phone']):
|
if check(receipt['company']['phone']):
|
||||||
|
|
|
@ -61,8 +61,8 @@ class pos_config(osv.osv):
|
||||||
'journal_ids' : fields.many2many('account.journal', 'pos_config_journal_rel',
|
'journal_ids' : fields.many2many('account.journal', 'pos_config_journal_rel',
|
||||||
'pos_config_id', 'journal_id', 'Available Payment Methods',
|
'pos_config_id', 'journal_id', 'Available Payment Methods',
|
||||||
domain="[('journal_user', '=', True ), ('type', 'in', ['bank', 'cash'])]",),
|
domain="[('journal_user', '=', True ), ('type', 'in', ['bank', 'cash'])]",),
|
||||||
'warehouse_id' : fields.many2one('stock.warehouse', 'Warehouse',
|
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
|
||||||
required=True),
|
'stock_location_id': fields.many2one('stock.location', 'Stock Location', domain=[('usage', '=', 'internal')], required=True),
|
||||||
'journal_id' : fields.many2one('account.journal', 'Sale Journal',
|
'journal_id' : fields.many2one('account.journal', 'Sale Journal',
|
||||||
domain=[('type', '=', 'sale')],
|
domain=[('type', '=', 'sale')],
|
||||||
help="Accounting journal used to post sales entries."),
|
help="Accounting journal used to post sales entries."),
|
||||||
|
@ -87,7 +87,8 @@ class pos_config(osv.osv):
|
||||||
"to customize the reference numbers of your orders."),
|
"to customize the reference numbers of your orders."),
|
||||||
'session_ids': fields.one2many('pos.session', 'config_id', 'Sessions'),
|
'session_ids': fields.one2many('pos.session', 'config_id', 'Sessions'),
|
||||||
'group_by' : fields.boolean('Group Journal Items', help="Check this if you want to group the Journal Items by Product while closing a Session"),
|
'group_by' : fields.boolean('Group Journal Items', help="Check this if you want to group the Journal Items by Product while closing a Session"),
|
||||||
'pricelist_id': fields.many2one('product.pricelist','Pricelist', required=True)
|
'pricelist_id': fields.many2one('product.pricelist','Pricelist', required=True),
|
||||||
|
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _check_cash_control(self, cr, uid, ids, context=None):
|
def _check_cash_control(self, cr, uid, ids, context=None):
|
||||||
|
@ -131,24 +132,39 @@ class pos_config(osv.osv):
|
||||||
res = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale'), ('company_id', '=', company_id)], limit=1, context=context)
|
res = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale'), ('company_id', '=', company_id)], limit=1, context=context)
|
||||||
return res and res[0] or False
|
return res and res[0] or False
|
||||||
|
|
||||||
def _default_warehouse(self, cr, uid, context=None):
|
|
||||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
|
||||||
res = self.pool.get('stock.warehouse').search(cr, uid, [('company_id', '=', user.company_id.id)], limit=1, context=context)
|
|
||||||
return res and res[0] or False
|
|
||||||
|
|
||||||
def _default_pricelist(self, cr, uid, context=None):
|
def _default_pricelist(self, cr, uid, context=None):
|
||||||
res = self.pool.get('product.pricelist').search(cr, uid, [('type', '=', 'sale')], limit=1, context=context)
|
res = self.pool.get('product.pricelist').search(cr, uid, [('type', '=', 'sale')], limit=1, context=context)
|
||||||
return res and res[0] or False
|
return res and res[0] or False
|
||||||
|
|
||||||
|
def _get_default_location(self, cr, uid, context=None):
|
||||||
|
wh_obj = self.pool.get('stock.warehouse')
|
||||||
|
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||||
|
res = wh_obj.search(cr, uid, [('company_id', '=', user.company_id.id)], limit=1, context=context)
|
||||||
|
if res and res[0]:
|
||||||
|
return wh_obj.browse(cr, uid, res[0], context=context).lot_stock_id.id
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _get_default_company(self, cr, uid, context=None):
|
||||||
|
company_id = self.pool.get('res.users')._get_company(cr, uid, context=context)
|
||||||
|
return company_id
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'state' : POS_CONFIG_STATE[0][0],
|
'state' : POS_CONFIG_STATE[0][0],
|
||||||
'warehouse_id': _default_warehouse,
|
|
||||||
'journal_id': _default_sale_journal,
|
'journal_id': _default_sale_journal,
|
||||||
'group_by' : True,
|
'group_by' : True,
|
||||||
'pricelist_id': _default_pricelist,
|
'pricelist_id': _default_pricelist,
|
||||||
'iface_invoicing': True,
|
'iface_invoicing': True,
|
||||||
|
'stock_location_id': _get_default_location,
|
||||||
|
'company_id': _get_default_company,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def onchange_picking_type_id(self, cr, uid, ids, picking_type_id, context=None):
|
||||||
|
p_type_obj = self.pool.get("stock.picking.type")
|
||||||
|
p_type = p_type_obj.browse(cr, uid, picking_type_id, context=context)
|
||||||
|
if p_type.default_location_src_id and p_type.default_location_src_id.usage == 'internal' and p_type.default_location_dest_id and p_type.default_location_dest_id.usage == 'customer':
|
||||||
|
return {'value': {'stock_location_id': p_type.default_location_src_id.id}}
|
||||||
|
return False
|
||||||
|
|
||||||
def set_active(self, cr, uid, ids, context=None):
|
def set_active(self, cr, uid, ids, context=None):
|
||||||
return self.write(cr, uid, ids, {'state' : 'active'}, context=context)
|
return self.write(cr, uid, ids, {'state' : 'active'}, context=context)
|
||||||
|
|
||||||
|
@ -334,7 +350,7 @@ class pos_session(osv.osv):
|
||||||
# the .xml files as the CoA is not yet installed.
|
# the .xml files as the CoA is not yet installed.
|
||||||
jobj = self.pool.get('pos.config')
|
jobj = self.pool.get('pos.config')
|
||||||
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
||||||
context.update({'company_id': pos_config.warehouse_id.company_id.id})
|
context.update({'company_id': pos_config.company_id.id})
|
||||||
if not pos_config.journal_id:
|
if not pos_config.journal_id:
|
||||||
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
||||||
if jid:
|
if jid:
|
||||||
|
@ -361,7 +377,7 @@ class pos_session(osv.osv):
|
||||||
bank_values = {
|
bank_values = {
|
||||||
'journal_id' : journal.id,
|
'journal_id' : journal.id,
|
||||||
'user_id' : uid,
|
'user_id' : uid,
|
||||||
'company_id' : pos_config.warehouse_id.company_id.id
|
'company_id' : pos_config.company_id.id
|
||||||
}
|
}
|
||||||
statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_values, context=context)
|
statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_values, context=context)
|
||||||
bank_statement_ids.append(statement_id)
|
bank_statement_ids.append(statement_id)
|
||||||
|
@ -642,7 +658,6 @@ class pos_order(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Order Ref', size=64, required=True, readonly=True),
|
'name': fields.char('Order Ref', size=64, required=True, readonly=True),
|
||||||
'company_id':fields.many2one('res.company', 'Company', required=True, readonly=True),
|
'company_id':fields.many2one('res.company', 'Company', required=True, readonly=True),
|
||||||
'warehouse_id': fields.related('session_id', 'config_id', 'warehouse_id', relation='stock.warehouse', type='many2one', string='Warehouse', store=True, readonly=True),
|
|
||||||
'date_order': fields.datetime('Order Date', readonly=True, select=True),
|
'date_order': fields.datetime('Order Date', readonly=True, select=True),
|
||||||
'user_id': fields.many2one('res.users', 'Salesman', help="Person who uses the the cash register. It can be a reliever, a student or an interim employee."),
|
'user_id': fields.many2one('res.users', 'Salesman', help="Person who uses the the cash register. It can be a reliever, a student or an interim employee."),
|
||||||
'amount_tax': fields.function(_amount_all, string='Taxes', digits_compute=dp.get_precision('Account'), multi='all'),
|
'amount_tax': fields.function(_amount_all, string='Taxes', digits_compute=dp.get_precision('Account'), multi='all'),
|
||||||
|
@ -671,7 +686,8 @@ class pos_order(osv.osv):
|
||||||
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
|
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
|
||||||
'account_move': fields.many2one('account.move', 'Journal Entry', readonly=True),
|
'account_move': fields.many2one('account.move', 'Journal Entry', readonly=True),
|
||||||
'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True),
|
'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True),
|
||||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True),
|
'picking_type_id': fields.related('session_id', 'config_id', 'picking_type_id', string="Picking Type", type='many2one', relation='stock.picking.type'),
|
||||||
|
'location_id': fields.related('session_id', 'config_id', 'stock_location_id', string="Location", type='many2one', store=True, relation='stock.location'),
|
||||||
'note': fields.text('Internal Notes'),
|
'note': fields.text('Internal Notes'),
|
||||||
'nb_print': fields.integer('Number of Print', readonly=True),
|
'nb_print': fields.integer('Number of Print', readonly=True),
|
||||||
'pos_reference': fields.char('Receipt Ref', size=64, readonly=True),
|
'pos_reference': fields.char('Receipt Ref', size=64, readonly=True),
|
||||||
|
@ -706,7 +722,6 @@ class pos_order(osv.osv):
|
||||||
'session_id': _default_session,
|
'session_id': _default_session,
|
||||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||||
'pricelist_id': _default_pricelist,
|
'pricelist_id': _default_pricelist,
|
||||||
'picking_type_id': _get_out_picking_type,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(self, cr, uid, values, context=None):
|
def create(self, cr, uid, values, context=None):
|
||||||
|
@ -736,43 +751,55 @@ class pos_order(osv.osv):
|
||||||
continue
|
continue
|
||||||
addr = order.partner_id and partner_obj.address_get(cr, uid, [order.partner_id.id], ['delivery']) or {}
|
addr = order.partner_id and partner_obj.address_get(cr, uid, [order.partner_id.id], ['delivery']) or {}
|
||||||
picking_type = order.picking_type_id
|
picking_type = order.picking_type_id
|
||||||
picking_id = picking_obj.create(cr, uid, {
|
picking_id = False
|
||||||
'origin': order.name,
|
if picking_type:
|
||||||
'partner_id': addr.get('delivery',False),
|
picking_id = picking_obj.create(cr, uid, {
|
||||||
'picking_type_id': picking_type.id,
|
'origin': order.name,
|
||||||
'company_id': order.company_id.id,
|
'partner_id': addr.get('delivery',False),
|
||||||
'move_type': 'direct',
|
'picking_type_id': picking_type.id,
|
||||||
'note': order.note or "",
|
'company_id': order.company_id.id,
|
||||||
'invoice_state': 'none',
|
'move_type': 'direct',
|
||||||
}, context=context)
|
'note': order.note or "",
|
||||||
self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
|
'invoice_state': 'none',
|
||||||
location_id = picking_type.default_location_src_id.id
|
}, context=context)
|
||||||
|
self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
|
||||||
|
location_id = order.location_id.id
|
||||||
if order.partner_id:
|
if order.partner_id:
|
||||||
destination_id = order.partner_id.property_stock_customer.id
|
destination_id = order.partner_id.property_stock_customer.id
|
||||||
else:
|
elif picking_type:
|
||||||
|
if not picking_type.default_location_dest_id:
|
||||||
|
raise osv.except_osv(_('Error!'), _('Missing source or destination location for picking type %s. Please configure those fields and try again.' % (picking_type.name,)))
|
||||||
destination_id = picking_type.default_location_dest_id.id
|
destination_id = picking_type.default_location_dest_id.id
|
||||||
if not location_id or not destination_id:
|
else:
|
||||||
raise osv.except_osv(_('Error!'), _('Missing source or destination location for picking type %s. Please configure those fields and try again.' % (picking_type.name,)))
|
destination_id = partner_obj.default_get(cr, uid, ['property_stock_customer'], context=context)['property_stock_customer']
|
||||||
|
|
||||||
|
move_list = []
|
||||||
for line in order.lines:
|
for line in order.lines:
|
||||||
if line.product_id and line.product_id.type == 'service':
|
if line.product_id and line.product_id.type == 'service':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
move_obj.create(cr, uid, {
|
move_list.append(move_obj.create(cr, uid, {
|
||||||
'name': line.name,
|
'name': line.name,
|
||||||
'product_uom': line.product_id.uom_id.id,
|
'product_uom': line.product_id.uom_id.id,
|
||||||
'product_uos': line.product_id.uom_id.id,
|
'product_uos': line.product_id.uom_id.id,
|
||||||
'picking_id': picking_id,
|
'picking_id': picking_id,
|
||||||
|
'picking_type_id': picking_type.id,
|
||||||
'product_id': line.product_id.id,
|
'product_id': line.product_id.id,
|
||||||
'product_uos_qty': abs(line.qty),
|
'product_uos_qty': abs(line.qty),
|
||||||
'product_uom_qty': abs(line.qty),
|
'product_uom_qty': abs(line.qty),
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'location_id': location_id if line.qty >= 0 else destination_id,
|
'location_id': location_id if line.qty >= 0 else destination_id,
|
||||||
'location_dest_id': destination_id if line.qty >= 0 else location_id,
|
'location_dest_id': destination_id if line.qty >= 0 else location_id,
|
||||||
}, context=context)
|
}, context=context))
|
||||||
picking_obj.action_confirm(cr, uid, [picking_id], context=context)
|
|
||||||
picking_obj.force_assign(cr, uid, [picking_id], context=context)
|
if picking_id:
|
||||||
picking_obj.action_done(cr, uid, [picking_id], context=context)
|
picking_obj.action_confirm(cr, uid, [picking_id], context=context)
|
||||||
|
picking_obj.force_assign(cr, uid, [picking_id], context=context)
|
||||||
|
picking_obj.action_done(cr, uid, [picking_id], context=context)
|
||||||
|
elif move_list:
|
||||||
|
move_obj.action_confirm(cr, uid, move_list, context=context)
|
||||||
|
move_obj.force_assign(cr, uid, move_list, context=context)
|
||||||
|
move_obj.action_done(cr, uid, move_list, context=context)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def cancel_order(self, cr, uid, ids, context=None):
|
def cancel_order(self, cr, uid, ids, context=None):
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
</record>
|
</record>
|
||||||
<record model="pos.config" id="pos_config_main">
|
<record model="pos.config" id="pos_config_main">
|
||||||
<field name="name">Main</field>
|
<field name="name">Main</field>
|
||||||
|
<field name="picking_type_id" ref="picking_type_posout"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- notify all employees of module installation -->
|
<!-- notify all employees of module installation -->
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
<page string="Extra Info">
|
<page string="Extra Info">
|
||||||
<group string="General Information">
|
<group string="General Information">
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
<field name="warehouse_id" widget="selection" groups="stock.group_locations"/>
|
<field name="location_id" widget="selection" groups="stock.group_locations"/>
|
||||||
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'point_of_sale.group_pos_user']}"/>
|
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'point_of_sale.group_pos_user']}"/>
|
||||||
<field name="pricelist_id" groups="product.group_sale_pricelist" domain="[('type','=','sale')]"/>
|
<field name="pricelist_id" groups="product.group_sale_pricelist" domain="[('type','=','sale')]"/>
|
||||||
<field name="picking_id" readonly="1"/>
|
<field name="picking_id" readonly="1"/>
|
||||||
|
@ -591,7 +591,9 @@
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
</h1>
|
</h1>
|
||||||
<group col="4">
|
<group col="4">
|
||||||
<field name="warehouse_id" widget="selection" groups="stock.group_locations" />
|
<field name="picking_type_id" widget="selection" groups="stock.group_locations"
|
||||||
|
on_change="onchange_picking_type_id(picking_type_id)"/>
|
||||||
|
<field name="stock_location_id" groups="stock.group_locations"/>
|
||||||
<field name="pricelist_id" groups="product.group_sale_pricelist"/>
|
<field name="pricelist_id" groups="product.group_sale_pricelist"/>
|
||||||
<field name="currency_id" invisible="1"/>
|
<field name="currency_id" invisible="1"/>
|
||||||
<field name="journal_id" widget="selection"/>
|
<field name="journal_id" widget="selection"/>
|
||||||
|
@ -639,7 +641,7 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Point of Sale Configuration" colors="grey:state == 'inactive'">
|
<tree string="Point of Sale Configuration" colors="grey:state == 'inactive'">
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="warehouse_id" groups="stock.group_locations"/>
|
<field name="stock_location_id" groups="stock.group_locations"/>
|
||||||
<field name="state" />
|
<field name="state" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
@ -653,7 +655,7 @@
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<filter string="Active" domain="[('state', '=', 'active')]" />
|
<filter string="Active" domain="[('state', '=', 'active')]" />
|
||||||
<filter string="Inactive" domain="[('state', '=', 'inactive')]" />
|
<filter string="Inactive" domain="[('state', '=', 'inactive')]" />
|
||||||
<field name="warehouse_id" groups="stock.group_locations" />
|
<field name="stock_location_id" groups="stock.group_locations" />
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -36,7 +36,7 @@ class pos_order_report(osv.osv):
|
||||||
'price_total':fields.float('Total Price', readonly=True),
|
'price_total':fields.float('Total Price', readonly=True),
|
||||||
'total_discount':fields.float('Total Discount', readonly=True),
|
'total_discount':fields.float('Total Discount', readonly=True),
|
||||||
'average_price': fields.float('Average Price', readonly=True,group_operator="avg"),
|
'average_price': fields.float('Average Price', readonly=True,group_operator="avg"),
|
||||||
'warehouse_id':fields.many2one('stock.warehouse', 'Warehouse', readonly=True),
|
'location_id':fields.many2one('stock.location', 'Location', readonly=True),
|
||||||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
||||||
'nbr':fields.integer('# of Lines', readonly=True),
|
'nbr':fields.integer('# of Lines', readonly=True),
|
||||||
'product_qty':fields.integer('# of Qty', readonly=True),
|
'product_qty':fields.integer('# of Qty', readonly=True),
|
||||||
|
@ -61,7 +61,7 @@ class pos_order_report(osv.osv):
|
||||||
s.partner_id as partner_id,
|
s.partner_id as partner_id,
|
||||||
s.state as state,
|
s.state as state,
|
||||||
s.user_id as user_id,
|
s.user_id as user_id,
|
||||||
s.warehouse_id as warehouse_id,
|
s.location_id as location_id,
|
||||||
s.company_id as company_id,
|
s.company_id as company_id,
|
||||||
s.sale_journal as journal_id,
|
s.sale_journal as journal_id,
|
||||||
l.product_id as product_id
|
l.product_id as product_id
|
||||||
|
@ -71,7 +71,7 @@ class pos_order_report(osv.osv):
|
||||||
left join product_uom u on (u.id=pt.uom_id)
|
left join product_uom u on (u.id=pt.uom_id)
|
||||||
group by
|
group by
|
||||||
s.date_order, s.partner_id,s.state,
|
s.date_order, s.partner_id,s.state,
|
||||||
s.user_id,s.warehouse_id,s.company_id,s.sale_journal,l.product_id,s.create_date
|
s.user_id,s.location_id,s.company_id,s.sale_journal,l.product_id,s.create_date
|
||||||
having
|
having
|
||||||
sum(l.qty * u.factor) != 0)""")
|
sum(l.qty * u.factor) != 0)""")
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
<filter string="Salesperson" icon="terp-personal" name="User" context="{'group_by':'user_id'}"/>
|
<filter string="Salesperson" icon="terp-personal" name="User" context="{'group_by':'user_id'}"/>
|
||||||
<filter string="Customer" icon="terp-personal" context="{'group_by':'partner_id'}"/>
|
<filter string="Customer" icon="terp-personal" context="{'group_by':'partner_id'}"/>
|
||||||
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
|
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
|
||||||
|
<filter string="Stock Location" context="{'group_by': 'location_id'}"/>
|
||||||
<filter string="Order Date (day)" icon="terp-go-today" context="{'group_by':'date:day'}" help="Day of order date"/>
|
<filter string="Order Date (day)" icon="terp-go-today" context="{'group_by':'date:day'}" help="Day of order date"/>
|
||||||
<filter string="Order Date (month)" icon="terp-go-month" context="{'group_by':'date:month'}" help="Month of order date"/>
|
<filter string="Order Date (month)" icon="terp-go-month" context="{'group_by':'date:month'}" help="Month of order date"/>
|
||||||
<filter string="Order Date (year)" icon="terp-go-year" context="{'group_by':'date:year'}" help="Year of order date"/>
|
<filter string="Order Date (year)" icon="terp-go-year" context="{'group_by':'date:year'}" help="Year of order date"/>
|
||||||
|
|
|
@ -34,7 +34,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
this.company_logo = null;
|
this.company_logo = null;
|
||||||
this.company_logo_base64 = '';
|
this.company_logo_base64 = '';
|
||||||
this.currency = null;
|
this.currency = null;
|
||||||
this.shop = null;
|
|
||||||
this.company = null;
|
this.company = null;
|
||||||
this.user = null;
|
this.user = null;
|
||||||
this.users = [];
|
this.users = [];
|
||||||
|
@ -174,7 +173,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
|
|
||||||
return self.fetch(
|
return self.fetch(
|
||||||
'pos.config',
|
'pos.config',
|
||||||
['name','journal_ids','warehouse_id','journal_id','pricelist_id',
|
['name','journal_ids','journal_id','pricelist_id',
|
||||||
'iface_self_checkout', 'iface_led', 'iface_cashdrawer',
|
'iface_self_checkout', 'iface_led', 'iface_cashdrawer',
|
||||||
'iface_payment_terminal', 'iface_electronic_scale', 'iface_barscan',
|
'iface_payment_terminal', 'iface_electronic_scale', 'iface_barscan',
|
||||||
'iface_vkeyboard','iface_print_via_proxy','iface_scan_via_proxy',
|
'iface_vkeyboard','iface_print_via_proxy','iface_scan_via_proxy',
|
||||||
|
@ -191,10 +190,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
self.config.iface_scan_via_proxy ||
|
self.config.iface_scan_via_proxy ||
|
||||||
self.config.iface_cashdrawer;
|
self.config.iface_cashdrawer;
|
||||||
|
|
||||||
return self.fetch('stock.warehouse',[],[['id','=', self.config.warehouse_id[0]]]);
|
|
||||||
}).then(function(shops){
|
|
||||||
self.shop = shops[0];
|
|
||||||
|
|
||||||
return self.fetch('product.pricelist',['currency_id'],[['id','=',self.config.pricelist_id[0]]]);
|
return self.fetch('product.pricelist',['currency_id'],[['id','=',self.config.pricelist_id[0]]]);
|
||||||
}).then(function(pricelists){
|
}).then(function(pricelists){
|
||||||
self.pricelist = pricelists[0];
|
self.pricelist = pricelists[0];
|
||||||
|
@ -954,7 +949,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
var client = this.get('client');
|
var client = this.get('client');
|
||||||
var cashier = this.pos.cashier || this.pos.user;
|
var cashier = this.pos.cashier || this.pos.user;
|
||||||
var company = this.pos.company;
|
var company = this.pos.company;
|
||||||
var shop = this.pos.shop;
|
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -999,9 +993,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
phone: company.phone,
|
phone: company.phone,
|
||||||
logo: this.pos.company_logo_base64,
|
logo: this.pos.company_logo_base64,
|
||||||
},
|
},
|
||||||
shop:{
|
|
||||||
name: shop.name,
|
|
||||||
},
|
|
||||||
currency: this.pos.currency,
|
currency: this.pos.currency,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -781,7 +781,6 @@
|
||||||
<t t-esc="widget.pos.company.name"/><br />
|
<t t-esc="widget.pos.company.name"/><br />
|
||||||
Phone: <t t-esc="widget.pos.company.phone || ''"/><br />
|
Phone: <t t-esc="widget.pos.company.phone || ''"/><br />
|
||||||
User: <t t-esc="widget.pos.user.name"/><br />
|
User: <t t-esc="widget.pos.user.name"/><br />
|
||||||
Shop: <t t-esc="widget.pos.shop.name"/><br />
|
|
||||||
<br />
|
<br />
|
||||||
<t t-if="widget.pos.config.receipt_header">
|
<t t-if="widget.pos.config.receipt_header">
|
||||||
<div style='text-align:center'>
|
<div style='text-align:center'>
|
||||||
|
|
|
@ -91,85 +91,6 @@ class pos_return(osv.osv_memory):
|
||||||
'context': context,
|
'context': context,
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
}
|
}
|
||||||
def create_returns2(self, cr, uid, ids, context=None):
|
|
||||||
|
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
active_id = context.get('active_id', False)
|
|
||||||
order_obj =self.pool.get('pos.order')
|
|
||||||
line_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")
|
|
||||||
uom_obj =self. pool.get('product.uom')
|
|
||||||
statementl_obj = self.pool.get('account.bank.statement.line')
|
|
||||||
#Todo :Need to clean the code
|
|
||||||
if active_id:
|
|
||||||
data = self.browse(cr, uid, ids, context=context)[0]
|
|
||||||
date_cur = time.strftime('%Y-%m-%d %H:%M:%S')
|
|
||||||
|
|
||||||
for order_id in order_obj.browse(cr, uid, [active_id], context=context):
|
|
||||||
source_stock_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
|
|
||||||
new_picking = picking_obj.copy(cr, uid, order_id.picking_id.id, {'name':'%s (return)' % order_id.name,
|
|
||||||
'move_lines': [],
|
|
||||||
'state':'draft',
|
|
||||||
'type': 'in',
|
|
||||||
'partner_id': order_id.partner_id.id,
|
|
||||||
'date': date_cur })
|
|
||||||
new_order = order_obj.copy(cr, uid, order_id.id, {'name': 'Refund %s'%order_id.name,
|
|
||||||
'lines':[],
|
|
||||||
'statement_ids':[],
|
|
||||||
'picking_id':[]})
|
|
||||||
account_def = property_obj.get(cr, uid, 'property_account_payable', 'res.partner', context=context)
|
|
||||||
amount = 0.0
|
|
||||||
for line in order_id.lines:
|
|
||||||
for record in data.pos_moves_ids:
|
|
||||||
if line.id == record.line_id:
|
|
||||||
qty = record.quantity
|
|
||||||
amount += qty * line.price_unit
|
|
||||||
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': source_stock_id,
|
|
||||||
'product_id': line.product_id.id,
|
|
||||||
'location_dest_id': location_id,
|
|
||||||
'name': '%s (return)' %order_id.name,
|
|
||||||
'date': date_cur
|
|
||||||
})
|
|
||||||
if qty != 0.0:
|
|
||||||
line_obj.copy(cr, uid, line.id, {'qty': -qty, 'order_id': new_order})
|
|
||||||
statementl_obj.create(cr, uid, {
|
|
||||||
'name': 'Refund %s'%order_id.name,
|
|
||||||
'statement_id': order_id.statement_ids[0].statement_id.id,
|
|
||||||
'pos_statement_id': new_order,
|
|
||||||
'date': fields.date.context_today(self, cr, uid, context=context),
|
|
||||||
'account_id': order_id.partner_id and order_id.partner_id.property_account_payable \
|
|
||||||
and order_id.partner_id.property_account_payable.id or account_def.id,
|
|
||||||
'amount': -amount,
|
|
||||||
})
|
|
||||||
order_obj.write(cr,uid, [active_id,new_order], {'state': 'done'})
|
|
||||||
picking_obj.signal_button_confirm(cr, uid, [new_picking])
|
|
||||||
picking_obj.force_assign(cr, uid, [new_picking], context)
|
|
||||||
act = {
|
|
||||||
'domain': "[('id', 'in', ["+str(new_order)+"])]",
|
|
||||||
'name': 'Refunded Orders',
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'tree,form',
|
|
||||||
'res_model': 'pos.order',
|
|
||||||
'auto_refresh':0,
|
|
||||||
'res_id':new_order,
|
|
||||||
'view_id': False,
|
|
||||||
'context':context,
|
|
||||||
'type': 'ir.actions.act_window'
|
|
||||||
}
|
|
||||||
return act
|
|
||||||
|
|
||||||
|
|
||||||
class add_product(osv.osv_memory):
|
class add_product(osv.osv_memory):
|
||||||
|
|
Loading…
Reference in New Issue