[IMP]remove date related sale.shop and add warehouse_id as new field to handle location in sale order

bzr revid: sgo@tinyerp.com-20130122110857-61jsli1sywu3h5q0
This commit is contained in:
sgo@tinyerp.com 2013-01-22 16:38:57 +05:30
parent 05caf0a5ce
commit 5600ce8a34
9 changed files with 39 additions and 66 deletions

View File

@ -151,6 +151,12 @@ class sale_order(osv.osv):
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
def _get_default_company(self, cr, uid, context=None):
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
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,
@ -220,6 +226,7 @@ class sale_order(osv.osv):
_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: '/',

View File

@ -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',

View File

@ -57,7 +57,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,
@ -83,7 +82,6 @@ class sale_report(osv.osv):
s.date_confirm,
s.partner_id,
s.user_id,
s.shop_id,
s.company_id,
s.state,
s.shipped,

View File

@ -51,9 +51,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"),
}

View File

@ -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>

View File

@ -26,14 +26,6 @@ from openerp.osv import fields, osv
from openerp import netsvc
from openerp.tools.translate import _
class sale_shop(osv.osv):
_inherit = "sale.shop"
_columns = {
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'),
}
sale_shop()
class sale_order(osv.osv):
_inherit = "sale.order"
@ -72,6 +64,13 @@ class sale_order(osv.osv):
vals.update({'invoice_quantity': 'procurement'})
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').browse(cr, uid, uid, context=context).company_id.id
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 default location for the current user\'s company!'))
return warehouse_ids[0]
# This is False
def _picked_rate(self, cr, uid, ids, name, arg, context=None):
@ -140,11 +139,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', 'Location'),
'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',
@ -276,7 +277,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,
@ -284,8 +285,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,

View File

@ -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>

View File

@ -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"/>

View File

@ -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,14 @@
<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="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 +50,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"/>