[MERGE]sync with parent

bzr revid: sgo@tinyerp.com-20130829121514-q205bhf6uyxzp6ly
This commit is contained in:
Sanjay Gohel (OpenERP) 2013-08-29 17:45:14 +05:30
commit 3d494a4deb
5 changed files with 84 additions and 48 deletions

View File

@ -14,8 +14,7 @@
!record {model: product.product, id: product_product_hrmanger0}:
categ_id: product.product_category_6
mes_type: fixed
name: HR Manger
procure_method: make_to_stock
name: HR Manager
standard_price: 1.0
supply_method: buy
type: service

View File

@ -658,7 +658,7 @@ class sale_order(osv.osv):
for order in self.browse(cr, uid, ids, context=context):
proc_ids = []
group_id = self.pool.get("procurement.group").create(cr, uid, {
'name': order.name, 'partner_id': order.partner_shipping_id.id
'name': order.name, 'partner_id': order.partner_shipping_id.id, 'move_type': order.picking_policy
}, context=context)
order.write({'procurement_group_id': group_id}, context=context)
for line in order.order_line:
@ -1082,4 +1082,4 @@ class procurement_order(osv.osv):
_defaults = {
'invoice_state': 'none',
}

View File

@ -61,7 +61,14 @@ class sale_order(osv.osv):
if move.procurement_id and move.procurement_id.sale_line_id:
res.add(move.procurement_id.sale_line_id.order_id.id)
return list(res)
def _get_orders_procurements(self, cr, uid, ids, context=None):
res = set()
for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
if proc.sale_line_id:
res.add(proc.sale_line_id.order_id.id)
return list(res)
def _get_picking_ids(self, cr, uid, ids, name, args, context=None):
res = {}
for sale in self.browse(cr, uid, ids, context=context):
@ -107,7 +114,10 @@ class sale_order(osv.osv):
('prepaid', 'Before Delivery'),
], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
help="""On demand: A draft invoice can be created from the sales order when needed. \nOn delivery order: A draft invoice can be created from the delivery order when the products have been delivered. \nBefore delivery: A draft invoice is created from the sales order and must be paid before the products can be delivered."""),
'shipped': fields.function(_get_shipped, string='Delivered', type='boolean', store={'stock.move': (_get_orders, ['state'], 10)}),
'shipped': fields.function(_get_shipped, string='Delivered', type='boolean', store={
'stock.move': (_get_orders, ['state'], 10),
'procurement.order': (_get_orders_procurements, ['state'], 10)
}),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'picking_ids': fields.function(_get_picking_ids, method=True, type='one2many', relation='stock.picking', string='Picking associated to this sale'),
}
@ -223,7 +233,7 @@ class sale_order(osv.osv):
self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
if write_cancel_ids:
self.pool.get('sale.order.line').write(cr, uid, write_cancel_ids, {'state': 'exception'})
if mode == 'finished':
return finished
elif mode == 'canceled':
@ -265,7 +275,7 @@ class sale_order(osv.osv):
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
def _number_packages(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for line in self.browse(cr, uid, ids, context=context):

View File

@ -39,10 +39,11 @@ This adds a route on the sales order and sales order line (mini module)
'update_xml': ['stock_complex_routes.xml'],
'demo_xml': [],
'test': [
'test/crossdock.yml',
'test/dropship.yml',
'test/lifo_price.yml'
],
'test/crossdock.yml',
'test/dropship.yml',
'test/procurementexception.yml',
'test/lifo_price.yml'
],
'installable': True,
'auto_install': True,
}

View File

@ -1,37 +1,63 @@
-
Create product with no seller_ids
-
-
Create a sales order with 1 piece for that product and route crossdock
-
!record{sale.order}
-
Confirm sales order
-
!python {
-
Check there is a procurement in exception that has the procurement group of the sales order
-
!python {
assert
-
Adjust the product that it has at least one seller_id
-
!record{id: model: product.product) or in !python
-
Run the Scheduler
-
!python
-
Check the status changed there is no procurement order in exception any more from that procurement group
-
!python{model: procurement.order}
search procurement from
-
Check a purchase quotation was created
-
I create a product with no supplier define for it.
-
!record {model: product.product, id: product_with_no_seller}:
name: 'product with no seller'
list_price: 20.00
standard_price: 15.00
categ_id: product.product_category_1
-
I create a sales order with this product with route crossdock.
-
!record {model: sale.order, id: sale_order_route_crossdock}:
partner_id: base.res_partner_2
partner_invoice_id: base.res_partner_address_3
partner_shipping_id: base.res_partner_address_3
note: crossdock route
payment_term: account.account_payment_term
order_line:
- product_id: product_with_no_seller
product_uom_qty: 1
route_id: stock_location.route_warehouse0_crossdock
-
I confirm the sales order.
-
!workflow {model: sale.order, ref: sale_order_route_crossdock, action: order_confirm}
-
I check there is a procurement in exception that has the procurement group of the sales order created before.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')])
assert proc_id, 'No Procurement!'
-
I set the at least one supplier on the product.
-
!record {model: product.product, id: product_with_no_seller}:
seller_ids:
- delay: 1
name: base.res_partner_2
min_qty: 2.0
-
I run the Procurement.
-
!python {model: procurement.order}: |
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')])
self.run(cr, uid, proc_id)
-
I check the status changed there is no procurement order in exception any more from that procurement group
-
!python {model: procurement.order}: |
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')])
assert not proc_id, 'Procurement should be in running state'
-
I check a purchase quotation was created.
-
!python {model: procurement.order}: |
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
proc_ids = self.search(cr, uid, [('group_id.name', '=', sale_id.name)])
purchase_id = [proc.purchase_id for proc in self.browse(cr, uid, proc_ids) if proc.purchase_id]
assert purchase_id, 'No Purchase Quotation is created'