diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 1a693637b7f..c1525a70f6f 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -761,7 +761,7 @@ class sale_order_line(osv.osv):
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', store=True, string='Salesperson'),
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation and the shipping of the products to the customer", readonly=True, states={'draft': [('readonly', False)]}),
- 'procurement_ids': fields.many2one('procurement.order', 'sale_line_ids', 'Procurements'),
+ 'procurement_ids': fields.one2many('procurement.order', 'sale_line_id', 'Procurements'),
}
_order = 'order_id desc, sequence, id'
_defaults = {
@@ -1072,7 +1072,7 @@ class account_invoice(osv.Model):
class procurement_order(osv.osv):
_inherit = 'procurement.order'
_columns = {
- 'sale_line_id': fields.many2one('sale.order.line', string = 'Sale Order Line')
+ 'sale_line_id': fields.many2one('sale.order.line', string='Sale Order Line'),
'invoice_state': fields.selection(
[
("invoiced", "Invoiced"),
@@ -1084,5 +1084,3 @@ class procurement_order(osv.osv):
'invoice_state': 'none',
}
-
-
diff --git a/addons/sale_stock/__init__.py b/addons/sale_stock/__init__.py
index f521debcea5..9c74739d4c9 100644
--- a/addons/sale_stock/__init__.py
+++ b/addons/sale_stock/__init__.py
@@ -24,4 +24,5 @@ import stock
import report
import company
import res_config
+import wizard
diff --git a/addons/sale_stock/__openerp__.py b/addons/sale_stock/__openerp__.py
index fe0b28fe43a..b1686bebb20 100644
--- a/addons/sale_stock/__openerp__.py
+++ b/addons/sale_stock/__openerp__.py
@@ -47,21 +47,24 @@ You can choose flexible invoicing methods:
'images': ['images/deliveries_to_invoice.jpeg'],
'depends': ['sale', 'stock_account'],
'init_xml': [],
- 'update_xml': ['security/sale_stock_security.xml',
- 'security/ir.model.access.csv',
- 'company_view.xml',
- 'sale_stock_view.xml',
- 'sale_stock_workflow.xml',
- 'stock_view.xml',
- 'res_config_view.xml',
- 'report/sale_report_view.xml',
- ],
+ 'update_xml': [
+ 'security/sale_stock_security.xml',
+ 'security/ir.model.access.csv',
+ 'company_view.xml',
+ 'wizard/stock_invoice_onshipping_view.xml',
+ 'sale_stock_view.xml',
+ 'sale_stock_workflow.xml',
+ 'stock_view.xml',
+ 'res_config_view.xml',
+ 'report/sale_report_view.xml',
+ ],
'demo_xml': ['sale_stock_demo.xml'],
- 'test': ['test/cancel_order_sale_stock.yml',
- 'test/picking_order_policy.yml',
- 'test/prepaid_order_policy.yml',
- 'test/sale_order_onchange.yml',
- ],
+ 'test': [
+ 'test/cancel_order_sale_stock.yml',
+ 'test/picking_order_policy.yml',
+ 'test/prepaid_order_policy.yml',
+ 'test/sale_order_onchange.yml',
+ ],
'installable': True,
'auto_install': True,
}
diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py
index 031bfbba97d..707adb27a7e 100644
--- a/addons/sale_stock/sale_stock.py
+++ b/addons/sale_stock/sale_stock.py
@@ -57,11 +57,9 @@ class sale_order(osv.osv):
def _get_orders(self, cr, uid, ids, context=None):
res = set()
- proc_obj = self.pool.get("procurement.order")
- procs = proc_obj.search(cr, uid, [('move_id', 'in', ids)], context=context)
- for proc in proc_obj.browse(cr, uid, procs, context=context):
- if proc.group_id and proc.group_id.sale_id:
- res.add(proc.group_id.sale_id.id)
+ for move in self.browse(cr, uid, ids, context=context):
+ 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_picking_ids(self, cr, uid, ids, name, args, context=None):
@@ -72,8 +70,9 @@ class sale_order(osv.osv):
continue
picking_ids = {}
for procurement in sale.procurement_group_id.procurement_ids:
- if procurement.move_id and procurement.move_id.picking_id:
- picking_ids[procurement.move_id.picking_id.id] = True
+ for move in procurement.move_ids:
+ if move.picking_id:
+ picking_ids[move.picking_id.id] = True
res[sale.id] = picking_ids.keys()
return res
@@ -207,13 +206,12 @@ class sale_order(osv.osv):
write_cancel_ids = []
for order in self.browse(cr, uid, ids, context={}):
for line in order.order_line:
- if (not line.procurement_id) or (line.procurement_id.state=='done'):
- if line.state != 'done':
+ for procurement in line.procurement_ids:
+ if procurement.state != 'done':
write_done_ids.append(line.id)
- else:
- finished = False
- if line.procurement_id:
- if (line.procurement_id.state == 'cancel'):
+ else:
+ finished = False
+ if (procurement.state == 'cancel'):
canceled = True
if line.state != 'exception':
write_cancel_ids.append(line.id)
diff --git a/addons/sale_stock/sale_stock_view.xml b/addons/sale_stock/sale_stock_view.xml
index c7ad4b88044..451a82f1837 100644
--- a/addons/sale_stock/sale_stock_view.xml
+++ b/addons/sale_stock/sale_stock_view.xml
@@ -58,10 +58,6 @@
-
-
-
-
@@ -108,5 +104,29 @@
groups="sale.group_delivery_invoice_address"
/>
+
+ stock.picking.form.inherit
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+ stock.picking.search.inherit
+ stock.picking
+
+
+
+
+
+
+
+
+
diff --git a/addons/sale_stock/stock.py b/addons/sale_stock/stock.py
index 4d52e610092..3646b26fc09 100644
--- a/addons/sale_stock/stock.py
+++ b/addons/sale_stock/stock.py
@@ -24,7 +24,7 @@ from openerp.tools.translate import _
class stock_picking(osv.osv):
_inherit = 'stock.picking'
- def __get_invoice_state(self, cursor, user, ids, name, arg, context=None):
+ def __get_invoice_state(self, cr, uid, ids, name, arg, context=None):
result = {}
for pick in self.browse(cr, uid, ids, context=context):
result[pick.id] = 'none'
@@ -37,14 +37,25 @@ class stock_picking(osv.osv):
break
return result
+ def __get_picking_procurement(self, cr, uid, ids, context={}):
+ result = {}
+ for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
+ for move in proc.move_ids:
+ if move.picking_id:
+ result[move.picking_id.id] = True
+ return result.keys()
+
_columns = {
- # TODO: add a store=...
- 'invoice_state': fields.function(_get_invoice_state, type='selection', selection=[
+ 'invoice_state': fields.function(__get_invoice_state, type='selection', selection=[
("invoiced", "Invoiced"),
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")
- ], "Invoice Control", required=True),
-
+ ], string="Invoice Control", required=True,
+ store={'procurement.order': (__get_picking_procurement, ['invoice_state'], 10)},
+ ),
+ }
+ _defaults = {
+ 'invoice_state': lambda *args, **argv: 'none'
}
def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None):
@@ -88,14 +99,14 @@ class stock_picking(osv.osv):
invoice_id = self.pool.get('account.invoice').create(cr, uid, {
'origin': sale.name,
'date_invoice': context.get('date_inv', False),
- 'user_id': sale.user_id and sale.user_id.id or False
+ 'user_id': sale.user_id and sale.user_id.id or False,
'partner_id': partner.id,
'account_id': account_id,
'payment_term': payment_term,
'type': inv_type,
'fiscal_position': partner.property_account_position.id,
'company_id': sale.company_id.id,
- 'currency_id': sale.pricelist_id.currency_id.id,
+ 'currency_id': sale.pricelist_id.currency_id.id,
'journal_id': journal_id,
}, context=context)
invoices[key] = invoice_id
diff --git a/addons/sale_stock/stock_view.xml b/addons/sale_stock/stock_view.xml
index 9a31b8e02a7..b06f56d6659 100644
--- a/addons/sale_stock/stock_view.xml
+++ b/addons/sale_stock/stock_view.xml
@@ -2,19 +2,6 @@
-
-
-
- Outgoing picking Inherited
- stock.picking
-
-
-
-
-
-
-
-
Deliveries to Invoice
@@ -23,7 +10,7 @@
form
tree,form,calendar
[('location_id.usage','=','internal'), ('location_dest_id.usage','!=','internal')]
- {'default_type': 'out', 'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1, 'default_invoice_state': '2binvoiced'}
+ {'default_type': 'out', 'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1}
diff --git a/addons/sale_stock/wizard/__init__.py b/addons/sale_stock/wizard/__init__.py
new file mode 100644
index 00000000000..e32a95fef96
--- /dev/null
+++ b/addons/sale_stock/wizard/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import stock_invoice_onshipping
diff --git a/addons/stock_account/wizard/stock_invoice_onshipping.py b/addons/sale_stock/wizard/stock_invoice_onshipping.py
similarity index 100%
rename from addons/stock_account/wizard/stock_invoice_onshipping.py
rename to addons/sale_stock/wizard/stock_invoice_onshipping.py
diff --git a/addons/stock_account/wizard/stock_invoice_onshipping_view.xml b/addons/sale_stock/wizard/stock_invoice_onshipping_view.xml
similarity index 100%
rename from addons/stock_account/wizard/stock_invoice_onshipping_view.xml
rename to addons/sale_stock/wizard/stock_invoice_onshipping_view.xml
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index 290f96a8201..7cf905bdcfa 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -39,7 +39,7 @@ class procurement_rule(osv.osv):
_columns = {
'location_id': fields.many2one('stock.location', 'Destination Location'),
'location_src_id': fields.many2one('stock.location', 'Source Location',
- help="Source location is action=move"),
+ help="Source location is action=move"),
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True,
help="Picking Type determines the way the picking should be shown in the view, reports, ...")
}
@@ -48,7 +48,7 @@ class procurement_order(osv.osv):
_inherit = "procurement.order"
_columns = {
'location_id': fields.many2one('stock.location', 'Destination Location'),
- 'move_id': fields.many2one('stock.move', 'Move', help="Move created by the procurement"),
+ 'move_ids': fields.one2many('stock.move', 'procurement_id', 'Moves', help="Moves created by the procurement"),
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Move which caused (created) the procurement"),
}
@@ -82,7 +82,7 @@ class procurement_order(osv.osv):
'location_id': procurement.rule_id.location_src_id.id,
'location_dest_id': procurement.rule_id.location_id.id,
'move_dest_id': procurement.move_dest_id and procurement.move_dest_id.id or False,
- 'group_id': procurement.group_id and procurement.group_id.id or False,
+ 'procurement_id': procurement.id,
'rule_id': procurement.rule_id.id,
'picking_type_id': procurement.rule_id.picking_type_id.id,
}
@@ -96,12 +96,16 @@ class procurement_order(osv.osv):
move_dict = self._run_move_create(cr, uid, procurement, context=context)
move_id = move_obj.create(cr, uid, move_dict, context=context)
move_obj.action_confirm(cr, uid, [move_id], context=context)
- self.write(cr, uid, [procurement.id], {'move_id': move_id}, context=context)
return move_id
return super(procurement_order, self)._run(cr, uid, procurement, context)
def _check(self, cr, uid, procurement, context=None):
if procurement.rule_id and procurement.rule_id.action == 'move':
+ for move in procurement.move_ids:
+ if not move.state in ('done', 'cancel'):
+ return False
+ else:
+ return True
return procurement.move_id.state == 'done'
return super(procurement_order, self)._check(cr, uid, procurement, context)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 74f10d3db0d..494393a3943 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -951,7 +951,8 @@ class stock_move(osv.osv):
'quant_ids': fields.many2many('stock.quant', 'stock_quant_move_rel', 'move_id', 'quant_id', 'Quants'),
'reserved_quant_ids': fields.one2many('stock.quant', 'reservation_id', 'Reserved quants'),
'remaining_qty': fields.function(_get_remaining_qty, type='float', string='Remaining Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), states={'done': [('readonly', True)]}),
- 'group_id': fields.many2one('procurement.group', 'Procurement Group'),
+ 'procurement_id': fields.many2one('procurement.order', 'Procurement'),
+ 'group_id': fields.related('procurement_id', 'group_id', type='many2one', relation="procurement.group", string='Procurement Group'),
'rule_id': fields.many2one('procurement.rule', 'Procurement Rule'),
'propagate': fields.boolean('Propagate cancel and split', help='If checked, when this move is cancelled, cancel the linked move too'),
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
@@ -2136,4 +2137,3 @@ class stock_picking_type(osv.osv):
}
-
diff --git a/addons/stock_account/__openerp__.py b/addons/stock_account/__openerp__.py
index 2434e88acfb..93ffe4006ec 100644
--- a/addons/stock_account/__openerp__.py
+++ b/addons/stock_account/__openerp__.py
@@ -48,11 +48,9 @@ Dashboard / Reports for Warehouse Management will include:
],
'data': [
'stock_account_data.xml',
- 'wizard/stock_invoice_onshipping_view.xml',
'wizard/stock_change_standard_price_view.xml',
'product_data.xml',
'product_view.xml',
-
'stock_account_view.xml',
'valuationandcostmethod.yml',
],
diff --git a/addons/stock_account/stock_account_view.xml b/addons/stock_account/stock_account_view.xml
index 0410396191d..cf9aaebf236 100644
--- a/addons/stock_account/stock_account_view.xml
+++ b/addons/stock_account/stock_account_view.xml
@@ -16,28 +16,5 @@
-
- stock.picking.form.inherit
- stock.picking
-
-
-
-
-
-
-
-
-
-
- stock.picking.search.inherit
- stock.picking
-
-
-
-
-
-
-
-
diff --git a/addons/stock_account/wizard/__init__.py b/addons/stock_account/wizard/__init__.py
index 001a39e763e..ecb883ed6fb 100644
--- a/addons/stock_account/wizard/__init__.py
+++ b/addons/stock_account/wizard/__init__.py
@@ -20,4 +20,3 @@
##############################################################################
import stock_change_standard_price
-import stock_invoice_onshipping