[IMP] Sale: Sale order line (convert many2many of invoices to many2one)
bzr revid: mra@mra-laptop-20100804045554-eo4r8jooe3cjhdpa
This commit is contained in:
parent
09f96311ff
commit
5c1a6112e8
|
@ -328,7 +328,7 @@ class sale_order(osv.osv):
|
|||
cr.execute('select id from sale_order_line where order_id IN %s and state=%s',(tuple(ids),'cancel'))
|
||||
line_ids = map(lambda x: x[0], cr.fetchall())
|
||||
self.write(cr, uid, ids, {'state': 'draft', 'invoice_ids': [], 'shipped': 0})
|
||||
self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'invoice_lines': [(6, 0, [])]})
|
||||
self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'line_invoice_id': False})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for inv_id in ids:
|
||||
# Deleting the existing instance of workflow for SO
|
||||
|
@ -512,11 +512,10 @@ class sale_order(osv.osv):
|
|||
for sale in self.browse(cr, uid, ids, context=context):
|
||||
for line in sale.order_line:
|
||||
invoiced = False
|
||||
for iline in line.invoice_lines:
|
||||
if iline.invoice_id and iline.invoice_id.state == 'cancel':
|
||||
continue
|
||||
else:
|
||||
invoiced = True
|
||||
if line.line_invoice_id and line.line_invoice_id.invoice_id.state == 'cancel':
|
||||
continue
|
||||
else:
|
||||
invoiced = True
|
||||
self.pool.get('sale.order.line').write(cr, uid, [line.id], {'invoiced': invoiced})
|
||||
self.write(cr, uid, ids, {'state': 'invoice_except', 'invoice_ids': False})
|
||||
return True
|
||||
|
@ -806,7 +805,8 @@ class sale_order_line(osv.osv):
|
|||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sale order lines."),
|
||||
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer", readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),
|
||||
'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
|
||||
# 'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
|
||||
'line_invoice_id': fields.many2one('account.invoice.line','Invoice Line',readonly=True),
|
||||
'invoiced': fields.boolean('Invoiced', readonly=True),
|
||||
'procurement_id': fields.many2one('procurement.order', 'Procurement'),
|
||||
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price'), readonly=True, states={'draft':[('readonly',False)]}),
|
||||
|
@ -918,8 +918,7 @@ class sale_order_line(osv.osv):
|
|||
'note': line.notes,
|
||||
'account_analytic_id': line.order_id.project_id and line.order_id.project_id.id or False,
|
||||
})
|
||||
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})
|
||||
self.write(cr, uid, [line.id], {'invoiced': True, 'line_invoice_id':inv_id})
|
||||
sales[line.order_id.id] = True
|
||||
create_ids.append(inv_id)
|
||||
# Trigger workflow events
|
||||
|
@ -982,7 +981,7 @@ class sale_order_line(osv.osv):
|
|||
context = {}
|
||||
if not default:
|
||||
default = {}
|
||||
default.update({'state': 'draft', 'move_ids': [], 'invoiced': False, 'invoice_lines': []})
|
||||
default.update({'state': 'draft', 'move_ids': [], 'invoiced': False, 'line_invoice_id': False})
|
||||
return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context)
|
||||
|
||||
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
|
||||
|
|
|
@ -175,8 +175,8 @@
|
|||
<field colspan="4" name="notes" nolabel="1"/>
|
||||
</page>
|
||||
<page string="History" groups="base.group_extended">
|
||||
<separator colspan="4" string="Invoice Lines"/>
|
||||
<field colspan="4" name="invoice_lines" nolabel="1"/>
|
||||
<separator colspan="4" string="Invoice"/>
|
||||
<field colspan="2" name="line_invoice_id" nolabel="1"/>
|
||||
<separator colspan="4" string="Stock Moves"/>
|
||||
<field colspan="4" name="move_ids" nolabel="1" widget="many2many"/>
|
||||
</page>
|
||||
|
@ -414,8 +414,8 @@
|
|||
<!-- <page string="Properties" groups="base.group_extended">-->
|
||||
<!-- <field name="property_ids" nolabel="1"/>-->
|
||||
<!-- </page>-->
|
||||
<page string="Invoice Lines" groups="base.group_extended">
|
||||
<field colspan="4" name="invoice_lines" nolabel="1"/>
|
||||
<page string="Invoice" groups="base.group_extended">
|
||||
<field colspan="2" name="line_invoice_id" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="notes" nolabel="1"/>
|
||||
|
|
|
@ -96,7 +96,7 @@ class stock_picking(osv.osv):
|
|||
sale_line_obj = self.pool.get('sale.order.line')
|
||||
if move_line.sale_line_id:
|
||||
sale_line_obj.write(cursor, user, [move_line.sale_line_id.id], {'invoiced':True,
|
||||
'invoice_lines': [(4, invoice_line_id)],
|
||||
'line_invoice_id': invoice_line_id,
|
||||
})
|
||||
return super(stock_picking, self)._invoice_line_hook(cursor, user,
|
||||
move_line, invoice_line_id)
|
||||
|
@ -185,7 +185,7 @@ class stock_picking(osv.osv):
|
|||
'account_analytic_id': account_analytic_id,
|
||||
}, context=context)
|
||||
self.pool.get('sale.order.line').write(cursor, user, [sale_line.id], {'invoiced':True,
|
||||
'invoice_lines': [(6, 0, [invoice_line_id])],
|
||||
'line_invoice_id': invoice_line_id,
|
||||
})
|
||||
|
||||
return result
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
</page>
|
||||
<page string="History" groups="base.group_extended">
|
||||
<separator colspan="4" string="Invoice Lines"/>
|
||||
<field colspan="4" name="invoice_lines" nolabel="1"/>
|
||||
<field colspan="4" name="line_invoice_id" nolabel="1"/>
|
||||
<separator colspan="4" string="Stock Moves"/>
|
||||
<field colspan="4" name="move_ids" nolabel="1" widget="many2many"/>
|
||||
</page>
|
||||
|
|
Loading…
Reference in New Issue