[MERGE] Merge stock_invoice_directly,stock_location module changes for view,yml
bzr revid: sbh@tinyerp.com-20100803124541-80o0jaxu2spqfz1w
This commit is contained in:
@@ -256,7 +256,22 @@
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = pick_obj.search(cr, uid, [('type','=','in')])
|
||||
self.view_init(cr, uid, ['date'],context={'active_ids': picking_ids})
|
||||
self.do_partial(cr, uid, [1], context={'active_ids': picking_ids})
|
||||
picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')])
|
||||
partial = self.browse(cr, uid, 1, context)
|
||||
partial_datas = {
|
||||
'delivery_date': partial.date
|
||||
}
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids):
|
||||
for m in pick.move_lines:
|
||||
partial_datas['move%s'%(m.id)] = {
|
||||
'product_id': m.product_id.id,
|
||||
'product_qty': m.product_qty,
|
||||
'product_uom': m.product_uom.id
|
||||
}
|
||||
if (pick.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
'product_price': m.product_price,
|
||||
'product_currency': m.product_currency
|
||||
})
|
||||
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_maxtor
|
||||
qty: 300.0
|
||||
min_qty: 300.0
|
||||
standard_price: 1.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
@@ -68,7 +68,7 @@
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_asus
|
||||
qty: 100.0
|
||||
min_qty: 100.0
|
||||
standard_price: 1.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
'init_xml': [],
|
||||
'update_xml': [],
|
||||
'demo_xml': [],
|
||||
'test': ['test/stock_invoice_directly.yml'],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '0081385081261',
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
-
|
||||
In order to test the stock_invoice_directly module. I will create an outgoing
|
||||
picking order which creates an invoice from the picking order itself.
|
||||
-
|
||||
I create an Outgoing Picking order.
|
||||
-
|
||||
!record {model: stock.picking, id: stock_picking_out0}:
|
||||
address_id: base.res_partner_address_3000
|
||||
company_id: base.main_company
|
||||
invoice_state: 2binvoiced
|
||||
move_lines:
|
||||
- company_id: base.main_company
|
||||
date_expected: '2010-08-03 11:05:47'
|
||||
date_planned: '2010-08-03 11:05:47'
|
||||
location_id: stock.stock_location_stock
|
||||
product_id: product.product_product_pc1
|
||||
product_qty: 3.0
|
||||
product_uom: product.product_uom_unit
|
||||
location_dest_id: stock.stock_location_customers
|
||||
name: '[PC1] Basic PC'
|
||||
move_type: direct
|
||||
name: OUT/00006
|
||||
type: out
|
||||
-
|
||||
I need to check the availability of the product so I make my picking order for processing later.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
self.draft_force_assign(cr, uid, [ref("stock_picking_out0")], {"lang": "en_US", "search_default_available":
|
||||
1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
|
||||
"active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
|
||||
})
|
||||
-
|
||||
I check the product availability. Product is available in the stock and ready to be sent.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
self.action_assign(cr, uid, [ref("stock_picking_out0")], {"lang": "en_US", "search_default_available":
|
||||
1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
|
||||
"active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
|
||||
})
|
||||
-
|
||||
I create a record for partial picking.
|
||||
-
|
||||
!record {model: stock.partial.picking, id: stock_partial_picking_0}:
|
||||
date: '2010-08-03 11:25:58'
|
||||
-
|
||||
I make picking order Done.
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
partial = self.browse(cr, uid, ref('stock_partial_picking_0'), context)
|
||||
partial_datas = {
|
||||
'delivery_date' : partial.date
|
||||
}
|
||||
for pick in pick_obj.browse(cr, uid, [ref('stock_picking_out0')]):
|
||||
for m in pick.move_lines:
|
||||
partial_datas['move%s'%(m.id)] = {
|
||||
'product_id' : m.product_id.id,
|
||||
'product_qty' : m.product_qty,
|
||||
'product_uom' : m.product_uom.id
|
||||
}
|
||||
pick_obj.do_partial(cr, uid, [ref('stock_picking_out0')], partial_datas, context=context)
|
||||
-
|
||||
As the Invoice state of the picking order is To be invoiced. I create a record for create invoice.
|
||||
-
|
||||
!record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_0}:
|
||||
invoice_date: '2010-08-04'
|
||||
journal_id: account.bank_journal
|
||||
type: out_invoice
|
||||
-
|
||||
I create a Customer invoice for my outgoing picking order.
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_0")], {"lang": "en_US",
|
||||
"search_default_available": 1, "tz": False, "active_model": "stock.picking",
|
||||
"contact_display": "partner", "active_ids": [ref("stock_picking_out0")], "active_id": ref("stock_picking_out0")})
|
||||
-
|
||||
I check that the customer invoice is created successfully.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
picking = picking_obj.browse(cr, uid, [ref('stock_picking_out0')])
|
||||
partner = picking[0].address_id.partner_id.id
|
||||
inv_ids = self.search(cr, uid, [('type','=','out_invoice'),('partner_id','=',partner)])
|
||||
assert inv_ids, 'No Invoice is generated!'
|
||||
|
||||
@@ -20,17 +20,24 @@
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class invoice_directly(osv.osv_memory):
|
||||
_inherit = 'stock.partial.picking'
|
||||
|
||||
def do_partial(self, cr, uid, ids, context):
|
||||
""" Makes partial moves and pickings done and
|
||||
launches Create invoice wizard if invoice state is To be Invoiced.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param context: A standard dictionary
|
||||
@return:
|
||||
"""
|
||||
result = super(invoice_directly, self).do_partial(cr, uid, ids, context)
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = context.get('active_ids', False)
|
||||
pick = pick_obj.browse(cr, uid, picking_ids, context)[0]
|
||||
if pick.invoice_state=='2binvoiced':
|
||||
if pick.invoice_state == '2binvoiced':
|
||||
return {
|
||||
'name': 'Create Invoice',
|
||||
'view_type': 'form',
|
||||
@@ -38,7 +45,7 @@ class invoice_directly(osv.osv_memory):
|
||||
'res_model': 'stock.invoice.onshipping',
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
}
|
||||
return {}
|
||||
|
||||
invoice_directly()
|
||||
|
||||
@@ -78,6 +78,15 @@
|
||||
<field name="invoice_state"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
<form string="Pushed flows">
|
||||
<field name="location_from_id"/>
|
||||
<field name="location_dest_id"/>
|
||||
<field name="auto"/>
|
||||
<field name="delay"/>
|
||||
<field name="name"/>
|
||||
<field name="invoice_state"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -192,7 +192,7 @@
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: res_partner_shawtrust0
|
||||
qty: 5.0
|
||||
min_qty: 5.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
@@ -204,7 +204,6 @@
|
||||
delay: 30
|
||||
location_dest_id: stock.location_inventory
|
||||
location_from_id: stock_location_suppiler0
|
||||
pricelist_sale: 'Public Pricelist (0.00) : 1.00\n'
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
'depends': ['mrp'],
|
||||
'update_xml': ['stock_no_autopicking_view.xml'],
|
||||
'demo_xml': [],
|
||||
'test': ['test/stock_no_autopicking.yml'],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '0075124168925',
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import netsvc
|
||||
from osv import fields,osv
|
||||
|
||||
class product(osv.osv):
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
-
|
||||
In order to test the module with OpenERP, I will make products with No auto-picking
|
||||
to allow an intermediate picking process to provide raw materials to production orders.
|
||||
-
|
||||
I create product category for measuring the liquid products. Say Litre.
|
||||
-
|
||||
!record {model: product.uom, id: product_uom_litre0}:
|
||||
category_id: product.product_uom_categ_kgm
|
||||
factor: 1.0
|
||||
name: Litre
|
||||
rounding: 0.01
|
||||
-
|
||||
I create a record for product Tea.
|
||||
-
|
||||
!record {model: product.product, id: product_product_tea0}:
|
||||
categ_id: product.cat1
|
||||
name: Tea
|
||||
procure_method: make_to_stock
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
auto_pick: True
|
||||
-
|
||||
I create a record for product Sugar.
|
||||
-
|
||||
!record {model: product.product, id: product_product_sugar0}:
|
||||
categ_id: product.cat1
|
||||
name: Sugar
|
||||
procure_method: make_to_stock
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
auto_pick: True
|
||||
-
|
||||
I create a record for product Milk.
|
||||
-
|
||||
!record {model: product.product, id: product_product_milk0}:
|
||||
categ_id: product.cat1
|
||||
name: Milk
|
||||
procure_method: make_to_order
|
||||
supply_method: buy
|
||||
type: consu
|
||||
uom_id: product_uom_litre0
|
||||
uom_po_id: product_uom_litre0
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
auto_pick: True
|
||||
-
|
||||
I create a record for product Cup of tea.
|
||||
-
|
||||
!record {model: product.product, id: product_product_cupoftea0}:
|
||||
categ_id: product.cat1
|
||||
name: Cup of Tea
|
||||
procure_method: make_to_order
|
||||
supply_method: produce
|
||||
type: product
|
||||
uom_id: product_uom_litre0
|
||||
uom_po_id: product_uom_litre0
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
auto_pick: False
|
||||
-
|
||||
I create a record for Workcenter.
|
||||
-
|
||||
!record {model: mrp.workcenter, id: mrp_workcenter_production0}:
|
||||
costs_cycle: 0.0
|
||||
costs_hour: 0.0
|
||||
name: Production Workcenter
|
||||
resource_type: material
|
||||
time_cycle: 0.0
|
||||
time_efficiency: 1.0
|
||||
time_start: 0.0
|
||||
time_stop: 0.0
|
||||
-
|
||||
I create a routing.
|
||||
-
|
||||
!record {model: mrp.routing, id: mrp_routing_productionrouting0}:
|
||||
name: Production Routing
|
||||
location_id: stock.stock_location_13
|
||||
workcenter_lines:
|
||||
- cycle_nbr: 1.0
|
||||
hour_nbr: 0.5
|
||||
sequence: 0.0
|
||||
name: Production
|
||||
workcenter_id: mrp_workcenter_production0
|
||||
-
|
||||
I create a Bill of material for the product Cup of tea.
|
||||
-
|
||||
!record {model: mrp.bom, id: mrp_bom_cupoftea0}:
|
||||
company_id: base.main_company
|
||||
name: Cup of Tea
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_cupoftea0
|
||||
product_qty: 1.0
|
||||
product_uom: product_uom_litre0
|
||||
type: normal
|
||||
routing_id: mrp_routing_productionrouting0
|
||||
bom_lines:
|
||||
- company_id: base.main_company
|
||||
name: Tea
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_tea0
|
||||
product_qty: 200.0
|
||||
product_uom: product.product_uom_gram
|
||||
type: normal
|
||||
- company_id: base.main_company
|
||||
name: Sugar
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_sugar0
|
||||
product_qty: 200.0
|
||||
product_uom: product.product_uom_gram
|
||||
type: normal
|
||||
- company_id: base.main_company
|
||||
name: Water
|
||||
product_efficiency: 1.0
|
||||
product_id: product_product_milk0
|
||||
product_qty: 0.5
|
||||
product_uom: product_uom_litre0
|
||||
type: normal
|
||||
-
|
||||
I make the production order for the product Cup of Tea.
|
||||
-
|
||||
!record {model: mrp.production, id: mrp_production_mo0}:
|
||||
product_id: product_product_cupoftea0
|
||||
product_qty: 5.0
|
||||
product_uom: product_uom_litre0
|
||||
product_uos_qty: 0.0
|
||||
bom_id: mrp_bom_cupoftea0
|
||||
routing_id: mrp_routing_productionrouting0
|
||||
company_id: base.main_company
|
||||
date_planned: '2010-08-03 15:12:32'
|
||||
location_dest_id: stock.stock_location_stock
|
||||
location_src_id: stock.stock_location_stock
|
||||
name: MO/00002
|
||||
-
|
||||
I compute the data of production order.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
self.action_compute(cr, uid, [ref("mrp_production_mo0")], {"lang": "en_US", "tz": False, "search_default_Current":
|
||||
1, "active_model": "ir.ui.menu", "active_ids": [ref("mrp.menu_mrp_production_action")],
|
||||
"active_id": ref("mrp.menu_mrp_production_action"), })
|
||||
-
|
||||
I confirm the production order.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo0}
|
||||
-
|
||||
I check that all three stock moves have the destination location which is set in routing instead of the default one.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
production = self.browse(cr, uid, [ref("mrp_production_mo0")])
|
||||
route_location_id = production[0].routing_id.location_id.id
|
||||
for move in production[0].move_lines:
|
||||
assert (move.location_id.id == route_location_id),'Wrong Move !'
|
||||
Reference in New Issue
Block a user