diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-06-14 16:58:48 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-06-14 16:58:48 +0200 |
| commit | ffeaa460ca6a3ca82fc73a0344a334ce271d18fd (patch) | |
| tree | 1bcdd61ad6649562d1c0f3c78c385b878fce655f | |
| parent | 24a411d9eb95eaeefcc79bb83985fde7e205d049 (diff) | |
| parent | e738adfafe01a579ebc3359de860a07381fde0d8 (diff) | |
[MERGE] sale, point_of_sale, sale_stock: remove the concept of sale.shop
and replace it by stock.warehouse
Also include several fixes and improvements in sale/point of sale.
bzr revid: tde@openerp.com-20130614145848-6zmjkxz0zkqs9jxb
36 files changed, 116 insertions, 283 deletions
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 089c577e940..370aa2e55ff 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -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 ), ('type', 'in', ['bank', 'cash'])]",), - 'shop_id' : fields.many2one('sale.shop', 'Shop', + 'warehouse_id' : fields.many2one('stock.warehouse', 'Warehouse', required=True), 'journal_id' : fields.many2one('account.journal', 'Sale Journal', domain=[('type', '=', 'sale')], @@ -70,6 +70,7 @@ class pos_config(osv.osv): "to customize the reference numbers of your orders."), '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"), + 'pricelist_id': fields.many2one('product.pricelist','Pricelist', required=True) } def _check_cash_control(self, cr, uid, ids, context=None): @@ -112,15 +113,21 @@ 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): + 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): + res = self.pool.get('product.pricelist').search(cr, uid, [('type', '=', 'sale')], limit=1, context=context) 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, + 'pricelist_id': _default_pricelist } def set_active(self, cr, uid, ids, context=None): @@ -306,7 +313,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 +340,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) @@ -594,7 +601,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='Warehouse', 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'), @@ -638,8 +645,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.config_id.pricelist_id and session_record.config_id.pricelist_id.id or False return False _defaults = { @@ -690,8 +696,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': diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index 8a53015b7d7..dbd5e731db1 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -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" groups="stock.group_locations"/> <field name="user_id"/> <field name="pricelist_id" groups="product.group_sale_pricelist" domain="[('type','=','sale')]"/> <field name="picking_id" readonly="1"/> @@ -769,12 +769,16 @@ </header> <sheet> - <group> - <field name="name"/> - <field name="shop_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" /> + <label for="name" class="oe_edit_only"/> + <h1> + <field name="name"/> + </h1> + <group col="4"> + <field name="warehouse_id" widget="selection" groups="stock.group_locations" /> + <field name="pricelist_id" groups="product.group_sale_pricelist"/> + <field name="journal_id" widget="selection"/> + <field name="group_by" groups="account.group_account_user"/> + <field name="sequence_id" readonly="1" groups="base.group_no_one"/> </group> <separator string="Available Payment Methods" colspan="4"/> <field name="journal_ids" colspan="4" nolabel="1"> @@ -809,7 +813,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" groups="stock.group_locations"/> <field name="state" /> </tree> </field> @@ -823,7 +827,7 @@ <field name="name" /> <filter string="Active" domain="[('state', '=', 'active')]" /> <filter string="Inactive" domain="[('state', '=', 'inactive')]" /> - <field name="shop_id" /> + <field name="warehouse_id" groups="stock.group_locations" /> </search> </field> </record> diff --git a/addons/point_of_sale/report/pos_order_report.py b/addons/point_of_sale/report/pos_order_report.py index f4df5f0f5f6..f3ee5e317c8 100644 --- a/addons/point_of_sale/report/pos_order_report.py +++ b/addons/point_of_sale/report/pos_order_report.py @@ -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', 'Warehouse', 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)""") diff --git a/addons/point_of_sale/report/pos_order_report_view.xml b/addons/point_of_sale/report/pos_order_report_view.xml index 8d7bf84171a..135b6dcadaa 100644 --- a/addons/point_of_sale/report/pos_order_report_view.xml +++ b/addons/point_of_sale/report/pos_order_report_view.xml @@ -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"/> diff --git a/addons/point_of_sale/report/pos_receipt.rml b/addons/point_of_sale/report/pos_receipt.rml index 0802114bb48..02b8a5b1a1a 100644 --- a/addons/point_of_sale/report/pos_receipt.rml +++ b/addons/point_of_sale/report/pos_receipt.rml @@ -75,7 +75,7 @@ <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">User : [[ o.user_id.name ]]</para> - <para style="terp_default_Centre_9">Shop : [[ o.shop_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="P4"> <font color="white"> </font> diff --git a/addons/point_of_sale/security/ir.model.access.csv b/addons/point_of_sale/security/ir.model.access.csv index 1d2c22053fb..b278c48e1f2 100644 --- a/addons/point_of_sale/security/ir.model.access.csv +++ b/addons/point_of_sale/security/ir.model.access.csv @@ -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
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 13003bcf19f..8cb88303dd1 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -142,7 +142,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','pricelist_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'], @@ -157,7 +157,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]); @@ -174,7 +174,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal ['name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13', 'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description'], [['sale_ok','=',true],['available_in_pos','=',true]], - {pricelist: self.get('shop').pricelist_id[0]} // context for price + {pricelist: self.get('pos_config').pricelist_id[0]} // context for price ); }).then(function(products){ self.db.add_products(products); diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index f0624948ed5..92bb6721f08 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -112,7 +112,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, @@ -205,7 +205,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) @@ -268,7 +268,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 diff --git a/addons/portal_sale/security/ir.model.access.csv b/addons/portal_sale/security/ir.model.access.csv index c73be67e8c9..37e27c54d36 100644 --- a/addons/portal_sale/security/ir.model.access.csv +++ b/addons/portal_sale/security/ir.model.access.csv @@ -11,7 +11,6 @@ access_account_move,account.move,account.model_account_move,portal.group_portal, access_account_move_line,account.move.line,account.model_account_move_line,portal.group_portal,1,0,0,0 access_account_move_reconcile,account.move.reconcile,account.model_account_move_reconcile,portal.group_portal,1,0,0,0 access_account_fiscalyear,account.sequence.fiscalyear,account.model_account_sequence_fiscalyear,portal.group_portal,1,0,0,0 -access_sale_shop,sale.shop,sale.model_sale_shop,portal.group_portal,1,0,0,0 access_product_list,product.pricelist,product.model_product_pricelist,portal.group_portal,1,0,0,0 access_res_partner,res.partner,base.model_res_partner,portal.group_portal,1,0,0,0 access_account_tax,account.tax,account.model_account_tax,portal.group_portal,1,0,0,0 diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index 80143379247..d5f07f863b9 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -40,7 +40,6 @@ class sale_report(osv.osv): 'product_uom_qty': fields.float('# of Qty', readonly=True), 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True), - 'shop_id': fields.many2one('sale.shop', 'Shop', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), 'user_id': fields.many2one('res.users', 'Salesperson', readonly=True), 'price_total': fields.float('Total Price', readonly=True), @@ -79,7 +78,6 @@ class sale_report(osv.osv): to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.user_id as user_id, - s.shop_id as shop_id, s.company_id as company_id, extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, @@ -103,7 +101,6 @@ class sale_report(osv.osv): s.date_confirm, s.partner_id, s.user_id, - s.shop_id, s.company_id, s.state, s.pricelist_id, diff --git a/addons/sale/report/sale_report_view.xml b/addons/sale/report/sale_report_view.xml index 8f725a9eacb..69e9cc5e119 100644 --- a/addons/sale/report/sale_report_view.xml +++ b/addons/sale/report/sale_report_view.xml @@ -13,7 +13,6 @@ <field name="year" invisible="1"/> <field name="day" invisible="1"/> <field name="month" invisible="1"/> - <field name="shop_id" invisible="1"/> <field name="company_id" invisible="1" groups="base.group_multi_company"/> <field name="partner_id" invisible="1"/> <field name="product_id" invisible="1"/> @@ -58,7 +57,6 @@ <field name="product_id"/> <field name="user_id"/> <group expand="0" string="Extended Filters..."> - <field name="shop_id"/> <field name="categ_id"/> <field name="company_id" groups="base.group_multi_company"/> </group> @@ -70,7 +68,6 @@ <filter string="Category of Product" icon="terp-stock_symbol-selection" name="Category" context="{'group_by':'categ_id'}"/> <filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'analytic_account_id'}" groups="analytic.group_analytic_accounting"/> <filter string="Status" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/> - <filter string="Shop" icon="terp-go-home" context="{'group_by':'shop_id'}"/> <filter string="Company" icon="terp-go-home" groups="base.group_multi_company" context="{'group_by':'company_id'}"/> <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Ordered date of the sales order"/> <filter string="Month" name="order_month" icon="terp-go-month" context="{'group_by':'month'}" help="Ordered month of the sales order"/> diff --git a/addons/sale/sale.py b/addons/sale/sale.py index d304c45b9e0..67c6f82ced3 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -28,21 +28,6 @@ from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FO import openerp.addons.decimal_precision as dp from openerp import netsvc -class sale_shop(osv.osv): - _name = "sale.shop" - _description = "Sales Shop" - _columns = { - 'name': fields.char('Shop Name', size=64, required=True), - 'payment_default_id': fields.many2one('account.payment.term', 'Default Payment Term', required=True), - 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'), - 'project_id': fields.many2one('account.analytic.account', 'Analytic Account', domain=[('parent_id', '!=', False)]), - 'company_id': fields.many2one('res.company', 'Company', required=False), - } - _defaults = { - 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'sale.shop', context=c), - } - - class sale_order(osv.osv): _name = "sale.order" _inherit = ['mail.thread', 'ir.needaction_mixin'] @@ -54,16 +39,6 @@ class sale_order(osv.osv): }, } - def onchange_shop_id(self, cr, uid, ids, shop_id, context=None): - v = {} - if shop_id: - shop = self.pool.get('sale.shop').browse(cr, uid, shop_id, context=context) - if shop.project_id.id: - v['project_id'] = shop.project_id.id - if shop.pricelist_id.id: - v['pricelist_id'] = shop.pricelist_id.id - return {'value': v} - def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} @@ -176,17 +151,15 @@ class sale_order(osv.osv): result[line.order_id.id] = True return result.keys() - def _get_default_shop(self, cr, uid, context=None): - company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id - shop_ids = self.pool.get('sale.shop').search(cr, uid, [('company_id','=',company_id)], context=context) - if not shop_ids: - raise osv.except_osv(_('Error!'), _('There is no default shop for the current user\'s company!')) - return shop_ids[0] + def _get_default_company(self, cr, uid, context=None): + company_id = self.pool.get('res.users')._get_company(cr, uid, context=context) + if not company_id: + raise osv.except_osv(_('Error!'), _('There is no default company for the current user!')) + return company_id _columns = { 'name': fields.char('Order Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True), - 'shop_id': fields.many2one('sale.shop', 'Shop', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}), 'origin': fields.char('Source Document', size=64, help="Reference of the document that generated this sales order request."), 'client_order_ref': fields.char('Customer Reference', size=64), 'state': fields.selection([ @@ -246,16 +219,16 @@ class sale_order(osv.osv): 'invoice_quantity': fields.selection([('order', 'Ordered Quantities')], 'Invoice on', help="The sales order will automatically create the invoice proposition (draft invoice).", required=True, readonly=True, states={'draft': [('readonly', False)]}), 'payment_term': fields.many2one('account.payment.term', 'Payment Term'), 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'), - 'company_id': fields.related('shop_id','company_id',type='many2one',relation='res.company',string='Company',store=True,readonly=True) + 'company_id': fields.many2one('res.company', 'Company'), } _defaults = { 'date_order': fields.date.context_today, 'order_policy': 'manual', + 'company_id': _get_default_company, 'state': 'draft', 'user_id': lambda obj, cr, uid, context: uid, 'name': lambda obj, cr, uid, context: '/', 'invoice_quantity': 'order', - 'shop_id': _get_default_shop, 'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'], 'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'], 'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index fc2287cadc0..443895631a9 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -19,20 +19,6 @@ <field name="object">sale.order</field> </record> - <!-- Resource: sale.shop --> - <record id="sale_shop_1" model="sale.shop"> - <field name="company_id" ref="base.main_company"/> - <field name="payment_default_id" ref="account.account_payment_term_net"/> - <field name="pricelist_id" ref="product.list0"/> - - <!-- Copy the name of any company. Without demo data this will yield - the main company name, which is correct. With demo data it will - be random, but it does not matter much --> - <field model="res.company" name="name" search="[]" use="name"/> - </record> - - <function eval="('default',False,'shop_id', [('sale.order', False)], sale_shop_1, True, False, False, False, True)" id="sale_default_set" model="ir.values" name="set"/> - <!-- notify all employees of module installation --> <record model="mail.message" id="module_install_notification"> <field name="model">mail.group</field> diff --git a/addons/sale/sale_demo.xml b/addons/sale/sale_demo.xml index eb937199aba..144ea49b75d 100644 --- a/addons/sale/sale_demo.xml +++ b/addons/sale/sale_demo.xml @@ -6,7 +6,6 @@ <field name="partner_id" ref="base.res_partner_2"/> <field name="partner_invoice_id" ref="base.res_partner_2"/> <field name="partner_shipping_id" ref="base.res_partner_2"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_demo"/> <field name="pricelist_id" ref="product.list0"/> </record> @@ -45,7 +44,6 @@ <field name="partner_id" ref="base.res_partner_7"/> <field name="partner_invoice_id" ref="base.res_partner_address_13"/> <field name="partner_shipping_id" ref="base.res_partner_address_13"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_root"/> <field name="pricelist_id" ref="product.list0"/> <field name="order_policy">manual</field> @@ -75,7 +73,6 @@ <field name="partner_id" ref="base.res_partner_14"/> <field name="partner_invoice_id" ref="base.res_partner_14"/> <field name="partner_shipping_id" ref="base.res_partner_14"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_root"/> <field name="pricelist_id" ref="product.list0"/> <field name="order_policy">manual</field> @@ -105,7 +102,6 @@ <field name="partner_id" ref="base.res_partner_15"/> <field name="partner_invoice_id" ref="base.res_partner_address_25"/> <field name="partner_shipping_id" ref="base.res_partner_address_25"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_root"/> <field name="pricelist_id" ref="product.list0"/> </record> @@ -154,7 +150,6 @@ <field name="partner_id" ref="base.res_partner_2"/> <field name="partner_invoice_id" ref="base.res_partner_2"/> <field name="partner_shipping_id" ref="base.res_partner_2"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_demo"/> <field name="pricelist_id" ref="product.list0"/> </record> @@ -193,7 +188,6 @@ <field name="partner_id" ref="base.res_partner_18"/> <field name="partner_invoice_id" ref="base.res_partner_18"/> <field name="partner_shipping_id" ref="base.res_partner_18"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_root"/> <field name="pricelist_id" ref="product.list0"/> </record> @@ -261,7 +255,6 @@ <field name="partner_id" ref="base.res_partner_15"/> <field name="partner_invoice_id" ref="base.res_partner_address_25"/> <field name="partner_shipping_id" ref="base.res_partner_address_25"/> - <field name="shop_id" ref="sale_shop_1"/> <field name="user_id" ref="base.user_demo"/> <field name="pricelist_id" ref="product.list0"/> <field name="order_policy">manual</field> diff --git a/addons/sale/sale_unit_test.xml b/addons/sale/sale_unit_test.xml index 18a59320d9c..8d7d54d9640 100644 --- a/addons/sale/sale_unit_test.xml +++ b/addons/sale/sale_unit_test.xml @@ -3,7 +3,6 @@ <data> <!-- Resource: sale.order --> <record id="test_order_1" model="sale.order"> - <field name="shop_id" ref="sale_shop_1"/> <field model="product.pricelist" name="pricelist_id" search="[]"/> <field name="user_id" ref="base.user_root"/> <field model="res.partner" name="partner_id" search="[]"/> diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index d8d038eb002..967350a88ac 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -13,59 +13,6 @@ <menuitem id="base.menu_product" name="Products" parent="base.menu_base_partner" sequence="9"/> - - <record id="view_shop_form" model="ir.ui.view"> - <field name="name">sale.shop</field> - <field name="model">sale.shop</field> - <field name="arch" type="xml"> - <form string="Sales Shop" version="7.0"> - <label for="name" class="oe_edit_only"/> - <h1><field name="name"/></h1> - <group name="shop"> - <group> - <field name="payment_default_id"/> - <field domain="[('type','=','sale')]" name="pricelist_id" groups="product.group_sale_pricelist"/> - </group> - <group> - <field name="project_id" groups="analytic.group_analytic_accounting"/> - <field name="company_id" widget="selection" groups="base.group_multi_company"/> - </group> - </group> - </form> - </field> - </record> - - <record id="view_shop_tree" model="ir.ui.view"> - <field name="name">sale.shop</field> - <field name="model">sale.shop</field> - <field name="arch" type="xml"> - <tree string="Sales Shop"> - <field name="name"/> - <field name="pricelist_id" groups="product.group_sale_pricelist"/> - <field name="project_id" groups="analytic.group_analytic_accounting"/> - </tree> - </field> - </record> - - <record id="action_shop_form" model="ir.actions.act_window"> - <field name="name">Shop</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">sale.shop</field> - <field name="view_type">form</field> - <field name="view_mode">tree,form</field> - <field name="view_id" ref="view_shop_tree"/> - <field name="help" type="html"> - <p class="oe_view_nocontent_create"> - Click to define a new sale shop. - </p><p> - Each quotation or sales order must be linked to a shop. The - shop also defines the warehouse from which the products will be - delivered for each particular sales. - </p> - </field> - </record> - - <record id="view_sale_order_calendar" model="ir.ui.view"> <field name="name">sale.order.calendar</field> <field name="model">sale.order</field> @@ -160,7 +107,6 @@ </group> <group> <field name="date_order"/> - <field name="shop_id" groups="base.group_no_one" on_change="onchange_shop_id(shop_id, context)" widget="selection"/> <field name="client_order_ref"/> <field domain="[('type','=','sale')]" name="pricelist_id" groups="product.group_sale_pricelist" on_change="onchange_pricelist_id(pricelist_id,order_line)"/> <field name="currency_id" invisible="1"/> @@ -178,13 +124,13 @@ <group> <field name="state" invisible="1" /> <field name="product_id" - context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" + context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" groups="base.group_user" on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/> <label for="product_uom_qty"/> <div> <field - context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" + context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" name="product_uom_qty" class="oe_inline" on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/> <field name="product_uom" groups="product.group_uom" class="oe_inline oe_no_button" @@ -222,12 +168,12 @@ <field name="state" invisible="1"/> <field name="th_weight" invisible="1"/> <field name="product_id" - context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" + context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" groups="base.group_user" on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/> <field name="name"/> <field name="product_uom_qty" - context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" + context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/> <field name="product_uom" on_change="product_uom_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, context)" diff --git a/addons/sale/security/ir.model.access.csv b/addons/sale/security/ir.model.access.csv index 670c863a022..5fea141bd2b 100644 --- a/addons/sale/security/ir.model.access.csv +++ b/addons/sale/security/ir.model.access.csv @@ -1,5 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sale_shop,sale.shop,model_sale_shop,base.group_user,1,0,0,0
access_sale_order,sale.order,model_sale_order,base.group_sale_salesman,1,1,1,0
access_sale_order_line,sale.order.line,model_sale_order_line,base.group_sale_salesman,1,1,1,1
access_sale_order_line_accountant,sale.order.line accountant,model_sale_order_line,account.group_account_user,1,1,0,0
@@ -19,7 +18,6 @@ access_res_partner_sale_user,res.partner.sale.user,base.model_res_partner,base.g access_res_partner_sale_manager,res.partner.sale.manager,base.model_res_partner,base.group_sale_manager,1,1,1,0
access_product_template_sale_user,product.template sale use,product.model_product_template,base.group_sale_salesman,1,0,0,0
access_product_product_sale_user,product.product sale use,product.model_product_product,base.group_sale_salesman,1,0,0,0
-access_sale_shop_manager,account.journal sale order.user,model_sale_shop,base.group_sale_manager,1,1,1,1
access_account_fiscalyear_user,account.fiscalyear.user,account.model_account_fiscalyear,base.group_sale_salesman,1,0,0,0
access_account_tax_user,account.tax.user,account.model_account_tax,base.group_sale_salesman,1,0,0,0
access_ir_attachment_sales,ir.attachment.sales,base.model_ir_attachment,base.group_sale_salesman,1,1,1,0
@@ -29,8 +27,6 @@ access_res_partner_bank_type_field_user,res.partner.bank.type.field.user,base.mo access_product_uom_user,product.uom.user,product.model_product_uom,base.group_sale_salesman,1,0,0,0
access_product_pricelist_sale_user,product.pricelist.sale.user,product.model_product_pricelist,base.group_sale_salesman,1,0,0,0
access_account_account_salesman,account_account salesman,account.model_account_account,base.group_sale_salesman,1,0,0,0
-access_sale_shop_sale_user,sale.shop.sale.user,model_sale_shop,base.group_sale_salesman,1,0,0,0
-access_sale_shop_sale_manager,sale.shop.sale.manager,model_sale_shop,base.group_sale_manager,1,1,1,1
access_product_uom_categ_sale_manager,product.uom.categ salemanager,product.model_product_uom_categ,base.group_sale_manager,1,1,1,1
access_product_uom_sale_manager,product.uom salemanager,product.model_product_uom,base.group_sale_manager,1,1,1,1
access_product_ul_sale_manager,product.ul salemanager,product.model_product_ul,base.group_sale_manager,1,1,1,1
diff --git a/addons/sale/security/sale_security.xml b/addons/sale/security/sale_security.xml index 49bd0e8716b..557562275d7 100644 --- a/addons/sale/security/sale_security.xml +++ b/addons/sale/security/sale_security.xml @@ -78,13 +78,6 @@ <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> </record> - <record model="ir.rule" id="sale_shop_comp_rule"> - <field name="name">Sale Shop multi-company</field> - <field name="model_id" ref="model_sale_shop"/> - <field name="global" eval="True"/> - <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> - </record> - <!-- Multi - Salesmen sales order assignation rules --> <record id="sale_order_personal_rule" model="ir.rule"> diff --git a/addons/sale_analytic_plans/sale_analytic_plans.py b/addons/sale_analytic_plans/sale_analytic_plans.py index 522f6b6f0fb..51262343d68 100644 --- a/addons/sale_analytic_plans/sale_analytic_plans.py +++ b/addons/sale_analytic_plans/sale_analytic_plans.py @@ -38,14 +38,4 @@ class sale_order_line(osv.osv): return create_ids -class sale_order(osv.osv): - _inherit = "sale.order" - - def onchange_shop_id(self, cr, uid, ids, shop_id, context=None): - # Remove the project_id from the result of super() call, if any, as this field is not in the view anymore - res = super(sale_order, self).onchange_shop_id(cr, uid, ids, shop_id, context=context) - if res.get('value',{}).get('project_id'): - del(res['value']['project_id']) - return res - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_crm/test/sale_crm.yml b/addons/sale_crm/test/sale_crm.yml index 011fb6ad5a8..21d2cc08195 100644 --- a/addons/sale_crm/test/sale_crm.yml +++ b/addons/sale_crm/test/sale_crm.yml @@ -1,15 +1,4 @@ - - Make sure the main company has at least one shop. -- - !python {model: sale.shop}: | - company_id = self.pool.get('res.users')._get_company(cr, uid, context=context) - shop_ids = self.search(cr, uid, [('company_id', '=', company_id)]) - if not shop_ids: - # take a shop, and assign it to the user's company - shop_ids = self.search(cr, uid, []) - if shop_ids: - self.write(cr, uid, [shop_ids[0]], {'company_id': company_id}) -- I open the wizard "Make sales". - !record {model: crm.make.sale, id: crm_make_sale_0}: diff --git a/addons/sale_crm/wizard/crm_make_sale.py b/addons/sale_crm/wizard/crm_make_sale.py index bd91e47b886..b74817059e4 100644 --- a/addons/sale_crm/wizard/crm_make_sale.py +++ b/addons/sale_crm/wizard/crm_make_sale.py @@ -95,7 +95,6 @@ class crm_make_sale(osv.osv_memory): 'origin': _('Opportunity: %s') % str(case.id), 'section_id': case.section_id and case.section_id.id or False, 'categ_ids': [(6, 0, [categ_id.id for categ_id in case.categ_ids])], - 'shop_id': make.shop_id.id, 'partner_id': partner.id, 'pricelist_id': pricelist, 'partner_invoice_id': partner_addr['invoice'], @@ -140,18 +139,12 @@ class crm_make_sale(osv.osv_memory): } return value - def _get_shop_id(self, cr, uid, ids, context=None): - cmpny_id = self.pool.get('res.users')._get_company(cr, uid, context=context) - shop = self.pool.get('sale.shop').search(cr, uid, [('company_id', '=', cmpny_id)]) - return shop and shop[0] or False _columns = { - 'shop_id': fields.many2one('sale.shop', 'Shop', required=True), 'partner_id': fields.many2one('res.partner', 'Customer', required=True, domain=[('customer','=',True)]), 'close': fields.boolean('Mark Won', help='Check this to close the opportunity after having created the sales order.'), } _defaults = { - 'shop_id': _get_shop_id, 'close': False, 'partner_id': _selectPartner, } diff --git a/addons/sale_crm/wizard/crm_make_sale_view.xml b/addons/sale_crm/wizard/crm_make_sale_view.xml index 2207cf536e2..695f3e919eb 100644 --- a/addons/sale_crm/wizard/crm_make_sale_view.xml +++ b/addons/sale_crm/wizard/crm_make_sale_view.xml @@ -10,7 +10,6 @@ <form string="Convert to Quotation" version="7.0"> <group col="4"> <field name="partner_id" required="1"/> - <field name="shop_id" required="1" widget="selection" groups="stock.group_locations"/> <field name="close"/> </group> <footer> diff --git a/addons/sale_margin/test/sale_margin.yml b/addons/sale_margin/test/sale_margin.yml index 1d6b295b3a1..197f51a9681 100644 --- a/addons/sale_margin/test/sale_margin.yml +++ b/addons/sale_margin/test/sale_margin.yml @@ -23,7 +23,6 @@ partner_invoice_id: base.res_partner_address_7 partner_shipping_id: base.res_partner_address_7 pricelist_id: product.list0 - shop_id: sale.sale_shop_1 - I confirm the sale order - diff --git a/addons/sale_mrp/test/sale_mrp.yml b/addons/sale_mrp/test/sale_mrp.yml index 5be5210b623..f0ec2de6efc 100644 --- a/addons/sale_mrp/test/sale_mrp.yml +++ b/addons/sale_mrp/test/sale_mrp.yml @@ -83,7 +83,6 @@ partner_shipping_id: base.res_partner_address_7 picking_policy: direct pricelist_id: product.list0 - shop_id: sale.sale_shop_1 - I confirm the sale order - diff --git a/addons/sale_stock/__openerp__.py b/addons/sale_stock/__openerp__.py index a849df295d4..fd20748aa75 100644 --- a/addons/sale_stock/__openerp__.py +++ b/addons/sale_stock/__openerp__.py @@ -57,7 +57,6 @@ You can choose flexible invoicing methods: 'report/sale_report_view.xml', 'process/sale_stock_process.xml', ], - 'data': ['sale_stock_data.xml'], 'demo_xml': ['sale_stock_demo.xml'], 'test': ['test/cancel_order_sale_stock.yml', 'test/picking_order_policy.yml', diff --git a/addons/sale_stock/report/sale_report.py b/addons/sale_stock/report/sale_report.py index 63641020d98..0feb3ee2392 100644 --- a/addons/sale_stock/report/sale_report.py +++ b/addons/sale_stock/report/sale_report.py @@ -27,6 +27,7 @@ class sale_report(osv.osv): _columns = { 'shipped': fields.boolean('Shipped', readonly=True), 'shipped_qty_1': fields.integer('Shipped', readonly=True), + 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse',readonly=True), 'state': fields.selection([ ('draft', 'Quotation'), ('waiting_date', 'Waiting Schedule'), @@ -57,8 +58,8 @@ class sale_report(osv.osv): to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.user_id as user_id, - s.shop_id as shop_id, s.company_id as company_id, + s.warehouse_id as warehouse_id, extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, t.categ_id as categ_id, @@ -83,7 +84,7 @@ class sale_report(osv.osv): s.date_confirm, s.partner_id, s.user_id, - s.shop_id, + s.warehouse_id, s.company_id, s.state, s.shipped, diff --git a/addons/sale_stock/report/sale_report_view.xml b/addons/sale_stock/report/sale_report_view.xml index ae8b12ca168..6642bffcede 100644 --- a/addons/sale_stock/report/sale_report_view.xml +++ b/addons/sale_stock/report/sale_report_view.xml @@ -7,9 +7,20 @@ <field name="inherit_id" ref="sale.view_order_product_tree"/> <field name="arch" type="xml"> <field name="product_uom_qty" position="after"> + <field name="warehouse_id" invisible="1"/> <field name="shipped_qty_1" sum="Shipped"/> </field> </field> </record> + <record id="view_order_product_search_sale_stock_inherit" model="ir.ui.view"> + <field name="name">sale.report.search.sale.stock</field> + <field name="model">sale.report</field> + <field name="inherit_id" ref="sale.view_order_product_search"/> + <field name="arch" type="xml"> + <xpath expr="//group/filter[@string='Status']" position="after"> + <filter string="Warehouse" context="{'group_by':'warehouse_id'}"/> + </xpath> + </field> + </record> </data> </openerp>
\ No newline at end of file diff --git a/addons/sale_stock/res_config.py b/addons/sale_stock/res_config.py index d06b6a81b32..4c3b92f1d33 100644 --- a/addons/sale_stock/res_config.py +++ b/addons/sale_stock/res_config.py @@ -50,9 +50,6 @@ class sale_configuration(osv.osv_memory): 'group_mrp_properties': fields.boolean('Product properties on order lines', implied_group='sale.group_mrp_properties', help="Allows you to tag sales order lines with properties."), - 'group_multiple_shops': fields.boolean("Manage multiple shops", - implied_group='stock.group_locations', - help="This allows to configure and use multiple shops."), 'module_project_timesheet': fields.boolean("Project Timesheet"), 'module_project_mrp': fields.boolean("Project MRP"), } diff --git a/addons/sale_stock/res_config_view.xml b/addons/sale_stock/res_config_view.xml index ad3b91b2a30..93bc8e5980e 100644 --- a/addons/sale_stock/res_config_view.xml +++ b/addons/sale_stock/res_config_view.xml @@ -59,12 +59,6 @@ <label for="group_mrp_properties"/> </div> </div> - <xpath expr="//div[@name='module_sale_margin']" position="before"> - <div> - <field name="group_multiple_shops" class="oe_inline"/> - <label for="group_multiple_shops"/> - </div> - </xpath> <field name="group_invoice_so_lines" position="replace"> <field name="group_invoice_so_lines" on_change="onchange_invoice_methods(group_invoice_so_lines, group_invoice_deli_orders)" class="oe_inline"/> </field> diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 92aa9d9aaf3..3f7ac28c900 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -27,13 +27,6 @@ from openerp.tools.translate import _ import pytz from openerp import SUPERUSER_ID -class sale_shop(osv.osv): - _inherit = "sale.shop" - _columns = { - 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'), - } - - class sale_order(osv.osv): _inherit = "sale.order" @@ -70,9 +63,16 @@ class sale_order(osv.osv): vals.update({'invoice_quantity': 'order'}) if vals['order_policy'] == 'picking': vals.update({'invoice_quantity': 'procurement'}) - order = super(sale_order, self).create(cr, uid, vals, context=context) + order = super(sale_order, self).create(cr, uid, vals, context=context) return order + def _get_default_warehouse(self, cr, uid, context=None): + company_id = self.pool.get('res.users')._get_company(cr, uid, context=context) + warehouse_ids = self.pool.get('stock.warehouse').search(cr, uid, [('company_id', '=', company_id)], context=context) + if not warehouse_ids: + raise osv.except_osv(_('Error!'), _('There is no warehouse defined for current company.')) + return warehouse_ids[0] + # This is False def _picked_rate(self, cr, uid, ids, name, arg, context=None): if not ids: @@ -140,11 +140,13 @@ class sale_order(osv.osv): 'picking_ids': fields.one2many('stock.picking.out', 'sale_id', 'Related Picking', readonly=True, help="This is a list of delivery orders that has been generated for this sales order."), 'shipped': fields.boolean('Delivered', readonly=True, help="It indicates that the sales order has been delivered. This field is updated only after the scheduler(s) have been launched."), 'picked_rate': fields.function(_picked_rate, string='Picked', type='float'), + 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True), 'invoice_quantity': fields.selection([('order', 'Ordered Quantities'), ('procurement', 'Shipped Quantities')], 'Invoice on', help="The sales order will automatically create the invoice proposition (draft invoice).\ You have to choose if you want your invoice based on ordered ", required=True, readonly=True, states={'draft': [('readonly', False)]}), } _defaults = { + 'warehouse_id': _get_default_warehouse, 'picking_policy': 'direct', 'order_policy': 'manual', 'invoice_quantity': 'order', @@ -162,6 +164,14 @@ class sale_order(osv.osv): return osv.osv.unlink(self, cr, uid, unlink_ids, context=context) + def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context=None): + val = {} + if warehouse_id: + warehouse = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context=context) + if warehouse.company_id: + val['company_id'] = warehouse.company_id.id + return {'value': val} + def action_view_delivery(self, cr, uid, ids, context=None): ''' This function returns an action that display existing delivery orders of given sales order ids. It can either be a in a list or in a form view, if there is only one delivery order to show. @@ -297,7 +307,7 @@ class sale_order(osv.osv): or line.product_uom_qty, 'product_uos': (line.product_uos and line.product_uos.id)\ or line.product_uom.id, - 'location_id': order.shop_id.warehouse_id.lot_stock_id.id, + 'location_id': order.warehouse_id.lot_stock_id.id, 'procure_method': line.type, 'move_id': move_id, 'company_id': order.company_id.id, @@ -305,8 +315,8 @@ class sale_order(osv.osv): } def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None): - 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 return { 'name': line.name, 'picking_id': picking_id, diff --git a/addons/sale_stock/sale_stock_data.xml b/addons/sale_stock/sale_stock_data.xml deleted file mode 100644 index bb4944bd87e..00000000000 --- a/addons/sale_stock/sale_stock_data.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data noupdate="1"> - - <!-- Resource: sale.shop --> - <record id="sale.sale_shop_1" model="sale.shop"> - <field name="warehouse_id" ref="stock.warehouse0"/> - </record> - - </data> -</openerp>
\ No newline at end of file diff --git a/addons/sale_stock/sale_stock_demo.xml b/addons/sale_stock/sale_stock_demo.xml index 15b1e60b829..2e7b641659d 100644 --- a/addons/sale_stock/sale_stock_demo.xml +++ b/addons/sale_stock/sale_stock_demo.xml @@ -3,21 +3,37 @@ <data noupdate="1"> <record id="sale.sale_order_1" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> <field name="order_policy">prepaid</field> </record> - + + <record id="sale.sale_order_2" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> + </record> + + <record id="sale.sale_order_3" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> + </record> + <record id="sale.sale_order_4" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> <field name="order_policy">prepaid</field> </record> <record id="sale.sale_order_5" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> <field name="order_policy">picking</field> </record> <record id="sale.sale_order_6" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> <field name="order_policy">picking</field> </record> + <record id="sale.sale_order_8" model="sale.order"> + <field name="warehouse_id" ref="stock.warehouse0"/> + </record> + <!-- Confirm some Sale Orders--> <workflow action="order_confirm" model="sale.order" ref="sale.sale_order_1"/> <workflow action="order_confirm" model="sale.order" ref="sale.sale_order_5"/> diff --git a/addons/sale_stock/sale_stock_view.xml b/addons/sale_stock/sale_stock_view.xml index 9d852405b9e..b66177d374b 100644 --- a/addons/sale_stock/sale_stock_view.xml +++ b/addons/sale_stock/sale_stock_view.xml @@ -2,31 +2,6 @@ <openerp> <data> - <record id="view_sale_shop_form_inherit" model="ir.ui.view"> - <field name="name">sale.shop.inherit.form</field> - <field name="model">sale.shop</field> - <field name="inherit_id" ref="sale.view_shop_form"/> - <field name="arch" type="xml"> - <xpath expr="//group[@name='shop']" position="before"> - <label for="warehouse_id" class="oe_edit_only"/> - <h2><field name="warehouse_id" required="1"/></h2> - </xpath> - </field> - </record> - - <record id="view_shop_tree_inherit" model="ir.ui.view"> - <field name="name">sale.shop.sale.stock</field> - <field name="model">sale.shop</field> - <field name="inherit_id" ref="sale.view_shop_tree"/> - <field name="arch" type="xml"> - <field name="name" position="after"> - <field name="warehouse_id"/> - </field> - </field> - </record> - - <menuitem action="sale.action_shop_form" id="menu_action_shop_form" parent="base.menu_base_config" sequence="35" groups="stock.group_locations"/> - <record id="view_order_form_inherit" model="ir.ui.view"> <field name="name">sale.order.form.sale.stock</field> <field name="model">sale.order</field> @@ -48,17 +23,20 @@ <field name="state" position="replace"> <field name="state" widget="statusbar" statusbar_visible="draft,sent,progress,invoiced,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/> </field> - <field name="shop_id" position="replace"> - <field name="shop_id" on_change="onchange_shop_id(shop_id)" widget="selection" groups="stock.group_locations"/> - </field> + <field name="company_id" position="replace"> + <field name="company_id" readonly="True"/> + </field> + <field name="fiscal_position" position="after"> + <field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection" groups="stock.group_locations"/> + </field> <field name="product_id" position="replace"> <field name="product_id" - context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" + context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" groups="base.group_user" on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, True, parent.date_order, product_packaging, parent.fiscal_position, False, context)"/> </field> <field name="product_uom_qty" position="replace"> - <field context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" + <field context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" name="product_uom_qty" class="oe_inline" on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, context)"/> </field> @@ -78,7 +56,7 @@ groups="sale.group_mrp_properties"/> </xpath> <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='tax_id']" position="before"> - <field name="product_packaging" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}" on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)" domain="[('product_id','=',product_id)]" groups="product.group_stock_packaging" /> + <field name="product_packaging" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)" domain="[('product_id','=',product_id)]" groups="product.group_stock_packaging" /> </xpath> <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/div/field[@name='invoice_lines']" position="after"> <label for="move_ids"/> diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml index afffda1ef21..4a6f3d38f97 100644 --- a/addons/sale_stock/test/picking_order_policy.yml +++ b/addons/sale_stock/test/picking_order_policy.yml @@ -63,8 +63,8 @@ assert picking.note == sale_order.note,"Note is not correspond with sale order." assert picking.invoice_state == (sale_order.order_policy=='picking' and '2binvoiced') or 'none',"Invoice policy is not correspond with sale order." assert len(picking.move_lines) == len(sale_order.order_line), "Total move of delivery order are not corresposning with total sale order lines." - location_id = sale_order.shop_id.warehouse_id.lot_stock_id.id - output_id = sale_order.shop_id.warehouse_id.lot_output_id.id + location_id = sale_order.warehouse_id.lot_stock_id.id + output_id = sale_order.warehouse_id.lot_output_id.id for move in picking.move_lines: order_line = move.sale_line_id sale_order_date = self.date_to_datetime(cr, uid, sale_order.date_order, context) diff --git a/addons/stock/product.py b/addons/stock/product.py index 29445f671ee..f31c2b21ef1 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -205,7 +205,6 @@ class product_product(osv.osv): location_obj = self.pool.get('stock.location') warehouse_obj = self.pool.get('stock.warehouse') - shop_obj = self.pool.get('sale.shop') states = context.get('states',[]) what = context.get('what',()) @@ -215,11 +214,6 @@ class product_product(osv.osv): if not ids: return res - if context.get('shop', False): - warehouse_id = shop_obj.read(cr, uid, int(context['shop']), ['warehouse_id'])['warehouse_id'][0] - if warehouse_id: - context['warehouse'] = warehouse_id - if context.get('warehouse', False): lot_id = warehouse_obj.read(cr, uid, int(context['warehouse']), ['lot_stock_id'])['lot_stock_id'][0] if lot_id: @@ -372,7 +366,6 @@ class product_product(osv.osv): "In a context with a single Warehouse, this includes " "goods stored in the Stock Location of this Warehouse, or any " "of its children.\n" - "In a context with a single Shop, this includes goods " "stored in the Stock Location of the Warehouse of this Shop, " "or any of its children.\n" "Otherwise, this includes goods stored in any Stock Location " @@ -387,7 +380,6 @@ class product_product(osv.osv): "In a context with a single Warehouse, this includes " "goods stored in the Stock Location of this Warehouse, or any " "of its children.\n" - "In a context with a single Shop, this includes goods " "stored in the Stock Location of the Warehouse of this Shop, " "or any of its children.\n" "Otherwise, this includes goods stored in any Stock Location " diff --git a/addons/stock_location/stock_location_demo_cpu1.xml b/addons/stock_location/stock_location_demo_cpu1.xml index d9a220daef6..c756dac2566 100644 --- a/addons/stock_location/stock_location_demo_cpu1.xml +++ b/addons/stock_location/stock_location_demo_cpu1.xml @@ -75,17 +75,5 @@ <field name="product_id" ref="product.product_product_9"/> </record> - <record id="sale_shop2" model="sale.shop"> - <field name="name">Chicago Shop</field> - <field name="warehouse_id" ref="stock.stock_warehouse_shop0"/> - <field name="company_id" ref="stock.res_company_1"/> - <field model="account.payment.term" name="payment_default_id" search="[]"/> - </record> - <record id="sale_shop3" model="sale.shop"> - <field name="name">Birmingham shop</field> - <field name="warehouse_id" ref="stock.stock_warehouse_shop1"/> - <field name="company_id" ref="stock.res_company_2"/> - <field model="account.payment.term" name="payment_default_id" search="[]"/> - </record> </data> </openerp>
\ No newline at end of file |
