[IMP] Put company_id on pos config + remove pos config name
bzr revid: jco@openerp.com-20140324120747-v3mt7pwgqylekshg
This commit is contained in:
parent
3631cc0df6
commit
d4eda78813
|
@ -198,8 +198,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']):
|
||||||
|
|
|
@ -64,7 +64,7 @@ class pos_config(osv.osv):
|
||||||
# 'warehouse_id' : fields.many2one('stock.warehouse', 'Warehouse',
|
# 'warehouse_id' : fields.many2one('stock.warehouse', 'Warehouse',
|
||||||
# required=True),
|
# required=True),
|
||||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
|
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
|
||||||
'stock_location_id': fields.many2one('stock.location', 'Stock Location to take from', required=True),
|
'stock_location_id': fields.many2one('stock.location', 'Stock Location to take from', 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."),
|
||||||
|
@ -90,6 +90,7 @@ class pos_config(osv.osv):
|
||||||
'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):
|
||||||
|
@ -137,12 +138,18 @@ class pos_config(osv.osv):
|
||||||
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_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],
|
||||||
'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,
|
||||||
|
'company_id': _get_default_company,
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_active(self, cr, uid, ids, context=None):
|
def set_active(self, cr, uid, ids, context=None):
|
||||||
|
@ -330,7 +337,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:
|
||||||
|
@ -357,7 +364,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)
|
||||||
|
@ -631,7 +638,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'),
|
||||||
|
@ -661,8 +667,8 @@ class pos_order(osv.osv):
|
||||||
'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.many2one('stock.picking.type', 'Picking Type', required=True),
|
||||||
'picking_type_id': fields.related('session_id', 'config_id', 'picking_type_id', type='many2one', relation='stock.picking.type'),
|
'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', type='many2one', relation='stock.location'),
|
'location_id': fields.related('session_id', 'config_id', 'stock_location_id', string="Location", type='many2one', 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),
|
||||||
|
@ -726,43 +732,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):
|
||||||
|
|
|
@ -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];
|
||||||
|
@ -949,7 +944,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 {
|
||||||
|
@ -993,9 +987,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,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -632,7 +632,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