summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosse Colpaert <jco@odoo.com>2014-09-08 15:20:01 +0200
committerJosse Colpaert <jco@odoo.com>2014-09-12 13:49:42 +0200
commitcd462b7c8d182c5e554351d45f652dff33707fa4 (patch)
tree5f5f620b8ae4b6eeda1055fcf4cd8366edaaee15
parentd38fafdee8fdd4ad1ce3043e5b347317f0b83369 (diff)
[IMP] Invoice_state on move and search custom picking type
-rw-r--r--addons/mrp/mrp.py22
-rw-r--r--addons/stock/stock.py11
-rw-r--r--addons/stock_account/stock.py7
-rw-r--r--addons/stock_account/stock_account_view.xml10
4 files changed, 40 insertions, 10 deletions
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index c06acff1153..5f84cdaf730 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -1065,16 +1065,32 @@ class mrp_production(osv.osv):
+
def _create_previous_move(self, cr, uid, move_id, product, source_location_id, dest_location_id, context=None):
'''
When the routing gives a different location than the raw material location of the production order,
we should create an extra move from the raw material location to the location of the routing, which
- precedes the consumption line (chained)
+ precedes the consumption line (chained). The picking type depends on the warehouse in which this happens
+ and the type of locations.
'''
-
+ loc_obj = self.pool.get("stock.location")
stock_move = self.pool.get('stock.move')
type_obj = self.pool.get('stock.picking.type')
- types = type_obj.search(cr, uid, [('code','=','outgoing')], context=context)
+ # Need to search for a picking type
+ src_loc = loc_obj.browse(cr, uid, source_location_id, context=context)
+ dest_loc = loc_obj.browse(cr, uid, dest_location_id, context=context)
+ code = 'internal'
+ check_loc = dest_loc
+ if src_loc.usage == 'internal' and dest_loc.usage != 'internal':
+ code = 'outgoing'
+ check_loc = src_loc
+ if src_loc.usage != 'internal' and dest_loc.usage == 'internal':
+ code = 'incoming'
+ wh = loc_obj.get_warehouse(cr, uid, check_loc, context=context)
+ domain = [('code','=', code)]
+ if wh:
+ domain += [('warehouse_id', '=', wh)]
+ types = type_obj.search(cr, uid, domain, context=context)
move = stock_move.copy(cr, uid, move_id, default = {
'location_id': source_location_id,
'location_dest_id': dest_location_id,
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index f033b4d5e6a..9b9d8a5c0d9 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -189,6 +189,16 @@ class stock_location(osv.osv):
return self._default_removal_strategy(cr, uid, context=context)
+ def get_warehouse(self, cr, uid, location, context=None):
+ """
+ Returns warehouse id of warehouse that contains location
+ :param location: browse record (stock.location)
+ """
+ wh_obj = self.pool.get("stock.warehouse")
+ whs = wh_obj.search(cr, uid, [('view_location_id.parent_left', '<=', location.parent_left),
+ ('view_location_id.parent_right', '>=', location.parent_left)], context=context)
+ return whs and whs[0] or False
+
#----------------------------------------------------------
# Routes
#----------------------------------------------------------
@@ -3460,6 +3470,7 @@ class stock_warehouse(osv.osv):
'limit': 20
}
+
class stock_location_path(osv.osv):
_name = "stock.location.path"
_description = "Pushed Flows"
diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py
index 12f6c76573d..f1a3680eca7 100644
--- a/addons/stock_account/stock.py
+++ b/addons/stock_account/stock.py
@@ -97,7 +97,6 @@ class stock_move(osv.osv):
def _get_master_data(self, cr, uid, move, company, context=None):
''' returns a tuple (browse_record(res.partner), ID(res.users), ID(res.currency)'''
currency = company.currency_id.id
- import pdb; pdb.set_trace()
partner = move.picking_id and move.picking_id.partner_id
if partner:
if partner.property_product_pricelist and move.location_id.usage == 'internal' and move.location_dest_id.usage != 'internal':
@@ -193,11 +192,6 @@ class stock_picking(osv.osv):
res.append(move.picking_id.id)
return res
- def _set_inv_state(self, cr, uid, picking_id, name, value, arg, context=None):
- pick = self.browse(cr, uid, picking_id, context=context)
- moves = [x.id for x in pick.move_lines]
- move_obj= self.pool.get("stock.move")
- move_obj.write(cr, uid, moves, {'invoice_state': pick.invoice_state})
_columns = {
@@ -206,7 +200,6 @@ class stock_picking(osv.osv):
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")
], string="Invoice Control", required=True,
- #fnct_inv = _set_inv_state,
store={
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['state'], 10),
'stock.move': (__get_picking_move, ['picking_id', 'invoice_state'], 10),
diff --git a/addons/stock_account/stock_account_view.xml b/addons/stock_account/stock_account_view.xml
index dbce1a96bdd..a3dd6260189 100644
--- a/addons/stock_account/stock_account_view.xml
+++ b/addons/stock_account/stock_account_view.xml
@@ -82,5 +82,15 @@
</xpath>
</field>
</record>
+ <record model="ir.ui.view" id="view_move_picking_from_stockaccount_inherit">
+ <field name="name">stock.move.form.invoice_state</field>
+ <field name="model">stock.move</field>
+ <field name="inherit_id" ref="stock.view_move_picking_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='date_expected']" position="after">
+ <field name="invoice_state" groups="account.group_account_invoice"/>
+ </xpath>
+ </field>
+ </record>
</data>
</openerp>