[IMP]remove sale.shop from pos and improve code
bzr revid: sgo@tinyerp.com-20130123113306-n7enol5as84sv0g2
This commit is contained in:
parent
5600ce8a34
commit
e4250d1558
|
@ -51,7 +51,7 @@ class pos_config(osv.osv):
|
|||
'journal_ids' : fields.many2many('account.journal', 'pos_config_journal_rel',
|
||||
'pos_config_id', 'journal_id', 'Available Payment Methods',
|
||||
domain="[('journal_user', '=', True )]",),
|
||||
'shop_id' : fields.many2one('sale.shop', 'Shop',
|
||||
'warehouse_id' : fields.many2one('stock.warehouse', 'Location',
|
||||
required=True),
|
||||
'journal_id' : fields.many2one('account.journal', 'Sale Journal',
|
||||
domain=[('type', '=', 'sale')],
|
||||
|
@ -112,13 +112,13 @@ class pos_config(osv.osv):
|
|||
res = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale')], limit=1)
|
||||
return res and res[0] or False
|
||||
|
||||
def _default_shop(self, cr, uid, context=None):
|
||||
res = self.pool.get('sale.shop').search(cr, uid, [])
|
||||
def _default_warehouse(self, cr, uid, context=None):
|
||||
res = self.pool.get('stock.warehouse').search(cr, uid, [])
|
||||
return res and res[0] or False
|
||||
|
||||
_defaults = {
|
||||
'state' : POS_CONFIG_STATE[0][0],
|
||||
'shop_id': _default_shop,
|
||||
'warehouse_id': _default_warehouse,
|
||||
'journal_id': _default_sale_journal,
|
||||
'group_by' : True,
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class pos_session(osv.osv):
|
|||
# the .xml files as the CoA is not yet installed.
|
||||
jobj = self.pool.get('pos.config')
|
||||
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
||||
context.update({'company_id': pos_config.shop_id.company_id.id})
|
||||
context.update({'company_id': pos_config.warehouse_id.company_id.id})
|
||||
if not pos_config.journal_id:
|
||||
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
||||
if jid:
|
||||
|
@ -333,7 +333,7 @@ class pos_session(osv.osv):
|
|||
bank_values = {
|
||||
'journal_id' : journal.id,
|
||||
'user_id' : uid,
|
||||
'company_id' : pos_config.shop_id.company_id.id
|
||||
'company_id' : pos_config.warehouse_id.company_id.id
|
||||
}
|
||||
statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_values, context=context)
|
||||
bank_statement_ids.append(statement_id)
|
||||
|
@ -575,7 +575,7 @@ class pos_order(osv.osv):
|
|||
_columns = {
|
||||
'name': fields.char('Order Ref', size=64, required=True, readonly=True),
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True, readonly=True),
|
||||
'shop_id': fields.related('session_id', 'config_id', 'shop_id', relation='sale.shop', type='many2one', string='Shop', store=True, readonly=True),
|
||||
'warehouse_id': fields.related('session_id', 'config_id', 'warehouse_id', relation='stock.warehouse', type='many2one', string='Location', store=True, readonly=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."),
|
||||
'amount_tax': fields.function(_amount_all, string='Taxes', digits_compute=dp.get_precision('Point Of Sale'), multi='all'),
|
||||
|
@ -619,8 +619,7 @@ class pos_order(osv.osv):
|
|||
session_ids = self._default_session(cr, uid, context)
|
||||
if session_ids:
|
||||
session_record = self.pool.get('pos.session').browse(cr, uid, session_ids, context=context)
|
||||
shop = self.pool.get('sale.shop').browse(cr, uid, session_record.config_id.shop_id.id, context=context)
|
||||
return shop.pricelist_id and shop.pricelist_id.id or False
|
||||
return session_record.user_id.partner_id.property_product_pricelist and session_record.user_id.partner_id.property_product_pricelist.id or False
|
||||
return False
|
||||
|
||||
_defaults = {
|
||||
|
@ -671,8 +670,8 @@ class pos_order(osv.osv):
|
|||
'auto_picking': True,
|
||||
}, context=context)
|
||||
self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
|
||||
location_id = order.shop_id.warehouse_id.lot_stock_id.id
|
||||
output_id = order.shop_id.warehouse_id.lot_output_id.id
|
||||
location_id = order.warehouse_id.lot_stock_id.id
|
||||
output_id = order.warehouse_id.lot_output_id.id
|
||||
|
||||
for line in order.lines:
|
||||
if line.product_id and line.product_id.type == 'service':
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<page string="Extra Info">
|
||||
<group string="General Information">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="shop_id" widget="selection"/>
|
||||
<field name="warehouse_id" widget="selection"/>
|
||||
<field name="user_id"/>
|
||||
<field name="pricelist_id" groups="product.group_sale_pricelist" domain="[('type','=','sale')]"/>
|
||||
<field name="picking_id" readonly="1"/>
|
||||
|
@ -771,7 +771,7 @@
|
|||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="shop_id" widget="selection" groups="stock.group_locations" />
|
||||
<field name="warehouse_id" widget="selection" groups="stock.group_locations" />
|
||||
<field name="journal_id" widget="selection" />
|
||||
<field name="sequence_id" readonly="1" groups="base.group_no_one" />
|
||||
<field name="group_by" groups="account.group_account_user" />
|
||||
|
@ -809,7 +809,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<tree string="Point of Sale Configuration" colors="grey:state == 'inactive'">
|
||||
<field name="name" />
|
||||
<field name="shop_id" />
|
||||
<field name="warehouse_id" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -823,7 +823,7 @@
|
|||
<field name="name" />
|
||||
<filter string="Active" domain="[('state', '=', 'active')]" />
|
||||
<filter string="Inactive" domain="[('state', '=', 'inactive')]" />
|
||||
<field name="shop_id" />
|
||||
<field name="warehouse_id" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -41,7 +41,7 @@ class pos_order_report(osv.osv):
|
|||
'price_total':fields.float('Total Price', readonly=True),
|
||||
'total_discount':fields.float('Total Discount', readonly=True),
|
||||
'average_price': fields.float('Average Price', readonly=True,group_operator="avg"),
|
||||
'shop_id':fields.many2one('sale.shop', 'Shop', readonly=True),
|
||||
'warehouse_id':fields.many2one('stock.warehouse', 'Location', readonly=True),
|
||||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
||||
'nbr':fields.integer('# of Lines', readonly=True),
|
||||
'product_qty':fields.integer('# of Qty', readonly=True),
|
||||
|
@ -69,7 +69,7 @@ class pos_order_report(osv.osv):
|
|||
s.partner_id as partner_id,
|
||||
s.state as state,
|
||||
s.user_id as user_id,
|
||||
s.shop_id as shop_id,
|
||||
s.warehouse_id as warehouse_id,
|
||||
s.company_id as company_id,
|
||||
s.sale_journal as journal_id,
|
||||
l.product_id as product_id
|
||||
|
@ -80,7 +80,7 @@ class pos_order_report(osv.osv):
|
|||
group by
|
||||
to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'),
|
||||
to_char(s.date_order, 'YYYY-MM-DD'), s.partner_id,s.state,
|
||||
s.user_id,s.shop_id,s.company_id,s.sale_journal,l.product_id,s.create_date
|
||||
s.user_id,s.warehouse_id,s.company_id,s.sale_journal,l.product_id,s.create_date
|
||||
having
|
||||
sum(l.qty * u.factor) != 0)""")
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<field name="month" invisible="1"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="shop_id" invisible="1"/>
|
||||
<field name="warehouse_id" invisible="1"/>
|
||||
<!--<field name="journal_id" invisible="1"/>-->
|
||||
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
|
||||
<field name="nbr" sum="# of Lines"/>
|
||||
|
|
|
@ -8,7 +8,7 @@ access_account_journal_pos_user,account.journal pos_user,account.model_account_j
|
|||
access_account_move_pos_user,account.move pos_user,account.model_account_move,group_pos_user,1,1,1,0
|
||||
access_account_account_pos_user,account.account pos_user,account.model_account_account,group_pos_user,1,0,0,0
|
||||
access_stock_picking_pos_user,stock.picking pos_user,stock.model_stock_picking,group_pos_user,1,1,1,1
|
||||
access_sale_shop_pos_user,sale.shop pos_user,sale.model_sale_shop,group_pos_user,1,0,0,0
|
||||
access_stock_warehouse_pos_user,stock.warehouse pos_user,stock.model_stock_warehouse,group_pos_user,1,0,0,0
|
||||
access_pos_order_stock_worker,pos.order stock_worker,model_pos_order,stock.group_stock_user,1,0,0,0
|
||||
access_stock_move_pos_user,stock.move pos_user,stock.model_stock_move,group_pos_user,1,1,1,1
|
||||
access_report_sales_by_user_pos,report.sales.by.user.pos,model_report_sales_by_user_pos,group_pos_user,1,0,0,0
|
||||
|
|
|
|
@ -140,7 +140,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
|
||||
return self.fetch(
|
||||
'pos.config',
|
||||
['name','journal_ids','shop_id','journal_id',
|
||||
['name','journal_ids','warehouse_id','journal_id',
|
||||
'iface_self_checkout', 'iface_led', 'iface_cashdrawer',
|
||||
'iface_payment_terminal', 'iface_electronic_scale', 'iface_barscan', 'iface_vkeyboard',
|
||||
'iface_print_via_proxy','iface_cashdrawer','state','sequence_id','session_ids'],
|
||||
|
@ -155,7 +155,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
self.iface_self_checkout = !!pos_config.iface_self_checkout;
|
||||
self.iface_cashdrawer = !!pos_config.iface_cashdrawer;
|
||||
|
||||
return self.fetch('sale.shop',[],[['id','=',pos_config.shop_id[0]]]);
|
||||
return self.fetch('stock.warehouse',[],[['id','=',pos_config.warehouse_id[0]]]);
|
||||
}).then(function(shops){
|
||||
self.set('shop',shops[0]);
|
||||
|
||||
|
@ -166,13 +166,16 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
return self.fetch('pos.category', ['id','name','parent_id','child_id','image'])
|
||||
}).then(function(categories){
|
||||
self.db.add_categories(categories);
|
||||
|
||||
return self.fetch('res.users',['partner_id'],[['id','=',self.session.uid]])
|
||||
}).then(function(user){
|
||||
return self.fetch('res.partner',['property_product_pricelist'],[['id','=',user[0].partner_id[0]]])
|
||||
}).then(function(pricelist){
|
||||
return self.fetch(
|
||||
'product.product',
|
||||
['name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13',
|
||||
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description'],
|
||||
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description','pricelist_id'],
|
||||
[['sale_ok','=',true],['available_in_pos','=',true]],
|
||||
{pricelist: self.get('shop').pricelist_id[0]} // context for price
|
||||
{pricelist: pricelist[0].property_product_pricelist[0]} // context for price
|
||||
);
|
||||
}).then(function(products){
|
||||
self.db.add_products(products);
|
||||
|
|
|
@ -114,7 +114,7 @@ class pos_return(osv.osv_memory):
|
|||
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.shop_id.warehouse_id.id,))
|
||||
(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,
|
||||
|
@ -209,7 +209,7 @@ class add_product(osv.osv_memory):
|
|||
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.shop_id.warehouse_id.id,))
|
||||
(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)
|
||||
|
@ -273,7 +273,7 @@ class add_product(osv.osv_memory):
|
|||
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.shop_id.warehouse_id.id,))
|
||||
(order_id.warehouse_id.id,))
|
||||
res=cr.fetchone()
|
||||
location_id=res and res[0] or None
|
||||
|
||||
|
|
Loading…
Reference in New Issue