-
-
+
+
diff --git a/addons/sale/report/order.rml b/addons/sale/report/order.rml
index 26f3e8a2cd8..e9b42811414 100644
--- a/addons/sale/report/order.rml
+++ b/addons/sale/report/order.rml
@@ -144,14 +144,15 @@
[[ o.partner_shipping_id.title or '' ]][[ o.partner_shipping_id.name ]]
[[ o.partner_shipping_id.street ]]
[[ o.partner_shipping_id.street2 or '' ]]
- [[ o.partner_shipping_id.city or '' ]][[ o.partner_shipping_id.zip or '' ]]
+ [[ o.partner_shipping_id.city or '' ]] [[ o.partner_shipping_id.zip or '' ]]
[[ o.partner_shipping_id.state_id and o.partner_shipping_id.state_id.name or '' ]][[ o.partner_shipping_id.country_id and o.partner_shipping_id.country_id.name or '' ]]
Invoice address :
[[ o.partner_invoice_id.street ]][[ o.partner_invoice_id.street2 and (', %s' % o.partner_invoice_id.street2 or '') ]]
- [[ o.partner_invoice_id.zip or '' ]][[ o.partner_invoice_id.city or '' ]][[ o.partner_invoice_id.country_id and (', %s' % (o.partner_invoice_id.country_id and o.partner_invoice_id.country_id.name or '')) ]]
+ [[ o.partner_invoice_id.city or '' ]] [[ o.partner_invoice_id.zip or '' ]]
+ [[ o.partner_invoice_id.country_id and ('%s' % (o.partner_invoice_id.country_id and o.partner_invoice_id.country_id.name or '')) ]]
|
@@ -163,7 +164,7 @@
[[ o.partner_order_id.title or '' ]][[ o.partner_order_id.name ]]
[[ o.partner_order_id.street ]]
[[ o.partner_order_id.street2 or '' ]]
- [[ o.partner_order_id.zip or '' ]][[ o.partner_order_id.city or '' ]]
+ [[ o.partner_order_id.city or '' ]] [[ o.partner_order_id.zip or '' ]]
[[ o.partner_order_id.state_id and o.partner_order_id.state_id.name or '' ]][[ o.partner_order_id.country_id and o.partner_order_id.country_id.name or '' ]]
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 494891dd2cd..40574cca830 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -172,6 +172,12 @@ class sale_order(osv.osv):
return [('id', '=', 0)]
return [('id', 'in', [x[0] for x in res])]
+ def _get_order(self, cr, uid, ids, context={}):
+ result = {}
+ for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
+ result[line.order_id.id] = True
+ return result.keys()
+
_columns = {
'name': fields.char('Order Reference', size=64, required=True, select=True),
'shop_id':fields.many2one('sale.shop', 'Shop', required=True, readonly=True, states={'draft':[('readonly',False)]}),
@@ -224,9 +230,23 @@ class sale_order(osv.osv):
'note': fields.text('Notes'),
'amount_untaxed': fields.function(_amount_all, method=True, string='Untaxed Amount',
- store=True, multi='sums'),
- 'amount_tax': fields.function(_amount_all, method=True, string='Taxes', store=True, multi='sums'),
- 'amount_total': fields.function(_amount_all, method=True, string='Total', store=True, multi='sums'),
+ store={
+ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
+ 'sale.order.line': (_get_order, None, 10),
+ },
+ multi='sums'),
+ 'amount_tax': fields.function(_amount_all, method=True, string='Taxes',
+ store={
+ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
+ 'sale.order.line': (_get_order, None, 10),
+ },
+ multi='sums'),
+ 'amount_total': fields.function(_amount_all, method=True, string='Total',
+ store={
+ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, None, 10),
+ 'sale.order.line': (_get_order, None, 10),
+ },
+ multi='sums'),
'invoice_quantity': fields.selection([('order','Ordered Quantities'),('procurement','Shipped Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice). Ordered and delivered quantities may not be the same. You have to choose if you invoice based on ordered or shipped quantities. If the product is a service, shipped quantities means hours spent on the associated tasks.",required=True),
'payment_term' : fields.many2one('account.payment.term', 'Payment Term'),
@@ -362,7 +382,7 @@ class sale_order(osv.osv):
return inv_id
- def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed','done']):
+ def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed','done','exception']):
res = False
invoices = {}
invoice_ids = []
@@ -381,7 +401,7 @@ class sale_order(osv.osv):
for i in o.invoice_ids:
if i.state == 'draft':
return i.id
- picking_obj=self.pool.get('stock.picking')
+ picking_obj=self.pool.get('stock.picking')
for val in invoices.values():
if grouped:
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x,y: x + y, [l for o,l in val], []))
@@ -389,7 +409,7 @@ class sale_order(osv.osv):
self.write(cr, uid, [o.id], {'state' : 'progress'})
if o.order_policy=='picking':
picking_obj.write(cr,uid,map(lambda x:x.id,o.picking_ids),{'invoice_state':'invoiced'})
- cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%d,%d)', (o.id, res))
+ cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (o.id, res))
else:
for order, il in val:
res = self._make_invoice(cr, uid, order, il)
@@ -397,7 +417,7 @@ class sale_order(osv.osv):
self.write(cr, uid, [order.id], {'state' : 'progress'})
if order.order_policy=='picking':
picking_obj.write(cr,uid,map(lambda x:x.id,order.picking_ids),{'invoice_state':'invoiced'})
- cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%d,%d)', (order.id, res))
+ cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (order.id, res))
return res
def action_invoice_cancel(self, cr, uid, ids, context={}):
@@ -479,26 +499,24 @@ 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') or (line.procurement_id.move_id and line.procurement_id.move_id.state=='done'):
+ if (not line.procurement_id) or (line.procurement_id.state=='done'):
finished = True
+ if line.state != 'done':
+ write_done_ids.append(line.id)
else:
finished = False
if line.procurement_id:
- if (line.procurement_id.state == 'cancel') or (line.procurement_id.move_id and line.procurement_id.move_id.state=='cancel'):
+ if (line.procurement_id.state == 'cancel'):
canceled = True
- if line.state != 'cancel':
+ if line.state != 'exception':
write_cancel_ids.append(line.id)
else:
notcanceled = True
- # if a line is finished (ie its procuremnt is done or it has not procuremernt and it
- # is not already marked as done, mark it as being so...
- if ((not line.procurement_id) or line.procurement_id.state == 'done') and line.state != 'done':
- write_done_ids.append(line.id)
if write_done_ids:
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': 'cancel'})
+ self.pool.get('sale.order.line').write(cr, uid, write_cancel_ids, {'state': 'exception'})
if mode=='finished':
return finished
@@ -602,8 +620,12 @@ class sale_order(osv.osv):
if order.state=='shipping_except':
val['state'] = 'progress'
- if (order.order_policy == 'manual') and order.invoice_ids:
- val['state'] = 'manual'
+
+ if (order.order_policy == 'manual'):
+ for line in order.order_line:
+ if (not line.invoiced) and (line.state not in ('cancel','draft')):
+ val['state'] = 'manual'
+ break
self.write(cr, uid, [order.id], val)
return True
@@ -612,10 +634,18 @@ class sale_order(osv.osv):
for order in self.browse(cr, uid, ids):
val = {'shipped':True}
if order.state=='shipping_except':
- if (order.order_policy=='manual') and not order.invoice_ids:
- val['state'] = 'manual'
- else:
- val['state'] = 'progress'
+ val['state'] = 'progress'
+ if (order.order_policy == 'manual'):
+ for line in order.order_line:
+ if (not line.invoiced) and (line.state not in ('cancel','draft')):
+ val['state'] = 'manual'
+ break
+ for line in order.order_line:
+ towrite = []
+ if line.state=='exception':
+ towrite.append(line.id)
+ if towrite:
+ self.pool.get('sale.order.line').write(cr, uid, towrite, {'state':'done'},context=context)
self.write(cr, uid, [order.id], val)
return True
@@ -697,7 +727,7 @@ class sale_order_line(osv.osv):
'number_packages': fields.function(_number_packages, method=True, type='integer', string='Number packages'),
'notes': fields.text('Notes'),
'th_weight' : fields.float('Weight'),
- 'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', required=True, readonly=True),
+ 'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Canceled'),('exception','Exception')], 'Status', required=True, readonly=True),
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer')
}
_order = 'sequence, id'
@@ -767,11 +797,17 @@ class sale_order_line(osv.osv):
'note': line.notes,
'account_analytic_id': line.order_id.project_id.id,
})
- cr.execute('insert into sale_order_line_invoice_rel (order_line_id,invoice_id) values (%d,%d)', (line.id, inv_id))
+ cr.execute('insert into sale_order_line_invoice_rel (order_line_id,invoice_id) values (%s,%s)', (line.id, inv_id))
self.write(cr, uid, [line.id], {'invoiced':True})
create_ids.append(inv_id)
return create_ids
+ def button_cancel(self, cr, uid, ids, context={}):
+ for line in self.browse(cr, uid, ids, context=context):
+ if line.invoiced:
+ raise osv.except_osv(_('Invalid action !'), _('You can not cancel a sale order line that has already been invoiced !'))
+ return self.write(cr, uid, ids, {'state':'cancel'})
+
def button_confirm(self, cr, uid, ids, context={}):
return self.write(cr, uid, ids, {'state':'confirmed'})
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 41b6d336b4d..03f03ae99cf 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -384,11 +384,11 @@
-
+
-
+
@@ -401,7 +401,8 @@
-
+
+
diff --git a/addons/sale/wizard/wizard_sale_line_invoice.py b/addons/sale/wizard/wizard_sale_line_invoice.py
index f6dd1413c7b..15124b1113c 100644
--- a/addons/sale/wizard/wizard_sale_line_invoice.py
+++ b/addons/sale/wizard/wizard_sale_line_invoice.py
@@ -66,7 +66,7 @@ def _makeInvoices(self, cr, uid, data, context):
return inv_id
for line in pool.get('sale.order.line').browse(cr,uid,data['ids']):
- if not line.invoiced:
+ if (not line.invoiced) and (line.state not in ('draft','cancel')):
if not line.order_id.id in invoices:
invoices[line.order_id.id] = []
line_id = pool.get('sale.order.line').invoice_line_create(cr, uid,
@@ -91,7 +91,7 @@ def _makeInvoices(self, cr, uid, data, context):
il = map(lambda x: x[1], result)
res = make_invoice(order, il)
cr.execute('INSERT INTO sale_order_invoice_rel \
- (order_id,invoice_id) values (%d,%d)', (order.id, res))
+ (order_id,invoice_id) values (%s,%s)', (order.id, res))
return {}
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 4e5463b5245..e74165e8c15 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -234,9 +234,9 @@ class stock_location(osv.osv):
result = []
amount = 0.0
for id in self.search(cr, uid, [('location_id', 'child_of', ids)]):
- cr.execute("select product_uom,sum(product_qty) as product_qty from stock_move where location_dest_id=%s and product_id=%s and state='done' group by product_uom", (id,product_id))
+ cr.execute("select product_uom,sum(product_qty) as product_qty from stock_move where location_dest_id=%s and location_id<>%s and product_id=%s and state='done' group by product_uom", (id,id,product_id))
results = cr.dictfetchall()
- cr.execute("select product_uom,-sum(product_qty) as product_qty from stock_move where location_id=%s and product_id=%s and state in ('done', 'assigned') group by product_uom", (id,product_id))
+ cr.execute("select product_uom,-sum(product_qty) as product_qty from stock_move where location_id=%s and location_dest_id<>%s and product_id=%s and state in ('done', 'assigned') group by product_uom", (id,id,product_id))
results += cr.dictfetchall()
total = 0.0
@@ -465,15 +465,19 @@ class stock_picking(osv.osv):
for pick in self.browse(cr, uid, ids):
wf_service.trg_validate(uid, 'stock.picking', pick.id,
'button_confirm', cr)
- move_ids = [x.id for x in pick.move_lines]
- self.pool.get('stock.move').force_assign(cr, uid, move_ids)
- wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
+ #move_ids = [x.id for x in pick.move_lines]
+ #self.pool.get('stock.move').force_assign(cr, uid, move_ids)
+ #wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
return True
def draft_validate(self, cr, uid, ids, *args):
wf_service = netsvc.LocalService("workflow")
self.draft_force_assign(cr, uid, ids)
for pick in self.browse(cr, uid, ids):
+ move_ids = [x.id for x in pick.move_lines]
+ self.pool.get('stock.move').force_assign(cr, uid, move_ids)
+ wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
+
self.action_move(cr, uid, [pick.id])
wf_service.trg_validate(uid, 'stock.picking', pick.id , 'button_done', cr)
return True
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index ad16df6d958..e45732b4ae3 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -350,7 +350,7 @@
- >
+
@@ -540,7 +540,10 @@
-
+
@@ -633,7 +636,10 @@
-
+
@@ -821,7 +827,10 @@
-
+
@@ -1005,7 +1014,10 @@
-
+
@@ -1220,7 +1232,10 @@
-
+
diff --git a/addons/warning/warning_view.xml b/addons/warning/warning_view.xml
index 2adba29c996..3f9f7f24ec2 100644
--- a/addons/warning/warning_view.xml
+++ b/addons/warning/warning_view.xml
@@ -13,7 +13,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml
index 8dc80ed2752..7a8d17e47e4 100644
--- a/addons/wiki/wiki_view.xml
+++ b/addons/wiki/wiki_view.xml
@@ -17,7 +17,7 @@
tree
child_ids
-
+
@@ -27,7 +27,7 @@
wiki.groups
form
- |